Simulink fails to build & upload to Arduino

3 vues (au cours des 30 derniers jours)
Valeriy
Valeriy le 12 Sep 2023
Commenté : Valeriy le 1 Oct 2023
Hello,
I ran hardware setup wizard successfully to connect Arduino Micro to Simulink. The board got detected and the test program was uploaded and executed by the wizard (presumably, the data light was flashing). The wizard detected the board parameters and seems to be happy.
After going to Simulink and adding a Read Analog Sensor block or Read Serial Port block connected to a Scope, clicking the build button builds the program successfully. When I click Deploy and Start, then the same build fails with C compiler errors.
The settings look like this:
I have Arduino Micro picked on the Hardware tab:
Clicking Monitor & Tune or Build, Deploy & Start fails with the following errors in the output pane:
arduinotarget/scheduler/include/arduinoAVRScheduler.h:16:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean disable_rt_OneStep(void);
^~~~~~~
boolean_T
arduinotarget/scheduler/include/arduinoAVRScheduler.h:18:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean MW_Arduino_Loop(void);
^~~~~~~
boolean_T
arduinobase/src/MW_SerialRead.cpp: In function 'uint32_t getCurrentTime()':
arduinobase/src/MW_SerialRead.cpp:14:10: error: 'millis' was not declared in this scope
return millis();
^~~~~~
arduinobase/src/MW_SerialRead.cpp: In function 'void MW_Serial0_read(char*, uint16_t)':
arduinobase/src/MW_SerialRead.cpp:21:5: error: 'Serial' was not declared in this scope
Serial.readBytes(bufferData,DataSizeInBytes);
^~~~~~
arduinobase/src/MW_SerialRead.cpp: In function 'int MW_Serial0_available()':
arduinobase/src/MW_SerialRead.cpp:27:18: error: 'Serial' was not declared in this scope
BufferSize = Serial.available();
^~~~~~
arduinobase/src/MW_SerialRead.cpp: In function 'void MW_Serial1_read(char*, uint16_t)':
arduinobase/src/MW_SerialRead.cpp:35:13: error: 'Serial1' was not declared in this scope
Serial1.readBytes(bufferData,DataSizeInBytes);
^~~~~~~
arduinobase/src/MW_SerialRead.cpp:35:13: note: suggested alternative: 'Serial_read'
Serial1.readBytes(bufferData,DataSizeInBytes);
^~~~~~~
Serial_read
arduinobase/src/MW_SerialRead.cpp: In function 'int MW_Serial1_available()':
arduinobase/src/MW_SerialRead.cpp:41:26: error: 'Serial1' was not declared in this scope
BufferSize = Serial1.available();
^~~~~~~
arduinobase/src/MW_SerialRead.cpp:41:26: note: suggested alternative: 'Serial_read'
BufferSize = Serial1.available();
^~~~~~~
Serial_read
In file included from matlab/arduino_ert_rtw/MW_target_hardware_resources.h:7:0,
from matlab/arduino_ert_rtw/Arduino.h:15,
from arduinobase/src/MW_SerialWrite.cpp:4:
arduinotarget/scheduler/include/arduinoAVRScheduler.h:16:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean disable_rt_OneStep(void);
^~~~~~~
boolean_T
arduinotarget/scheduler/include/arduinoAVRScheduler.h:18:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean MW_Arduino_Loop(void);
^~~~~~~
boolean_T
arduinobase/src/MW_SerialWrite.cpp: In function 'void MW_SCI_Open(uint8_T)':
<command-line>:0:22: error: 'SERIAL_8N1' was not declared in this scope
arduinobase/src/MW_SerialWrite.cpp:29:53: note: in expansion of macro '_RTT_CONFIG_SERIAL1_'
Serial_begin(1, _RTT_BAUDRATE_SERIAL1_, _RTT_CONFIG_SERIAL1_);
^~~~~~~~~~~~~~~~~~~~
arduinobase/src/MW_SerialWrite.cpp: In function 'void MW_Serial_write(uint8_T, void*, size_t, uint8_T, uint8_T, uint8_T, uint8_T, uint8_T, char*)':
arduinobase/src/MW_SerialWrite.cpp:61:14: error: 'DEC' was not declared in this scope
base=DEC;
^~~
arduinobase/src/MW_SerialWrite.cpp:64:14: error: 'HEX' was not declared in this scope
base=HEX;
^~~
arduinobase/src/MW_SerialWrite.cpp:67:14: error: 'OCT' was not declared in this scope
base=OCT;
^~~
arduinobase/src/MW_SerialWrite.cpp:70:14: error: 'BIN' was not declared in this scope
base=BIN;
^~~
arduinobase/src/MW_SerialWrite.cpp:77:17: error: 'Serial' was not declared in this scope
Serial.write((uint8_t *)dataInput,(s*dataSize));
^~~~~~
arduinobase/src/MW_SerialWrite.cpp:81:17: error: 'Serial' was not declared in this scope
Serial.print(label);
^~~~~~
arduinobase/src/MW_SerialWrite.cpp:195:17: error: 'Serial1' was not declared in this scope
Serial1.write((uint8_t *)dataInput,(s*dataSize));
^~~~~~~
arduinobase/src/MW_SerialWrite.cpp:195:17: note: suggested alternative: 'Serial_read'
Serial1.write((uint8_t *)dataInput,(s*dataSize));
^~~~~~~
Serial_read
arduinobase/src/MW_SerialWrite.cpp:199:17: error: 'Serial1' was not declared in this scope
Serial1.print(label);
^~~~~~~
arduinobase/src/MW_SerialWrite.cpp:199:17: note: suggested alternative: 'Serial_read'
Serial1.print(label);
^~~~~~~
Serial_read
gmake[1]: *** [MW_SerialRead.o] Error 1
gmake[1]: *** Waiting for unfinished jobs....
In file included from matlab/arduino_ert_rtw/MW_target_hardware_resources.h:7:0,
from matlab/arduino_ert_rtw/Arduino.h:15,
from arduinotarget/src/MW_ArduinoHWInit.cpp:6:
arduinotarget/scheduler/include/arduinoAVRScheduler.h:16:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean disable_rt_OneStep(void);
^~~~~~~
boolean_T
arduinotarget/scheduler/include/arduinoAVRScheduler.h:18:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean MW_Arduino_Loop(void);
^~~~~~~
boolean_T
gmake[1]: *** [MW_SerialWrite.o] Error 1
arduinotarget/src/MW_ArduinoHWInit.cpp: In function 'void MW_Arduino_Init()':
<command-line>:0:22: error: 'SERIAL_8N1' was not declared in this scope
arduinotarget/src/MW_ArduinoHWInit.cpp:146:45: note: in expansion of macro '_RTT_CONFIG_SERIAL0_'
Serial_begin(0, _RTT_BAUDRATE_SERIAL0_, _RTT_CONFIG_SERIAL0_);
^~~~~~~~~~~~~~~~~~~~
In file included from matlab/arduino_ert_rtw/MW_target_hardware_resources.h:7:0,
from matlab/arduino_ert_rtw/Arduino.h:15,
from arduinobase/src/io_wrappers.cpp:8:
arduinotarget/scheduler/include/arduinoAVRScheduler.h:16:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean disable_rt_OneStep(void);
^~~~~~~
boolean_T
arduinotarget/scheduler/include/arduinoAVRScheduler.h:18:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean MW_Arduino_Loop(void);
^~~~~~~
boolean_T
In file included from matlab/arduino_ert_rtw/MW_target_hardware_resources.h:7:0,
from matlab/arduino_ert_rtw/arduino.h:15,
from matlab/arduino_ert_rtw/arduino_data.c:2:
arduinotarget/scheduler/include/arduinoAVRScheduler.h:16:1: error: unknown type name 'boolean'; did you mean 'boolean_T'?
boolean disable_rt_OneStep(void);
^~~~~~~
boolean_T
In file included from matlab/arduino_ert_rtw/MW_target_hardware_resources.h:7:0,
from matlab/arduino_ert_rtw/arduino.h:15,
from matlab/arduino_ert_rtw/arduino.c:2:
arduinotarget/scheduler/include/arduinoAVRScheduler.h:16:1: error: unknown type name 'boolean'; did you mean 'boolean_T'?
boolean disable_rt_OneStep(void);
^~~~~~~
boolean_T
arduinotarget/scheduler/include/arduinoAVRScheduler.h:18:1: error: unknown type name 'boolean'; did you mean 'boolean_T'?
boolean MW_Arduino_Loop(void);
^~~~~~~
boolean_T
arduinotarget/scheduler/include/arduinoAVRScheduler.h:18:1: error: unknown type name 'boolean'; did you mean 'boolean_T'?
boolean MW_Arduino_Loop(void);
^~~~~~~
boolean_T
In file included from matlab/arduino_ert_rtw/MW_target_hardware_resources.h:7:0,
from matlab/arduino_ert_rtw/Arduino.h:15,
from arduinotarget/scheduler/src/arduinoAVRScheduler.cpp:6:
arduinotarget/scheduler/include/arduinoAVRScheduler.h:16:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean disable_rt_OneStep(void);
^~~~~~~
boolean_T
arduinotarget/scheduler/include/arduinoAVRScheduler.h:18:1: error: 'boolean' does not name a type; did you mean 'boolean_T'?
boolean MW_Arduino_Loop(void);
^~~~~~~
boolean_T
arduinotarget/scheduler/src/arduinoAVRScheduler.cpp:29:4: error: expected constructor, destructor, or type conversion before '(' token
ISR(INTERRUPT_VECTOR)
^
arduinobase/src/io_wrappers.cpp: In function 'void Serial_begin(int, long int, int)':
arduinobase/src/io_wrappers.cpp:44:13: error: 'Serial' was not declared in this scope
Serial.begin(r,config);
^~~~~~
In file included from matlab/arduino_ert_rtw/MW_target_hardware_resources.h:7:0,
from matlab/arduino_ert_rtw/Arduino.h:15,
from arduinotarget/scheduler/src/arduinoAVRScheduler.cpp:6:
arduinotarget/scheduler/src/arduinoAVRScheduler.cpp: In function 'void configureArduinoAVRTimer()':
arduinotarget/scheduler/include/arduinoAVRScheduler.h:115:35: error: 'TCNT3' was not declared in this scope
#define RESET_TIMER TCNT3 = INIT_TIMER_VAL
^
arduinotarget/scheduler/src/arduinoAVRScheduler.cpp:57:3: note: in expansion of macro 'RESET_TIMER'
RESET_TIMER;
^~~~~~~~~~~
arduinobase/src/io_wrappers.cpp:54:13: error: 'Serial1' was not declared in this scope
Serial1.begin(r,config);
^~~~~~~
  2 commentaires
Valeriy
Valeriy le 13 Sep 2023
Modifié(e) : Valeriy le 13 Sep 2023
I re-installed the Arduino support package a couple of times, looks like it's on to another error.
  • I definitely have Arduino Micro
  • I verified that the board is not toasted by uploading one of the Arduino sample programs, and it got uploaded correctly. I looked at the output from the serial port and that looked good as well. The board appears to be in good shape, as well as the connection to it from the computer
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATmega32U4 is 1E 95 87
Prasanth Sunkara
Prasanth Sunkara le 22 Sep 2023
Hi Valeriy,
Your model is currently seems to be named as arduino.slx. Could you try renaming it something else like my_arduino_test.slx and save it to a different folder and try the deployment from Simulink again?

Connectez-vous pour commenter.

Réponses (1)

Nipun
Nipun le 21 Sep 2023
Hi Valeriy,
I understand that you are encountering errors when deploying the generated C code on Arduino micro, however it successfully connects to Simulink. I assume that you tried uploading the sample program using Simulink itself after re-installing the Arduino support package.
I found a similar case on Stack Overflow . It seems that either the USB connection might be at fault. Additionally, you may try reseting it by sending a specific baudrate as suggested by Taylor in the same thread.
I am linking the documentation to running model on Arduino hardware in case it is required. Hope this helps.
Regards,
Nipun Mahajan
  1 commentaire
Valeriy
Valeriy le 1 Oct 2023
I also found this question on Stack Overflow before posting here on Matlab forums. I uninstalled and re-installed the tools a few times, and I even have the serial plotter working from Arduino tools for Matlab (it successfully reads from the analog pins and plots the value on the chart). However Building still fails.
I uninstalled all the Arduino tools and gave up on trying to accomplish anything via this route. Ended up creating my own Arduino program, writing a Linux C++ program to communicate with it and record data to a CSV file, then imported that into Matlab. Don't recommend anyone try to use Arduino tools in Matlab, they are truly awful.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by