Why do I get a 'Failed to connect to the target' error when I try to run a model in External mode on a Xilinx board?

13 Ansichten (letzte 30 Tage)
I am using the "Embedded Coder Support Package for Xilinx Zynq Platform" and/or "SoC Blockset Support Package for Xilinx Devices" with a supported board such as Zedboard, ZC702, ZC706, ZCU102, ZCU111 RFSoC, ZCU216 RFSoC, ADI RF SOM, or PicoZed..
I can successfully build a Simulink model for the Xilinx board. However, when I try to run the model in External mode by using the "Monitor & Tune" or "Connect to Target" button, I observe the following error:
Error occurred while executing External Mode MEX-file 'ext_comm':
Failed to connect to the target. Possible reasons for the failure:
a) The target is not switched on.
b) The target is not connected to your host machine.
c) The application for the model is not running on the target.
You might have clicked the Stop button. If the Run button is not dimmed,
click it. Otherwise, click the Build button,
which downloads and runs your application on the target.
Caused by:
An error occurred attempting to open an rtIOStream.
More detail may be reported in the MATLAB command window

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 25 Okt. 2023
Bearbeitet: MathWorks Support Team am 25 Okt. 2023
This error message indicates that Simulink is unable to communicate with the Xilinx board over the Ethernet connection. 
Going through the above article will ensure the following:
  • The Linux Image on the SD card matches your version of MATLAB.
  • The jumper settings are correct and the Xilinx board boots successfully from the SD card.
  • The IP settings for both the Xilinx board and host PC are correct, and you can ping the Xilinx board from the host PC.
  • You can enter the "zynq" command in MATLAB without getting an error.
Once you have ensured that the Ethernet connection between the host PC and the Xilinx board is fine, please try the following troubleshooting steps:
1. Reset the 'Hardware board' setting in the interface model:
a) Open Configuration Parameters > Hardware Implementation.
b) Set 'Hardware board' to 'None'.
c) Set 'Hardware board' to 'Zedboard', then click 'Apply'.
d) Verify that the correct IP address was filled into Hardware Board Settings > Target hardware resources > Board Parameters > Device Address.
e) Run in external mode.
2. If step 1 fails, please check whether the program can be manually run on the hardware:
a) Load the model manually by entering the following command into the MATLAB Command Window:
>> h = zynq;
>> h.loadModel('gm_hdlcoder_led_blinking_interface');
where 'gm_hdlcoder_led_blinking_interface' is the name of your model.
For more info on zynq object, type "help zynq" in MATLAB.
b) From MATLAB, open a PuTTY shell:
>> h.openShell('ssh') % enter the credentials (username - 'root', password - 'root')
In the PuTTY shell, execute the following commands to run the application:
zynq> cd /tmp
zynq> ./gm_hdlcoder_led_blinking_interface
Note that in older versions of MATLAB, the executable may have an .elf extension.
c) In Simulink, select Code > External Mode Control Panel. Click 'Connect', then 'Start Real-Time Code'.
e) Check in the PUTTY window to see if the application is still running by using the "ps" Linux command:
zynq> ps
You should see the "gm_hdlcoder_led_blinking_interface" process in the list.
 
3. If step 2 fails, please try to do further debugging by following the steps below:
a) In your Simulink model, open the configuration parameters > Code Generation > Build Configuration > "Debug"
b) Click "Monitor & Tune" inn the model - you will see the same "Failed to connect to target error...".
c) From MATLAB, open a PuTTY shell:
>> h = zynq;
>> h.openShell('ssh') % enter the credentials (username - 'root', password - 'root')
In the PuTTY shell, execute the following commands to change the executable permissions of the app:
zynq> cd /tmp
zynq> chmod +x ./gm_hdlcoder_led_blinking_interface
zynq> ./gm_hdlcoder_led_blinking_interface
where 'gm_hdlcoder_led_blinking_interface' is the name of your model. Note that in older versions of MATLAB, the executable may have an .elf extension.
d) Run the app:you should see more informative log and errors in the shell.
zynq> ./gm_hdlcoder_led_blinking_interface
You should see a more informative log and errors in the shell now.
If the application errors out, copy the error log and send it to MathWorks Technical Support.
If the application starts and is waiting, then continue with following steps.
e) In Simulink, select Code > External Mode Control Panel. Click 'Connect', then 'Start Real-Time Code'.
f) Observe the log on the Linux shell where you started the application manually.
g) copy the error log from the PuTTY shell and send it to MathWorks Technical Support.

Weitere Antworten (1)

Noam Levine
Noam Levine am 14 Jan. 2019
Bearbeitet: MathWorks Support Team am 4 Mär. 2024
The Embedded Coder Support Package for Xilinx Zynq Platform will not work with the Zybo board out of the box. You need to create a custom refernce design for Zybo, as explained in the following documentation. To view the documentation, enter the following command on your MATLAB R2018b instance:
web(fullfile(docroot, "supportpkg/xilinxzynq7000/board-and-reference-design.html"))

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by