MATLAB: Simulink unable to upload to Arduino Nano 3.0 Linux

arduinoarduino nano 3simulink

System - Ubuntu 18.04
Matlab Version - R2019b
Device - Arduino Nano 3
I connected the arduino nano to the computer. Using matlab support for arduino package I am able to upload code successfully onto the nano. It also works with the regular arduino nano.
I then opened the arduino_getting_started found here
I changed the board to arduino nano 3.0 and selected the correct COM port /tty/USB0.
I am sure this is the correct COM port because it works with the matlab version.
When I pressed upload and deploy to board I encounter the error below.
AVR Memory Usage
----------------
Device: atmega328p
Program: 4252 bytes (13.0% Full)

(.text + .data + .bootloader)
Data: 232 bytes (11.3% Full)
(.data + .bss + .noinit)
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
### Build procedure for model: 'arduino_gettingstarted' aborted due to an error.
The following error occurred during deployment to your hardware board:
Could not connect to specified Arduino board.
Verify that the board is connected to your host, and that the host COM port set in the model matches the COM port name in the host.
To change the host COM port in the model, click 'Simulation ', click 'Model Configuration Parameters'... In the dialog that opens, select the 'Hardware Implementation' pane, click 'Target hardware resources > Host-board connection' and set the COM port number.
To find out the COM port in the host, open a terminal and type ls /dev/ttyACM* in the terminal. Choose the name that corresponds to your board.
I've also tried manually bootloading the code onto the arduino using this command, which succeeded.
~/Documents/MATLAB/SupportPackages/R2019b/3P.instrset/arduinoide.instrset/arduino-1.8.8/hardware/tools/avr/bin/avrdude -C /home/vuwij/Documents/MATLAB/SupportPackages/R2019b/3P.instrset/arduinoide.instrset/arduino-1.8.8/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:$(pwd)/arduino_gettingstarted.hex
I've attached the exact slx which caused the problem.
Screenshot from 2020-01-27 23-08-28.png

Best Answer

Hi Jason Wang,
The issue is due to the updated bootloader of Nano board. Old bootloader communicates at 57600 baud whereas the new bootloader communicates at 115200 baud.
Simulink tries to flash using the old bootloader but your board has new bootloader. That's the reason you are seeing this failure.
Workaround:
  1. Flash the old bootloader into nano board using another Arduino as ICSP from Arduino IDE. Please note that you have to select Processor as "Atmega 328P (Old Bootloader)" in Arduino IDE. You can find this setting in tools menu of Arduino IDE.
Support for new bootloader is under consideration and will be added in future releases. If you want to flash using the new bootloader, please contact technical support.
Thanks,
Arun