MATLAB: How to deploy an ARM software executable from a Simulink model to the Zynq board to run in standalone mode

HDL Coder

I would like to deploy the ARM software executable generated from a Simulink model to my Zynq board, so that it can be run without any connection to Simulink on my host machine. However, each time I restart my Zynq board, it no longer runs. How do I permanently deploy the executable to my Zynq board so that it can always be run?

Best Answer

The following steps demonstrate how to generate and deploy a software executable in “standalone” mode, so that it can be run without any connection to Simulink on your host machine.
NOTE: This guide refers to the generated standalone executable as the “.elf file”. In R2018a and prior, the executable will not have a file extension. The steps below will be the same, but the executable file will be called “modelName” instead of “modelName.elf”
1. In the Model Configuration Parameters, set the “Build action” to “Build”. This will generate the executable (.elf file) without automatically downloading it to the board and running it.
2. Build the .elf file with Ctrl+B in Simulink, or in MATLAB using the slbuild command.
>> modelName = 'zynqRadioADSB_interface';
>> slbuild(modelName)
When the build process completes, the .elf file will be placed in your current directory
3. Copy the .elf file to the board using the zynq object interface. Make sure to use the actual IP address of your board if it is different than 192.168.3.2.
>> z = zynq('linux','192.168.3.2','root','root','/tmp')
z =
LinuxShell with properties:
IPAddress: '192.168.3.2'
Username: 'root'
Port: 22
>> z.putFile('zynqRadioADSB_interface.elf','/mnt')
The second argument to putFile is the destination directory on the target. Here, "/mnt" is the mounted SD card directory in Linux. It is the only persistent directory in this Embedded Linux file system, so placing the .elf file somewhere other than /mnt will cause that file to disappear when the board is rebooted.
4. Run the .elf file from an ssh terminal session on the target.
>> z.openShell('ssh')
5. When you are done running the application, exit with Ctrl+C.
6. If you would like the standalone software to run automatically when the board is powered on, add a line to the init.sh file on the SD card. This file is a shell script that is called by Linux on startup.
Editing this file is shown below using the vi editor on the board, but you can also do this using your preferred text editor on your host machine.
Here, the "&" character means run the process in the background.