zcu102 executable not really run when launched from command line
101 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I'm trying to run a matlab excutable generated for ZCU102. If I launch my application from simulink everything works fine and I see a led controlled by the FPGA blinking. If I follow the instructions on
the executable runs but the led is not blinking. I tried to run it as
./my_executable -tf inf
but if seems like the binary is not running. Do I miss something in the executable call?
thanks
michele
2 Kommentare
Sai
am 21 Aug. 2025 um 11:07
Bearbeitet: Sai
am 21 Aug. 2025 um 12:03
Hi Michele,
Good to hear that you are able to launch the application from Simulink and able to controll the LEDs.
We are assuming that you wanted your elf file to run continuously from the board startup stage itself. If so, you can place your elf file in /mnt directory and add this path into the init.sh script as mentioned below.
/mnt/<executable.elf>
Now, everytime you Power-On Reset (POR) the board, this elf file runs continuously on the processor after complete bootup of the board.
If your intention is different to this, please provide detailed information of what you want to achieve so that we can guide you better.
Thanks
Sai G
Antworten (2)
Adit
am 22 Aug. 2025 um 5:46
Hello Michele,
An ARM application generated by Simulink for the Zynq board (e.g., ZCU102) may not function as expected when run from the command line, even though it works when launched from Simulink. This is often because Simulink automatically handles certain steps—such as loading the FPGA bitstream and running the executable from a proper filesystem—that must be performed manually when launching from the terminal.
In Simulink, set the ‘Build action’ to “Build”. This will generate both the FPGA bitstream (.bit file) and the software executable (.elf file) but will not automatically deploy or run them on the board.
You can build the files using the shortcut ‘CTRL+B’ in Simulink, or by running this in MATLAB:
modelName = 'my_executable';
slbuild(modelName)
After building, you’ll have ‘my_executable.elf’ and ‘my_executable.bit’.
Next, you need to put these files on your Zynq board. You can use MATLAB’s Zynq object like this:
z = zynq('linux','192.168.3.2','root','root','/tmp');
z.putFile('my_executable.elf','/mnt');
z.putFile('my_executable.bit','/mnt');
Make sure to use your board’s real IP address.
Simulink automatically loads the bitstream when running the model, but when running manually, you must load the bitstream yourself. Open a terminal and connect to your board:
ssh root@192.168.3.2
Then, load the bitstream like this:
cat /mnt/my_executable.bit > /dev/xdevcfg
On some boards, the device name might be different, like /dev/fpga0.
Now, run the executable as follows:
cp -f /mnt/my_executable.elf /tmp/my_executable.elf
chmod +x /tmp/my_executable.elf
cd /tmp && ./my_executable.elf -tf inf &
- The -tf inf part makes your program run forever.
- The & means it will run in the background.
You can check your program from the board’s console. To stop it, use ‘kill’ or press ‘Ctrl+C’ if you ran it in the foreground.
For more information, refer to the following MathWorks documentation: https://www.mathworks.com/help/ecoder/setup-and-configuration-xilinxzynq7000ec.html
I hope this helps, thanks!
3 Kommentare
Adit
am 1 Sep. 2025 um 6:37
Bearbeitet: Adit
am 1 Sep. 2025 um 6:46
Hello Michele,
It's good to hear that the manual workflow is running as expected. Regarding the XCP connection:
When you start the application from Simulink, Simulink automatically manages the XCP server initialization and ensures the communication port is open for parameter tuning and data access. When you launch the application manually from the command line, you may need to ensure the XCP server is explicitly started and properly configured.
A few things to check and try:
1. Some generated executables require specific command-line options to enable XCP. Check if your model supports the -xcp. You can try:
./my_executable.elf -tf inf -port 17725 -xcp on &
If -xcp is not recognized, check your model’s documentation or code generation settings for the correct flag.
2. Ensure that the firewall on your Zynq board allows inbound connections to the XCP port (default is 17725). You can check this with:
netstat -an | grep 17725
after launching your application, to verify the port is open and listening.
3. Double-check that your model is configured for external mode/XCP communication. In Simulink: Code > C/C++ Code > Code Generation > Interface. Make sure "External mode" and "XCP on TCP/IP" are enabled, and the correct port is set.
4. Simulink may automatically set up the environment when running a model. If running manually, make sure to use the same directory and include all generated files, not just the .elf.
I hope this helps, thanks!
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!