Forums » Req. WJ2(ESP32) support »
ESP32 demo cannot be successfully compiled in MATLAB/Simulink
Added by Leonard GUO over 1 year ago
Software:
MATLAB2020b.
Waijung 2 Version 22.12a
Hello,
I just installed Waijung2 in my computer. And I build the 1st demo that provided in Waijung2 software package "D:\waijung2\targets\esp32\demo\digital_output_demo\"
Then I met the follow error.
Error massage:
The call to esp32_make_rtw_hook, during the exit hook generated the following error:
An error occurred in Auto compile and download process. Please refer the log data above.
The build process will terminate as a result.
Caused by:
An error occurred in Auto compile and download process. Please refer the log data above.
________________________________________________________________
- Starting build procedure for: esp32_digital_output_demo
End of entry - Generating code and artifacts to 'Model specific' folder structure
- Generating code into build folder: D:\ESP32_slx\digital_output_demo\esp32_digital_output_demo_esp32
- Invoking Target Language Compiler on esp32_digital_output_demo.rtw
- Using System Target File: D:\waijung2\targets\esp32\esp32.tlc
- Loading TLC function libraries
- Generating TLC interface API for custom data
. - Initial pass through model to cache user defined code
. - Caching model source code
### Writing header file esp32_digital_output_demo_types.h
### Writing header file waijung2_hwdrvlib.h
### Writing source file waijung2_hwdrvlib.c
### Writing header file esp32_digital_output_demo.h
. ### Writing header file rtwtypes.h ### Writing source file esp32_digital_output_demo.c ### Writing header file esp32_digital_output_demo_private.h ### Writing header file rtmodel.h
. ### Writing source file ert_main.c - TLC code generation complete.
. - Processing Template Makefile: D:\waijung2\targets\esp32\src\esp32.tmf
- Created makefile D:\ESP32_slx\digital_output_demo\esp32_digital_output_demo_esp32\esp32_digital_output_demo.mk
- Building esp32_digital_output_demo: .\esp32_digital_output_demo.bat
Top Model Build 2 2
Elapsed: 1:19 min
Waijung 2: System information
Computer: PCWIN64
Operating System: Microsoft Windows 10 רҵ°æ
Matlab: 9.9.0.1467703 (R2020b)
Waijung 2 version: 22.12a
Waijung 2 root: D:\waijung2
Waijung 2 System Target File: esp32.tlc
Waijung 2: 'RTWVerbose' is: 'on'
Waijung 2: SimulationMode is: 'normal'
Waijung 2: Removing remaing source files from previous build
D:\ESP32_slx\digital_output_demo\esp32_digital_output_demo_esp32>set MATLAB=C:\MATLAB\Polyspace\R2020b
D:\ESP32_slx\digital_output_demo\esp32_digital_output_demo_esp32>"C:\MATLAB\Polyspace\R2020b\bin\win64\gmake" -f esp32_digital_output_demo.mk GENERATE_ASAP2=0 OPTS="-DTID01EQ=0"- BUILD_MODE : real_time
- PRODUCT : esp32_digital_output_demo.out
- SHRLIBTARGET : 0
- MODULES : ert_main.c esp32_digital_output_demo.c waijung2_hwdrvlib.c rt_main.c
- MODELREF_TARGET_TYPE : NONE
- MAKEFILEBUILDER_TGT : 0
- STANDALONE_SUPPRESS_EXE : 0
- Source ert_main.c done
- Source esp32_digital_output_demo.c done
- Source waijung2_hwdrvlib.c done
- Ending esp32_digital_output_demo.out real_time
- Created esp32_digital_output_demo.out successfully (or it was already up to date)
- Successful completion of build procedure for: esp32_digital_output_demo
Waijung 2: Post processing started.
Warning: Directory already exists. [2 similar]
Waijung 2: Deleting pre-built src files.
Waijung 2: Copying required header and source files to the target build directory.- wj2_blockref checked
Waijung 2: Auto compile and download process started
[1/11] Performing build step for 'bootloader'
[1/1] cmd.exe /C "cd /D D:\ESP32_slx\digital_output_demo\esp32_digital_output_demo_esp32_build_system\build\bootloader\esp-idf\esptool_py && D:\waijung2\targets\esp32\setup\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe D:/waijung2/targets/esp32/setup/esp_idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 D:/ESP32_slx/digital_output_demo/esp32_digital_output_demo_esp32_build_system/build/bootloader/bootloader.bin"
Bootloader binary size 0x62d0 bytes. 0xd30 bytes (12%) free.
[2/9] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/ert_main.c.obj
[3/9] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/esp32_digital_output_demo.c.obj
[4/9] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/waijung2_hwdrvlib.c.obj
[5/9] Linking C static library esp-idf\main\libmain.a
[6/9] Generating ld/sections.ld
[7/9] Linking CXX executable waijung2_esp32.elf
[8/9] Generating binary image from built executable
esptool.py v3.2-dev
Merged 2 ELF sections
Generated D:/ESP32_slx/digital_output_demo/esp32_digital_output_demo_esp32_build_system/build/waijung2_esp32.bin
[9/9] cmd.exe /C "cd /D D:\ESP32_slx\digital_output_demo\esp32_digital_output_demo_esp32_build_system\build\esp-idf\esptool_py && D:\waijung2\targets\esp32\setup\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe D:/waijung2/targets/esp32/setup/esp_idf/components/partition_table/check_sizes.py --offset 0x8000 partition --type app D:/ESP32_slx/digital_output_demo/esp32_digital_output_demo_esp32_build_system/build/partition_table/partition-table.bin D:/ESP32_slx/digital_output_demo/esp32_digital_output_demo_esp32_build_system/build/waijung2_esp32.bin"
waijung2_esp32.bin binary size 0x2abc0 bytes. Smallest app partition is 0x100000 bytes. 0xd5440 bytes (83%) free.
Executing action: all (aliases: build)
Running ninja in directory d:\esp32_slx\digital_output_demo\esp32_digital_output_demo_esp32_build_system\build
Executing "ninja all"...
- wj2_blockref checked
D:\waijung2\targets\esp32\setup\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe ..\..\..\waijung2\targets\esp32\setup\esp_idf\components\esptool_py\esptool\esptool.py -p (PORT) -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 build\bootloader\bootloader.bin 0x8000 build\partition_table\partition-table.bin 0x10000 build\waijung2_esp32.bin
or run 'idf.py -p (PORT) flash'
Waijung 2: Downloading to the target
[1/5] cmd.exe /C "cd /D D:\ESP32_slx\digital_output_demo\esp32_digital_output_demo_esp32_build_system\build\esp-idf\esptool_py && D:\waijung2\targets\esp32\setup\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe D:/waijung2/targets/esp32/setup/esp_idf/components/partition_table/check_sizes.py --offset 0x8000 partition --type app D:/ESP32_slx/digital_output_demo/esp32_digital_output_demo_esp32_build_system/build/partition_table/partition-table.bin D:/ESP32_slx/digital_output_demo/esp32_digital_output_demo_esp32_build_system/build/waijung2_esp32.bin"
waijung2_esp32.bin binary size 0x2abc0 bytes. Smallest app partition is 0x100000 bytes. 0xd5440 bytes (83%) free.
[2/5] Performing build step for 'bootloader'
[1/1] cmd.exe /C "cd /D D:\ESP32_slx\digital_output_demo\esp32_digital_output_demo_esp32_build_system\build\bootloader\esp-idf\esptool_py && D:\waijung2\targets\esp32\setup\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe D:/waijung2/targets/esp32/setup/esp_idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 D:/ESP32_slx/digital_output_demo/esp32_digital_output_demo_esp32_build_system/build/bootloader/bootloader.bin"
Bootloader binary size 0x62d0 bytes. 0xd30 bytes (12%) free.
[2/3] cmd.exe /C "cd /D D:\waijung2\targets\esp32\setup\esp_idf\components\esptool_py && D:\waijung2\targets\esp32\setup\.espressif\tools\cmake\3.20.3\bin\cmake.exe -D IDF_PATH="D:/waijung2/targets/esp32/setup/esp_idf" -D SERIAL_TOOL="D:/waijung2/targets/esp32/setup/.espressif/python_env/idf4.4_py3.8_env/Scripts/python.exe D:/waijung2/targets/esp32/setup/esp_idf/components/esptool_py/esptool/esptool.py --chip esp32" -D SERIAL_TOOL_ARGS="--before=default_reset --after=hard_reset write_flash @flash_args" -D WORKING_DIRECTORY="D:/ESP32_slx/digital_output_demo/esp32_digital_output_demo_esp32_build_system/build" -P D:/waijung2/targets/esp32/setup/esp_idf/components/esptool_py/run_serial_tool.cmake"
esptool.py esp32 -p COM8 -b 115200 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 bootloader/bootloader.bin 0x10000 waijung2_esp32.bin 0x8000 partition_table/partition-table.bin
esptool.py v3.2-dev
Serial port COM8
Connecting......................................
A fatal error occurred: Failed to connect to ESP32: Wrong boot mode detected (0x13)! The chip needs to be in download mode.
For troubleshooting steps visit: https://github.com/espressif/esptool#troubleshooting
CMake Error at run_serial_tool.cmake:56 (message):
D:/waijung2/targets/esp32/setup/.espressif/python_env/idf4.4_py3.8_env/Scripts/python.exe
D:/waijung2/targets/esp32/setup/esp_idf/components/esptool_py/esptool/esptool.py
--chip esp32 failed
FAILED: CMakeFiles/flash
cmd.exe /C "cd /D D:\waijung2\targets\esp32\setup\esp_idf\components\esptool_py && D:\waijung2\targets\esp32\setup\.espressif\tools\cmake\3.20.3\bin\cmake.exe -D IDF_PATH="D:/waijung2/targets/esp32/setup/esp_idf" -D SERIAL_TOOL="D:/waijung2/targets/esp32/setup/.espressif/python_env/idf4.4_py3.8_env/Scripts/python.exe D:/waijung2/targets/esp32/setup/esp_idf/components/esptool_py/esptool/esptool.py --chip esp32" -D SERIAL_TOOL_ARGS="--before=default_reset --after=hard_reset write_flash @flash_args" -D WORKING_DIRECTORY="D:/ESP32_slx/digital_output_demo/esp32_digital_output_demo_esp32_build_system/build" -P D:/waijung2/targets/esp32/setup/esp_idf/components/esptool_py/run_serial_tool.cmake"
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Executing action: flash
Running ninja in directory d:\esp32_slx\digital_output_demo\esp32_digital_output_demo_esp32_build_system\build
Executing "ninja flash"...
- Build procedure for esp32_digital_output_demo aborted due to an error.
Build Summary 1
Elapsed: 0.4 sec
Top model targets built:
Model Action Rebuild Reason
=====================================================================================
esp32_digital_output_demo Failed Code generation information file does not exist.
0 of 1 models built (0 models already up to date)
Build duration: 0h 1m 19.978s
The call to esp32_make_rtw_hook, during the exit hook generated the following error:
An error occurred in Auto compile and download process. Please refer the log data above.
The build process will terminate as a result.
Caused by:
An error occurred in Auto compile and download process. Please refer the log data above.
Component:Simulink | Category:Block diagram error
___________________________________________________________
DOUT_demo_slx.png | View DOUT_demo_slx.png | 89.6 KB | |||
Error.png | View Error.png | 71.9 KB | |||
esp32_digital_output_demo.slx | esp32_digital_output_demo.slx | 33.2 KB |
Replies (2)
RE: ESP32 demo cannot be successfully compiled in MATLAB/Simulink - Added by Parth Maheshwari (พาร์ท) over 1 year ago
Hello Liang Guo,
Thank you for reaching out and for attaching the entire message from the diagnostic viewer.
Some ESP32 boards don't go into flash/download mode automatically when you try to deploy new code to them (refer to the error I have highlighted from your diagnostic viewer). Your board is one of them.
There is a simple solution (but you will have to do this every time you want to deploy code to this ESP32 board of yours), and there is a permanent solution.
Simple solution: as soon as you see the message "Waijung 2: Downloading to the target" (you will see this message towards the end of the build process as this is the last step), please hold down on the BOOT/FLASH button on your ESP32 until the build procedure is complete . This will restart the chip and put it into download mode and fix the problem.
Permanent solution - you can solder a 10 uF electrolytic capacitor between the EN and GND pins of your ESP32
Hope this helps.
Sincere regards,
Parth Maheshwari
RE: ESP32 demo cannot be successfully compiled in MATLAB/Simulink - Added by Leonard GUO over 1 year ago
Dear Parth,
Thank you for your quick response to my question. I'm glad it worked with your help.
Best regards.
Leonard