Building simulink model on Arduino Mega 2560

14 views (last 30 days)
Hello,
I've been trying to get my Simulink model onto the Arduino Mega 2560 for some time now. Unfortunately, I always get an error message. After I was able to solve some error messages, there is this error message which is just not solvable for me:
--------------------------------------------------------------------------------------------------------------------------------------
### Starting build procedure for: Real_Model
### Generating code and artifacts to 'Model specific' folder structure
### Generating code into build folder: C:\Users\filip\seminararbeit\Real_Model_ert_rtw
### Invoking Target Language Compiler on Real_Model.rtw
### Using System Target File: C:\Program Files\MATLAB\R2021a\rtw\c\ert\ert.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Writing header file Real_Model_types.h
### Writing source file Real_Model.c
### Writing header file Real_Model_private.h
.
### Writing header file Real_Model.h
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
### Writing header file rtGetNaN.h
### Writing source file rtGetNaN.c
### Writing header file rt_defines.h
.
### Writing header file rt_nonfinite.h
### Writing source file rt_nonfinite.c
### Writing header file rtGetInf.h
### Writing source file rtGetInf.c
### Writing header file rtmodel.h
### Writing source file Real_Model_data.c
### Writing source file ert_main.c
.
### TLC code generation complete.
### Evaluating PostCodeGenCommand specified in the model
### Using toolchain: Arduino AVR
### Creating 'C:\Users\filip\seminararbeit\Real_Model_ert_rtw\Real_Model.mk' ...
### Building 'Real_Model': "C:\PROGRA~1\MATLAB\R2021a\bin\win64\gmake" -f wrapper.mk all
C:\Users\filip\seminararbeit\Real_Model_ert_rtw>cd .
C:\Users\filip\seminararbeit\Real_Model_ert_rtw>chcp 1252
Aktive Codepage: 1252.
C:\Users\filip\seminararbeit\Real_Model_ert_rtw>if "" == "" ("C:\PROGRA~1\MATLAB\R2021a\bin\win64\gmake" -f wrapper.mk all ) else ("C:\PROGRA~1\MATLAB\R2021a\bin\win64\gmake" -f wrapper.mk )
"### Generating static library."
"C:/Program Files/MATLAB/R2021a/bin/win64/gmake" -j5 -C "C:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/SUPPOR~1/ARDUIN~2/STATIC~1" SHELL="%SystemRoot%/system32/cmd.exe" -f avrcore.mk all
gmake[1]: Entering directory `C:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/SUPPOR~1/ARDUIN~2/STATIC~1'
"### Successfully generated libcore.a library."
gmake[1]: Leaving directory `C:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/SUPPOR~1/ARDUIN~2/STATIC~1'
"C:/Program Files/MATLAB/R2021a/bin/win64/gmake" -j5 SHELL="%SystemRoot%/system32/cmd.exe" -f "Real_Model.mk" all
gmake[1]: Entering directory `C:/Users/filip/seminararbeit/Real_Model_ert_rtw'
"C:/ProgramData/MATLAB/SupportPackages/R2021a/aIDE/hardware/tools/avr/bin/avr-g++" -std=gnu++11 -fpermissive -fno-exceptions -fno-threadsafe-statics -c -w -ffunction-sections -fdata-sections -MMD -DARDUINO=10801 -MMD -MP -MF"Wire.dep" -MT"Wire.o" -Os -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_MEGA2560_ -DARDUINO_NUM_SERIAL_PORTS=4 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DMW_TIMERID=1 -DMW_PRESCALAR=64 -DMW_TIMERCOUNT=63911 -DMW_SCHEDULERCOUNTER=1 -DARDUINO_NUM_SERIAL_PORTS=4 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_BAUDRATE_SERIAL2_=9600 -D_RTT_BAUDRATE_SERIAL3_=9600 -D_RTT_ANALOG_REF_=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=1 -DXCP_CUSTOM_PLATFORM -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=Real_Model -DNUMST=2 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -IC:/Users/filip/seminararbeit -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/aIDE/hardware/arduino/avr/LIBRAR~1/Wire -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/aIDE/hardware/arduino/avr/LIBRAR~1/Wire/utility -IC:/Users/filip/AppData/Roaming/MATHWO~1/MATLAB~1/COLLEC~1/RENSSE~1/RASPlib/include -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/aIDE/hardware/arduino/avr/LIBRAR~1/Wire/src -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/aIDE/hardware/arduino/avr/LIBRAR~1/Wire/src/utility -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/shared/svd/include -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/SUPPOR~1/ARDUIN~2/include -IC:/Users/filip/AppData/Roaming/MATHWO~1/MATLAB~1/COLLEC~1/RENSSE~1/RASPlib/src -IC:/Users/filip/seminararbeit/Real_Model_ert_rtw -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/ert -IC:/ProgramData/MATLAB/SupportPackages/R2021a/aIDE/hardware/arduino/avr/cores/arduino -IC:/ProgramData/MATLAB/SupportPackages/R2021a/aIDE/hardware/arduino/avr/variants/mega -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/SUPPOR~1/ARDUIN~1/include -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/SUPPOR~1/ARDUIN~1/SCHEDU~1/include -IC:/ProgramData/MATLAB/SupportPackages/R2021a/aIDE/hardware/tools/avr/avr/include/avr -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/shared/EXTERN~1/include -o "Wire.o" "C:/ProgramData/MATLAB/SupportPackages/R2021a/aIDE/hardware/arduino/avr/libraries/Wire/Wire.cpp"
[...]
"C:/ProgramData/MATLAB/SupportPackages/R2021a/aIDE/hardware/tools/avr/bin/avr-gcc" -std=gnu11 -c -w -ffunction-sections -fdata-sections -MMD -DARDUINO=10801 -MMD -MP -MF"ert_main.dep" -MT"ert_main.o" -Os -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_MEGA2560_ -DARDUINO_NUM_SERIAL_PORTS=4 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DMW_TIMERID=1 -DMW_PRESCALAR=64 -DMW_TIMERCOUNT=63911 -DMW_SCHEDULERCOUNTER=1 -DARDUINO_NUM_SERIAL_PORTS=4 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_BAUDRATE_SERIAL2_=9600 -D_RTT_BAUDRATE_SERIAL3_=9600 -D_RTT_ANALOG_REF_=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=1 -DXCP_CUSTOM_PLATFORM -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=Real_Model -DNUMST=2 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -IC:/Users/filip/seminararbeit -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/aIDE/hardware/arduino/avr/LIBRAR~1/Wire -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/aIDE/hardware/arduino/avr/LIBRAR~1/Wire/utility -IC:/Users/filip/AppData/Roaming/MATHWO~1/MATLAB~1/COLLEC~1/RENSSE~1/RASPlib/include -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/aIDE/hardware/arduino/avr/LIBRAR~1/Wire/src -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/aIDE/hardware/arduino/avr/LIBRAR~1/Wire/src/utility -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/shared/svd/include -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/SUPPOR~1/ARDUIN~2/include -IC:/Users/filip/AppData/Roaming/MATHWO~1/MATLAB~1/COLLEC~1/RENSSE~1/RASPlib/src -IC:/Users/filip/seminararbeit/Real_Model_ert_rtw -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/ert -IC:/ProgramData/MATLAB/SupportPackages/R2021a/aIDE/hardware/arduino/avr/cores/arduino -IC:/ProgramData/MATLAB/SupportPackages/R2021a/aIDE/hardware/arduino/avr/variants/mega -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/SUPPOR~1/ARDUIN~1/include -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/SUPPOR~1/ARDUIN~1/SCHEDU~1/include -IC:/ProgramData/MATLAB/SupportPackages/R2021a/aIDE/hardware/tools/avr/avr/include/avr -IC:/PROGRA~3/MATLAB/SUPPOR~1/R2021a/toolbox/target/shared/EXTERN~1/include -o "ert_main.o" "C:/Users/filip/seminararbeit/Real_Model_ert_rtw/ert_main.c"
gmake[1]: *** [Real_Model.o] Error 1
gmake[1]: *** Waiting for unfinished jobs....
gmake[1]: Leaving directory `C:/Users/filip/seminararbeit/Real_Model_ert_rtw'
gmake: *** [all] Error 2
C:\Users\filip\seminararbeit\Real_Model_ert_rtw>echo The make command returned an error of 2
The make command returned an error of 2
C:\Users\filip\seminararbeit\Real_Model_ert_rtw>exit /B 1
---------------------------------------------------------------------------------------
I would be very grateful for your help.
  2 Comments
Filip Poloczek
Filip Poloczek on 18 Jan 2022
Edited: Filip Poloczek on 18 Jan 2022
Is it possible, that the space in the path:
C:\Program Files\MATLAB\R2021a\rtw\c\ert\ert.tlc
(Space in Program Files)
results in a problem?
Infinite_king
Infinite_king on 8 Feb 2024
It shouldn't be a problem. However, you can try changing the location to one where there are no spaces in the path, and then try to compile the model.

Sign in to comment.

Answers (1)

Infinite_king
Infinite_king on 8 Feb 2024
Hi Filip Poloczek,
It seems like there is an error during the build process of your Simulink model for the Arduino Mega 2560 target. From the log, we can see that 'gmake' has encountered an error while compiling Real_Model.c. This typically indicates a syntax error. I would suggest you to review the model for any unsupported blocks. Try the following example to make sure everything was set correctly, https://www.mathworks.com/help/supportpkg/arduino/ref/getting-started-with-arduino-hardware.html
In addition, try the below general troubleshooting steps,
  1. Ensure that your Simulink model is configured correctly for the Arduino Mega 2560 target. Check the target settings, including hardware configuration, compiler options, and other relevant settings.
  2. Make sure you are using the latest version of MATLAB and the support packages for Arduino. Updates often include bug fixes and improvements that could resolve the issue you're encountering.
  3. Finally, examine the generated C code (Real_Model.c and other related files) to identify any errors or inconsistencies.
Hope this is helpful.

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!