Project

General

Profile

unable to compiled and download to ESP32

Added by Sunphong Thanok 6 months ago

Can't download to esp32. After we create LED blink program and click on Embedded Coder -> build then found error message as attached.

Snap42.jpg View Snap42.jpg 103 KB error message
Snap43.jpg View Snap43.jpg 266 KB

Replies (11)

RE: unable to compiled and download to ESP32 - Added by Chandima Jayaneththi (จันทิมา) 6 months ago

Could you please copy and paste here all the log data from the Simulink Diagnostics Viewer.

RE: unable to compiled and download to ESP32 - Added by Sunphong Thanok 6 months ago

  1. Starting build procedure for: project01
  2. Generating code and artifacts to 'Model specific' folder structure
  3. Generating code into build folder: D:\waijung2_20_10a\mySourceCode\project01_esp32
  4. Invoking Target Language Compiler on project01.rtw
  5. Using System Target File: D:\waijung2_20_10a\targets\esp32\esp32.tlc
  6. Loading TLC function libraries
  7. Initial pass through model to cache user defined code
    .
  8. Caching model source code ### Writing header file project01_types.h ### Writing header file waijung2_hwdrvlib.h ### Writing source file waijung2_hwdrvlib.cpp ### Writing header file project01.h
    . ### Writing header file rtwtypes.h ### Writing source file project01.cpp ### Writing header file project01_private.h ### Writing header file rtmodel.h ### Writing source file ert_main.cpp
  9. TLC code generation complete.
  10. Successful completion of build procedure for: project01
    Waijung 2: Post processing started.
    Warning: Directory already exists. [2 similar]
    Auto compile and download process initiating...
    Toolchain path: /xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
    Toolchain version: esp-2019r2
    Compiler version: 8.2.0
    Python requirements from D:/waijung2_20_10a/targets/esp32/setup/esp-idf\requirements.txt are satisfied.
    Project is not inside a git repository, will not use 'git describe' to determine PROJECT_VER.
    App "waijung2_esp32" version: 1
    CC /cygdrive/d/waijung2_20_10a/mySourceCode/project01_esp32_build_system/build/main/waijung2_hwdrvlib.o
    CC /cygdrive/d/waijung2_20_10a/mySourceCode/project01_esp32_build_system/build/main/ert_main.o
    In file included from D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:21:
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/include/project01.h:37:1: error: unknown type name 'class'
    class project01ModelClass {
    ^~~
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/include/project01.h:37:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    class project01ModelClass {
    ^
    make1: * [/esp-idf/make/component_wrapper.mk:292: waijung2_hwdrvlib.o] Error 1
    make1:
    Waiting for unfinished jobs....
    In file included from D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/ert_main.c:21:
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/include/project01.h:37:1: error: unknown type name 'class'
    class project01ModelClass {
    ^~~
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/include/project01.h:37:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    class project01ModelClass {
    ^
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/ert_main.c: In function 'vTaskFunctionBaseRate':
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/ert_main.c:82:5: error: implicit declaration of function 'project01_step' [-Werror=implicit-function-declaration]
    project01_step();
    ^~~~~~~~~~~~
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/ert_main.c: In function 'app_main':
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/ert_main.c:95:3: error: implicit declaration of function 'project01_initialize' [-Werror=implicit-function-declaration]
    project01_initialize();
    ^~~~~~~~~~~~~~~~~~
    cc1.exe: some warnings being treated as errors
    make1:
    [/esp-idf/make/component_wrapper.mk:292: ert_main.o] Error 1
    make:
    [D:\waijung2_20_10a\targets\esp32\setup\esp-idf/make/project.mk:590: component-main-build] Error 2
    make: *
    * Waiting for unfinished jobs....
  11. Build procedure for project01 aborted due to an error.
    Build Summary 1
    Elapsed: 0.67 sec
    Top model targets built:

Model Action Rebuild Reason =====================================================================
project01 Failed Code generation information file does not exist.

0 of 1 models built (0 models already up to date)
Build duration: 0h 1m 10.479s
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.

RE: unable to compiled and download to ESP32 - Added by Chandima Jayaneththi (จันทิมา) 6 months ago

We need to investigate a little bit on this issue. Could you please attach project01.slx model file and the project01.h file in 'D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/include' file path. We will find a solution for this issue and let you know as soon as possible.

You can attach a file as in the following figure

RE: unable to compiled and download to ESP32 - Added by Sunphong Thanok 6 months ago

Please see both files as attached

RE: unable to compiled and download to ESP32 - Added by Sunphong Thanok 6 months ago

How about to solve my problem?

RE: unable to compiled and download to ESP32 - Added by Chandima Jayaneththi (จันทิมา) 6 months ago

Sorry for the delayed response.

The issue is, Matlab generates the c++ code instead of the c code as in the following log data in the Simulink Diagnostics Viewer.

As in the above reference image all the generated files are .cpp files. It happens because the configurations of the Embedded Coder has been set for the c++ code generation, not for c code generation.

To change it to c code generation please click on 'Embedded C++ Code' and select 'Embedded C Code' as in the following figure

Once the configurations are changed and build the Simulink model again the C code should be generated as follows

Please follow the above steps to solve your problem. And let us know if the problem still persists.

RE: unable to compiled and download to ESP32 - Added by Sunphong Thanok 6 months ago

After we change to c code generation and built the code, but still found the error as attached,

search
  1. Starting build procedure for: project01
  2. Generating code and artifacts to 'Model specific' folder structure
  3. Generating code into build folder: D:\waijung2_20_10a\mySourceCode\project01_esp32
  4. Invoking Target Language Compiler on project01.rtw
  5. Using System Target File: D:\waijung2_20_10a\targets\esp32\esp32.tlc
  6. Loading TLC function libraries
  7. Initial pass through model to cache user defined code
    .
  8. Caching model source code ### Writing header file project01_types.h ### Writing header file waijung2_hwdrvlib.h ### Writing source file waijung2_hwdrvlib.c ### Writing header file project01.h
    . ### Writing header file rtwtypes.h ### Writing source file project01.c ### Writing header file project01_private.h ### Writing source file ert_main.c
  9. TLC code generation complete.
  10. Using toolchain: MinGW64 | gmake (64-bit Windows)
  11. 'D:\waijung2_20_10a\mySourceCode\project01_esp32\project01.mk' is up to date
  12. Successful completion of code generation for: project01
    Waijung 2: Post processing started.
    Warning: Directory already exists. [3 similar]
    Auto compile and download process initiating...
    Toolchain path: /xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
    Toolchain version: esp-2019r2
    Compiler version: 8.2.0
    Python requirements from D:/waijung2_20_10a/targets/esp32/setup/esp-idf\requirements.txt are satisfied.
    Project is not inside a git repository, will not use 'git describe' to determine PROJECT_VER.
    App "waijung2_esp32" version: 1
    CC /cygdrive/d/waijung2_20_10a/mySourceCode/project01_esp32_build_system/build/main/waijung2_hwdrvlib.o
    CC /cygdrive/d/waijung2_20_10a/mySourceCode/project01_esp32_build_system/build/main/ert_main.o
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c: In function 'GPIO_initialize_DigitalOut':
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:30:3: error: implicit declaration of function 'gpio_pad_select_gpio' [-Werror=implicit-function-declaration]
    gpio_pad_select_gpio(2);
    ^~~~~~~~~~~~~~~~~~
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:31:3: error: implicit declaration of function 'gpio_set_direction' [-Werror=implicit-function-declaration]
    gpio_set_direction(2, GPIO_MODE_OUTPUT_OD);
    ^~~~~~~~~~~~~~~~
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:31:25: error: 'GPIO_MODE_OUTPUT_OD' undeclared (first use in this function)
    gpio_set_direction(2, GPIO_MODE_OUTPUT_OD);
    ^~~~~~~~~~~~~~~~~
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:31:25: note: each undeclared identifier is reported only once for each function it appears in
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:32:3: error: implicit declaration of function 'gpio_set_drive_capability' [-Werror=implicit-function-declaration]
    gpio_set_drive_capability(GPIO_NUM_2, GPIO_DRIVE_CAP_2);
    ^~~~~~~~~~~~~~~~~~~~~~~
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:32:29: error: 'GPIO_NUM_2' undeclared (first use in this function)
    gpio_set_drive_capability(GPIO_NUM_2, GPIO_DRIVE_CAP_2);
    ^~~~~~~~
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:32:41: error: 'GPIO_DRIVE_CAP_2' undeclared (first use in this function)
    gpio_set_drive_capability(GPIO_NUM_2, GPIO_DRIVE_CAP_2);
    ^~~~~~~~~~~~~~
    In file included from D:/waijung2_20_10a/targets/esp32/setup/esp-idf/components/driver/include/driver/gpio.h:20,
    from D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/include/waijung2_hwdrvlib.h:23,
    from D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/include/project01.h:22,
    from D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:35:
    D:/waijung2_20_10a/targets/esp32/setup/esp-idf/components/esp_rom/include/esp32/rom/gpio.h: At top level:
    void gpio_pad_select_gpio(uint8_t gpio_num);
    ^~~~~~~~~~~~~~~~~~
    D:/waijung2_20_10a/mySourceCode/project01_esp32_build_system/main/waijung2_hwdrvlib.c:30:3: note: previous implicit declaration of 'gpio_pad_select_gpio' was here
    gpio_pad_select_gpio(2);
    ^~~~~~~~~~~~~~~~~~
    cc1.exe: some warnings being treated as errors
    make1: * [/esp-idf/make/component_wrapper.mk:292: waijung2_hwdrvlib.o] Error 1
    make1:
    Waiting for unfinished jobs....
    make:
    [D:\waijung2_20_10a\targets\esp32\setup\esp-idf/make/project.mk:590: component-main-build] Error 2
    make: *
    Waiting for unfinished jobs....
  13. Build procedure for project01 aborted due to an error.
    Build Summary 1
    Elapsed: 0.4 sec
    Top model targets built:
Model Load  1 
09:11 PM Elapsed: 0.6 sec
Model Save (project01)
09:11 PM Elapsed: 0.166 sec
Update Diagram
09:11 PM Elapsed: 0.281 sec
Update Diagram
09:11 PM Elapsed: 0.275 sec
Build 10 3 7
09:11 PM Elapsed: 41 sec
Top Model Build 9 3 6
Elapsed: 41 sec

Model Action Rebuild Reason =====================================================================
project01 Failed Code generation information file does not exist.

0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 41.258s
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

RE: unable to compiled and download to ESP32 - Added by Chandima Jayaneththi (จันทิมา) 6 months ago

Is it the same model that you attached before?
Can you try deleting the project01_esp32 folder and project01_esp32_build_system folder, building the model again and let us know whether the problem still there.

RE: unable to compiled and download to ESP32 - Added by Sunphong Thanok 6 months ago

Now, we can download by create new project but LED2 on esp32 not blink. Refer as schematic as attached.

RE: unable to compiled and download to ESP32 - Added by Chandima Jayaneththi (จันทิมา) 6 months ago

Sunphong Thanok wrote:

Now, we can download by create new project but LED2 on esp32 not blink. Refer as schematic as attached.

Glad to hear that the model can be compiled and downloaded without any error.

One of the reasons for not blinking the LED is current pin configuration in digital output block is set to Open drain. According to the schematic, GPIO2 should be configured as Push-pull. It can be configured as in the following figure.

And let us know whether the problem is still persists.

RE: unable to compiled and download to ESP32 - Added by Sunphong Thanok 6 months ago

Ohh, It's big mistake for me and now program it work well. Thanks for all that you replied to me.

    (1-11/11)