Main Content

Deploy Standalone Application to Zynq Board for Run on Startup

This example shows how to manually deploy the ARM software executable that you generate from a Simulink® model to your Zynq board (for example, Zedboard, ZC702, ZC706, ZCU102, or others). After manual deployment, you can run the executable without a connection to Simulink on your development computer.

Manual deployment is needed for standalone operation because---when Simulink deploys an ARM software executable to your Zynq board---the Simulink deployed executable is lost after reboot. The loss occurs because Simulink places the executable in the /tmp folder of the file system on the Zynq board. This folder is cleared after power-cycling the board.

Generate and Deploy Executable

These steps show how to generate and deploy a software executable in standalone mode. After you deploy the executable you can run it without a connection to Simulink on your development computer.

1. In the Model Configuration Parameters dialog box, set the Build action to Build. This selection generates the executable ELF file without automatically downloading the file to the /tmp folder of the board and running it.

window-config-params-build-options.png

2. Build the ELF file by using the shortcut Ctrl+B in Simulink or by using the slbuild function. In the MATLAB Command Window, type:

modelName = 'zynqRadioADSB_interface';

slbuild(modelName)

When the build process completes, the modelName ELF file is placed in the current working folder.

3. Copy the ELF file to the Zynq board by using the zynq object interface that is shipped with the Embedded Coder Support Package for AMD SoC Devices. Make sure to use the actual IP address of your board if it is different than 192.168.3.2 in this example. In the MATLAB Command Window, type:

z = zynq('linux','192.168.3.2','root','root','/tmp')

z.putFile('zynqRadioADSB_interface.elf','/mnt')

The second argument to putFile is the destination directory on the Zynq board. Here, /mnt is the mounted SD card directory in Linux. It is the only persistent directory in this embedded Linux file system. Placing the ELF file somewhere other than /mnt causes that file to disappear when the board is rebooted.

4. Run the ELF file from an SSH terminal session on the Zynq board. In the MATLAB Command Window, type:

z.openShell('ssh')

5. When you are done running the shell application, exit by using 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.

Edit the Initialization File

Editing this file is shown below by using the Linux vi editor in the ssh session to the board. You can also accomplish these edits by using your preferred text editor on your development computer and by copying this file to the SD card on the Zynq board.

window-putty-session-vi-editor.png

window-putty-session-vi-editor-customize.png

Adjust for Different File Systems

Note that the /mnt directory is mapped to the FAT32 file system, which is not a native Linux ext4 or tmpfs file system. To avoid any potential issues between these file systems, copy the ELF file to the /tmp directory, and then run the ELF file in the /tmp directory.

You can copy and execute the ELF file on startup by using this code in the init.sh file. In this code, <appname> is the name of the executable.

cp -f /mnt/<appname>.elf /tmp/<appname>.elf

cd /tmp && /tmp/<appname>.elf &