MATLAB Answers

2

Arduino MKR1000 + Simulink: build procedure aborted due to error

Asked by CJ Godfrey on 27 Jun 2018
Latest activity Answered by James Hill on 4 Mar 2019
I am following the Arduino Engineering Kit instructions; 2.3 Simulink Getting Started. Upon compiling the myDCMotorControl model I get the following error message:
/Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/supportpackages/arduinobase/src/MW_PWM.cpp:6:21: fatal error: Arduino.h: No such file or directory
#include "Arduino.h"
^
compilation terminated.
gmake: *** [MW_PWM.o] Error 1
### Build procedure for model: 'myDCMotorControl' aborted due to an error.
I understand that the C file is looking for the arduino.h file but I don't know why Simulink can't find it or how to fix it.
Full diagnostics here:
/Users/cj/Documents/matlab/SupportPackages/R2018a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -std=gnu++11 -fno-threadsafe-statics -fno-rtti -fno-exceptions -Os -c -g -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=10801 -MMD -MP -MF"MW_PWM.dep" -MT"MW_PWM.o" -MMD -mcpu=cortex-m0plus -fpermissive -DF_CPU=48000000L -DARDUINO_SAMD_MKR1000 -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x824e -DUSBCON -DUSB_MANUFACTURER=\""Unknown\"" -DUSB_PRODUCT=\""Genuino MKR1000\"" -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_MKR1000_ -DMODEL=myDCMotorControl -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DUNIX -DON_TARGET_WAIT_FOR_START=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DRT -DMW_TIMERID=9 -DMW_PRESCALAR=256 -DMW_TIMERCOUNT=18750 -DMW_SCHEDULERCOUNTER=1 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_ANALOG_REF_=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DON_TARGET_WAIT_FOR_START=1 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=myDCMotorControl -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DUNIX -I/Users/cj/Documents/matlab/Add-Ons/Toolboxes/Arduino\ Engineering\ Kit\ Project\ Files/code/work -I/Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/shared/svd/include -I/Users/cj/Documents/matlab/Add-Ons/Toolboxes/Arduino\ Engineering\ Kit\ Project\ Files/code/work/myDCMotorControl_ert_rtw -I/Applications/MATLAB_R2018a.app/extern/include -I/Applications/MATLAB_R2018a.app/simulink/include -I/Applications/MATLAB_R2018a.app/rtw/c/src -I/Applications/MATLAB_R2018a.app/rtw/c/src/ext_mode/common -I/Applications/MATLAB_R2018a.app/rtw/c/ert -I/Applications/MATLAB_R2018a.app/toolbox/coder/rtiostream/src/utils -I/Users/cj/Documents/matlab/SupportPackages/R2018a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include -I/Users/cj/Documents/matlab/SupportPackages/R2018a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/CMSIS-Atmel/1.1.0/CMSIS/Device/ATMEL -I/Users/cj/Documents/matlab/SupportPackages/R2018a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.12/cores/arduino -I/Users/cj/Documents/matlab/SupportPackages/R2018a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.12/variants/mkr1000 -I/Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/supportpackages/arduinotarget/include -I/Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/supportpackages/arduinotarget/scheduler/include -I/Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/supportpackages/armcortexmbase/scheduler/include -I/Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/supportpackages/arduinobase/include -I/Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/shared/externalmode_daemon/include -o MW_PWM.o /Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/supportpackages/arduinobase/src/MW_PWM.cpp
/Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/supportpackages/arduinobase/src/MW_PWM.cpp:6:21: fatal error: Arduino.h: No such file or directory
#include "Arduino.h"
^
compilation terminated.
gmake: *** [MW_PWM.o] Error 1
### Build procedure for model: 'myDCMotorControl' aborted due to an error.
Error(s) encountered while building "myDCMotorControl":
### Failed to generate all binary outputs.

  3 Comments

Hi CJ,
Can you try running the arduino_communication model in external mode on the MKR1000? This will tell us if there is something wrong with the support package installation or not.
Regards, Madhu
I ran the arduino_communication model. I get the same error:
/Users/cj/Documents/matlab/SupportPackages/R2018a/toolbox/target/supportpackages/arduinobase/src/MW_digitalio.cpp:1:21: fatal error: Arduino.h: No such file or directory
#include <Arduino.h>
^
compilation terminated.
gmake: *** [MW_digitalio.o] Error 1
### Build procedure for model: 'arduino_communication' aborted due to an error.
Error(s) encountered while building "arduino_communication":
### Failed to generate all binary outputs.
This makes me believe that the support package for Simulink was not installed properly. Could you uninstall and reinstall this support with administrator access?
The way to do it would be (I am guessing you are in Mac OS)-
1) Uninstall the Simulink support package for Arduino and then close MATLAB. 2) From Command prompt of Mac type sudo matlab 3) Reinstall the Simulink support package for Arduino 4) Try the arduino_communication model in external mode and in normal mode.
If all of this fails, I would strongly recommend reaching out to MathWorks Technical Support letting them know what you have tried so far and asking why you are receiving this error.
HTH, Madhu

Sign in to comment.

4 Answers

Answer by CJ Godfrey on 30 Jun 2018
 Accepted Answer

I was able to get this working. I already had the arduino IDE installed on my machine from other projects before installing Matlab, Simulink and hardware support packages. I uninstalled hardware support packages, then uninstalled Arduino IDE, then reinstalled hardware support packages and the simulink model compilation worked fine.
This was on MacOS High Sierra

  1 Comment

I am glad you got it working. Now waiting eagerly to see your version of the project. Please do share it with us in MATLAB Central Community.

Sign in to comment.


Answer by Emanuel Bombasaro on 4 Aug 2018
Edited by Emanuel Bombasaro on 5 Aug 2018

Uninstalling all Arduino Hardware related packages and re installing them following this order:
  1. MATLAB Support Package for Arduino Hardware
  2. Simulink Support Package for Arduino Hardware
  3. MATLAB Support Package for USB Webcams
  4. Arduino Engineering Kit Hardware Support
just a hint, when installing MATLAB Support Package for Arduino Hardware a terminal window opens on Mac OS installing parts in the background. Wait for it to finish, it may take a while.
Arduino IDE, was installed and no need to uninstall.
Cheers,

  2 Comments

Another user also mentioned the same about the new terminal window popping up which they kept closing.
Hopefully that hint helps everyone else.
Regards, Madhu
Thanks a lot, this workaround work great ( R2018b, win10, mkr1000 ) and solve the issue of not being able to use simulink, anyway I notice that during the setup of the simulink support package for arduino, test connection failed

Sign in to comment.


Answer by Suan Ruey Foo on 7 Aug 2018

Hi all. I am also having the same issue too. The difference here is that I am using a Windows 8.1 OS to run the application. I am also gonna try out your troubleshooting method, except for the command prompt.
I will update here again if there is any issue.

  1 Comment

Can you try out the suggestion that Emanuel has provided.

Sign in to comment.


Answer by James Hill on 4 Mar 2019

Emanuel's Solution worked for me as well. The order of operations do rewrite and reconfigure.
I would make a distinction ( <=R2018a and >=R2018b ) on Emanuel's posting and turning those downloads into the appropriate links:
However, I am obliged to point out the following:
link compile linking and make files we have this:
-I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.18/cores/arduino
-I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.18/variants/mkr1000
Prior to uninstalling I had this:
find /home/gilgamesh007 -name "Arduino.h" >> ArduinoHeader.txt
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/arduino-1.8.1/hardware/arduino/avr/cores/arduino/Arduino.h
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/avr/1.6.23/cores/arduino/Arduino.h
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/sam/1.6.12/cores/arduino/Arduino.h
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.20/cores/arduino/Arduino.h
After reinstallation:
find /home/gilgamesh007 -name "Arduino.h"
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/arduino-1.8.1/hardware/arduino/avr/cores/arduino/Arduino.h
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/sam/1.6.11/cores/arduino/Arduino.h
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.18/cores/arduino/Arduino.h

  0 Comments

Sign in to comment.