Arduino Mega Communication Problem to Simulink
2 views (last 30 days)
I keep getting 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.
I have set the port manually and and it does show up in "Devices and Printers".
I have no problem communicating with the IDE. The Mega is running the "fade" demo. The IDE is closed and I have rebotted my computer but still no communications to Simulink.
MATLAB SUPPORT PACKAGE FOR ARDUINO works flawlessly. a = andruino('COM7') works as expected with the adiosrv.pde uploaded to the board.
Tobi. on 13 Nov 2013
I had the very same problem and found a crude workaround: Somewhere deep inside TMW's support package, avrdude is being called to load the .hex file onto the Arduino. This call fails, but instead of passing the error message through to the user, we see a generic error message that doesn't say anything.
I wrote a patch that enabled me to overcome this problem. I hope it helps.
function toolsInfo = toolsInfoDataArduinoMega2560 (in)
%toolsInfoDataArduinoMega2560 Overwrite settings in TMW's own function with
% There's a bug in TMW's implementation of the deploy to Arduino Mega2560
% functionality which throws the following error message:
% 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.
% The reason for this message is not immediately clear, but can be traced
% back to a faulty call to avrdude, which is supposed to load the
% compiled data into the Arduino but fails to do so. It seems like there
% are additional flags set, making avrdude throw an error message which
% Simulink cannot handle, thus leading to the above mentioned unspecific
% error message.
% This function implements a simple workaround: It calls TMW's own
% function and replaces the field which contains all flags used during
% the call to avrdude by individual flags. It should not be considered a
% solution, it's merely a workaround until TMW solves the bug for good.
% To use, copy this file into the hardware support package's
% installation folder, typically
% Then rename the original file toolsInfoArduinoMega2560.p to
% Patch written by Tobias Meyer, University of Paderborn,
% email@example.com, November 2013
toolsInfo = realtime.internal.toolsInfoDataArduinoMega2560_TMW();
% toolsInfo.DownloadUtilityFlags = ' -CC:\MATLAB\SupportPackages\R2013a\arduino-1.0\hardware/tools/avr/etc/avrdude.conf -patmega2560 -cwiring -P//./$(COMPort) -b115200 -D -Uflash:w:';
toolsInfo.DownloadUtilityFlags = ' -C$(InstallDir)\hardware/tools/avr/etc/avrdude.conf -patmega2560 -cwiring -P//./$(COMPort) -b115200 -D -Uflash:w:';