Clear Filters
Clear Filters

Error downloading Simulink Model to Arduino Mega 2560 Rev3

7 views (last 30 days)
I'm using Matlab 2013a (on a Windows 8 64-bit PC) with Arduino support package 3.0. Downloading models to an Arduino UNO is wokring without problems. But I can't download any model to a new Arduino Mega 2560 Rev3. Tested with the arduinomega2560_gettingstarted model. When Simulink says "Downloading.." RX/TX LEDs are just blinking twice and I get the following error:
_The call to realtime_make_rtw_hook, during the after_make hook generated the following error: Could not download the model to the target hardware. Verify the connection between the computer and target hardware.
The build process will terminate as a result.
Caused by: Could not download the model to the target hardware. Verify the connection between the computer and target hardware._
But the target is definitely connected, and downloading programs with Ardino IDE is working fine. I've also tested this on a different PC with Windows 7 with the same result. Can anyone give me a hint please?

Accepted Answer

Arne on 2 Dec 2013
Thanks to the MathWorks support team, I reported this problem and they found a working solution (at least in my case):
1. Shutdown MATLAB
2. Go to the folder inside the Arduino Mega support package (by default this should be in
Note : This is the location which the user installed the support package for Arduino.
3. Make a backup of the existing file "toolsInfoDataArduinoMega2560.p"
4. Overwrite the file "toolsInfoDataArduinoMega2560.p" with the attached P-file (unzip first).
5. Restart MATLAB and execute "rehash toolboxcache"
6. Try the code generation and deployment for the boards in question and verify functionality
RISHEEK on 1 Jan 2014
please Arne or zaid_mka i need that file ;MY EMAIL : ,It would be of great help

Sign in to comment.

More Answers (4)

Andrea on 13 Jan 2014
Edited: Andrea on 13 Jan 2014
Hi, I am using Matlab 2013b on Mac OS 64bit, and I have the same problem of connection of the Arduino2560 R3. I couldn't find the file toolsInfoDataArduinoMega2560.p in the Matlab folder, I think because that file exists in the older versions of the Arduino support package. I have the last one, just downloaded from Mathworks Arduino Package Support. Is there another file or another way to solve my connection problem?
Thank you,

Gergely Takács
Gergely Takács on 13 Feb 2014
Hello all;
I have used this procedure and the external mode does work with certain very simple models. For example an analog input>double conversion>Embedded function for a y = u(5/1024); voltage conversion> scope combination works flawlessly.
However, as soon as I add another analog input, I get the same error as sri. The minimum not working example is two analog inputs with two scopes. The exact procedure goes like this: the building process is successful, and it says " Model Successfully Downloaded to Arduino Mega 2560 ". But then, upon trying to connect to the board, the process hangs at " Initializing " and after a while I get " Error occurred while executing External Mode MEX-file 'ext_serial_win32_comm': Timed-out waiting for first connect response packet. " I've also tried to run a simple embedded function with an extended Kalman filter inside (no inputs or outputs on Arduino) and a scope, but the same thing happened.
  • MATLAB Version: (R2012b)
  • Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
  • Java Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode
  • Board: Arduino Mega 2560
  • Fixed Step Discrete Solver (tried 1, 0.1 sec)
  • External mode enabled.
  • Baud rates 9600
  • Overrun detection enabled, on pin 13
  • Computer Lenovo ThinkPad T410i
Any help would be much appreciated.

Italo Rodrigues
Italo Rodrigues on 29 Jul 2014
Hi, I found the same problem to Arduino UNO. How to fix this?

Sign in to comment.

l z
l z on 4 Apr 2019
Thank you very much !
I used the way to slove my program.


Find more on Downloads in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!