AIoT | Software: Astra AI Application Software Compilation

Keywords :AIoTAstraAISoftwareSynaptics

During the cross-compilation process, we need to set up the device's runtime environment on the PC to ensure that the compiled application can run properly on the device. On the Astra platform, you only need to install a toolchain package to complete the environment setup. The relevant toolchain can be downloaded from Astra's GitHub page.Release v1.5.0 · synaptics-astra/sdk). However, if you add new features, you will need to compile a toolchain package that includes these new features yourself to ensure the relevant environment can support them. For detailed compilation steps, please refer to the documentation (Astra Yocto Linux Developer Guide — Synaptics Astra SDK User Guide 1.5.0 Documentation

 

Although installing the toolchain is a basic step, the key lies in how to compile a program. We can refer to the AI-related application source code provided by the official source (synaptics-astra/synap-framework at v1.5.0The source code is compiled using CMake scripts, but you need to specify the toolchain directory to generate a runnable program.

 

Set the directory for the toolchain:

In the CMakeLists.txt file under the synap-framework directory, add the settings.

set(CMAKE_INSTALL_INCLUDEDIR include)

set(CMAKE_INSTALL_LIBDIR lib)

set(CMAKE_INSTALL_PREFIX toolchain_4_0_17/sysroots/cortexa55-poky-linux/usr)

Among them, `CMAKE_INSTALL_PREFIX` points to the directory of the toolchain. Once the setup is complete, the compiled software can run on the device.

 

Add the required libraries to the compilation:

Although the program can be compiled, the required library files may sometimes fail to link correctly. In such cases, you need to manually add the relevant paths in the CMake script. For example, the OpenCV library, commonly used in machine vision, is included in the default Yocto project, but since the official example does not utilize it, manual linking is required. Fortunately, the `synap-framework/cmake/modules` directory provides linking scripts, but some link addresses may not match the toolchain paths and require the following modifications:

a. Modify the folder path of the header file location:

      target_include_directories(opencv_core INTERFACE ${SYNAP_SYSROOT_INCLUDEDIR}/opencv4)

b. Replace all `.a` library files with `.so` library files.

c.     Add the following to the `CMakeLists.txt` file in the `synap-framework` directory:

cmake find_package(OpenCV REQUIRED)

 

Add your own program:

        Assume we need to write a program named `ai_test_app`, the steps are as follows:

a. Copy a folder from the `synap-framework/app` directory and rename it to `ai_test_app`.

b. Modify the source code and the `CMakeLists.txt` script according to the requirements.

c. Add to the CMakeLists.txt file in the synap-framework/app directory.add_subdirectory(ai_test_app)

 

Compiler:

a. Execute the environment setup script for the toolchain:

. toolchain_4_0_17/environment-setup-cortexa73-poky-linux

b. Run in the synap-framework directory (build is the output path, and the parameters following -D are the relevant settings).

cmake -B build -DCMAKE_BUILD_TYPE=Debug

c. Then run it again.cmake --build build -j16

d. You can find the ai_test_app executable file in the build/app/ai_test_app directory.

e. Place the ai_test_app executable file on the Astra platform, and it can be executed.

 

That's all for this blog post. If you have any questions, feel free to leave a comment below or contact us, and we will do our best to address them (o´ω`o)و. Thank you for reading, and see you in the next post!

 

FAQ 1: What is a toolchain?

A1: Toolchain is a set of tools used for cross-compilation, including compilers, linkers, and other utilities, which help generate executable files suitable for the target device.

 

FAQ 2: How is the computing power of the Astra platform?

A2: The Astra platform currently uses SL1680 with ~8 TOPS computing power and SL1640 with ~1.6 TOPS computing power.

 

FAQ 3: What is the purpose of the CMakeLists.txt file?

A3: CMakeLists.txt is the configuration file for CMake, used to define the project's build rules, dependencies, and output paths.

 

FAQ 4: How to troubleshoot errors during compilation?

A4: Check whether the CMake script settings are correct, confirm if the toolchain path matches, and review the specific error messages in the compilation log.

 

FAQ 5: The execution document placed on the device cannot run?

A5: Use chmod +x to make the file executable and give it a try.

★All blog content is provided by individuals and is unrelated to the platform. For any legal or infringement issues, please contact the website administrator.

★ Please maintain civility online and post responsibly. If a post receives 5 reports within a week, the author will be temporarily suspended.