Compiling and Linking Host Code for Bare-Metal - 2023.1 English

AI Engine Tools and Flows User Guide (UG1076)

Document ID
UG1076
Release Date
2023-06-23
Version
2023.1 English

To build the PS application for the bare-metal flow, use the platform generated in the prior step. You need the PS application (main.cpp), and the bare-metal AI Engine control file (aie_control.cpp), which is created by the aiecompiler command and can be found in the ./Work/ps/c_rts folder.

Compile the main.cpp file using the following command:

aarch64-none-elf-gcc -I.. -I. -I../src \
-I./vck190_baremetal/export/vck190_baremetal/sw/vck190_baremetal/standalone_domain/bspinclude/include \
-g -c -std=c++17 -o main.o main.cpp
Note: You must include the BSP include files for the generated custom base-platform platform, located at: ./vck190_baremetal/export/vck190_baremetal/sw/vck190_baremetal/standalone_domain/bspinclude/include

where, vck190_baremetal is the platform name.

Compile the aie_control.cpp file using the following command:

aarch64-none-elf-gcc -I.. -I. -I../src \
-I./vck190_baremetal/export/vck190_baremetal/sw/vck190_baremetal/standalone_domain/bspinclude/include \
-g -c -std=c++17 -o aie_control.o ../Work/ps/c_rts/aie_control.cpp

Link the PS application using the two compiled object files:

aarch64-none-elf-gcc main.o aie_control.o -g -mcpu=cortex-a72 -Wl,-T -Wl,./lscript.ld \

-L./vck190_baremetal/export/vck190_baremetal/sw/vck190_baremetal/standalone_domain/bsplib/lib  \
-ladf_api -Wl,--start-group,-lxil,-lgcc,-lc,-lstdc++,--end-group -o main.elf
Note: You also need the BSP libxil.a located at ./vck190_baremetal/export/vck190_baremetal/standalone_domain/bsplib/lib during linking. This assumes the AI Engine is enabled during the platform management controller (PMC) boot.
Note: The linker script lscript.ld can be obtained from the Vitis IDE, as described in Building a Bare-metal AI Engine in the Vitis IDE. Additional details can be found in https://docs.xilinx.com/r/en-US/Vitis-Tutorials-AI-Engine-Development/A-to-Z-Bare-metal-Flow.