Running Emulation on an Embedded Processor Platform - 2020.2 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
UG1393
Release Date
2021-03-22
Version
2020.2 English
Recommended: The file size limit on your machine should either be set to unlimited or a higher value (over 16 GB) because embedded HW Emulation can create files with larger file size for memory.
Tip: Set up the command shell or window as described in Setting Up the Vitis Environment prior to running the builds.
  1. Set the desired runtime settings in the xrt.ini file.

    As described in xrt.ini File, the file specifies various parameters to control debugging, profiling, and message logging in XRT when running the host application and kernel execution. As described in Enabling Profiling in Your Application this enables the runtime to capture debugging and profile data as your application is running.

    The xrt.ini file, as well as any additional files required for running the application, must be included in the output files as explained in Packaging for Embedded Platforms.

    Tip: Be sure to use the v++ -g option when compiling your kernel code for emulation mode.
  2. Launch the QEMU emulation environment by running the launch_sw_emu.sh script or launch_hw_emu.sh script.
    launch_sw_emu.sh -forward-port 1440 22

    The script is created in the emulation directory during the packaging process, and uses the launch_emulator command to setup and launch QEMU. When launching the emulation script you can also specify options for the launch_emulator command. Such as the -forward-port option to forward the QEMU port to an open port on the local system. This will be needed when trying to copy files from QEMU as discussed in Step 5 below. Refer to launch_emulator Utility for details of the command.

    Another example would be to specify launch_hw_emu.sh -enable-debug to configure additional XTERMs to be opened for QEMU and PL processes to observe live transcripts of command execution to aid in debugging the application. This is not enabled by default, but can be useful when needed for debug.

  3. Mount and configure the QEMU shell with the required settings.

    The Xilinx embedded base platforms have rootfs on a separate EXT4 partition on the SD card. After booting Linux, this partition needs to be mounted. If you are running emulation manually, you need to run the following commands from the QEMU shell:

    mount /dev/mmcblk0p1 /mnt
    cd /mnt
    export LD_LIBRARY_PATH=/mnt:/tmp:$LD_LIBRARY_PATH
    export XCL_EMULATION_MODE=hw_emu
    export XILINX_XRT=/usr
    export XILINX_VITIS=/mnt
    Tip: You can set the XCL_EMULATION_MODE environment variable to sw_emu for software emulation, or hw_emu for hardware emulation. This configures the host application to run in emulation mode.
  4. Run the application from within the QEMU shell.

    With the runtime initialization (xrt.ini), the XCL_EMULATION_MODE environment set, run the host executable with the command line as required by the host application. For example:

    ./host.elf kernel.xclbin
    Tip: This command line assumes that the host program is written to take the name of the xclbin file as an argument, as most Vitis examples and tutorials do. However, your application can have the name of the xclbin file hard-coded into the host program, or can require a different approach to running the application.
  5. After the application run has completed, you might have some files that were produced by the runtime, such as profile_summary.csv, timeline.csv, and xclbin.run_summary. These files can be found in the /mnt folder inside the QEMU environment. However, to view these files you must copy them from the QEMU Linux system back to your local system. The files can be copied using the scp command as follows:
    scp -P 1440 root@<host-ip-address>:/mnt/<file> <dest_path>

    Where:

    • 1440 is the QEMU port to connect to.
    • root@<host-ip-address> is the root login for the PetaLinux running under QEMU on the specified IP address. The default root password is "root".
    • /mnt/<file> is the path and file name of the file you want to copy from the QEMU environment.
    • <dest_path> specifies the path and file name to copy the file to on the local system.
    For example:
    scp -P 1440 root@172.55.12.26:/mnt/xclbin.run_summary
  6. When your application has completed emulation and you have copied any needed files, click Ctrl + a + x keys to terminate the QEMU shell and return to the Linux shell.
    Note: If you have trouble terminating the QEMU environment, you can kill the processes it launches to run the environment. The tool reports the process IDs (pids) at the start of the transcript, or you can specify the -pid-file option to capture the pids when launching emulation.