If your Simulink Model (with Waijung 2) takes time to build and flash the ESP32 (normally it will take about 3 - 4 minutes for the first build), check the Task Manager whether the CPU usage is high with the Antivirus Guard (usually Microsoft Defender). If the CPU usage on Microsoft Defender is high, please follow the following steps to add the exclusions to the Microsoft Defender.
Step 1: Go to Settings and then select Update & Security
Step 2: Go to Windows Security and go to Virus & threat protection
Step 3: Click on Manage setting under Virus & threat protection settings
Step 4: Go to Add or remove exclusions under Exclusions
Step 4: By clicking on Add an exclusion you can add the exclusions to the Matlab folder, Waijung2 folder (ex: waijung2_20.10a folder) and if your model files are in a separate folder add and exclusion for that folder also.
Note: If you are using other Antivirus Guard software, the procedure will be different.
Possible cause 1: Some ESP32 development boards don’t go into flashing/uploading mode automatically when uploading a new code. This means that when you try to upload a new sketch to your ESP32, the ESP IDF fails to connect to your board, and you get the above error message.
A solution to this problem can be found in this blog