X-LINUX-AI Developer package

Revision as of 15:45, 2 July 2024 by Registered User
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Applicable for STM32MP13x lines, STM32MP15x lines, STM32MP25x lines


1. Developer package : build AI application from the X-LINUX-AI add-on SDK[edit source]

In order to easily develop and build an AI application without using the Yocto build system, X-LINUX-AI comes with a SDK add-on extending the OpenSTLinux SDK with AI functionality. To install and use the X-LINUX-AI SDK Add-on please refer to the following steps.

2. Prerequisites[edit source]

2.1. Install the OpenSTLinux SDK[edit source]

First of all, you must download and install the OpenSTLinux SDK, which contains all the basis needed for the X-LINUX-AI add-on. To do this, follow instructions given in STM32MPU Developer Package : Installing the SDK chapter. Once this has been done, you should have a directory containing the OpenSTLinux SDK.

Info white.png Information
Once this is done, if you have follow the example of directory structure the path to the OpenSTLinux SDK should be the following  :
<working directory absolute path>/Developer-Package/SDK

3. X-LINUX-AI SDK add-on installation[edit source]

3.1. Download the X-LINUX-AI SDK add-on[edit source]

To add the Artificial Intelligence part into the OpenSTLinux SDK, you must download and install the X-LINUX-AI SDK add-on. The add-on is delivered through a tarball file that can be downloaded here: X-LINUX-AI SDK add-on.

Warning white.png Warning
The X-LINUX-AI SDK add-on version and the STM32MPU board must be the same as the OpenSTLinux SDK. If either the version are not aligned or the board is different, it might not work correctly.

3.2. Install the X-LINUX-AI SDK add-on[edit source]

Install add-on for STM32MP1 series

Once the X-LINUX-AI SDK add-on is downloaded, uncompress the add-on:

Info white.png Information
The name of the tarball depends on the chosen version. In the example below the last uploaded version is used.
  cd  ~/Downloads/
  tar xzf  en.sdk-x86_64-stm32mp1-openstlinux-6.1-yocto-mickledore-mpu-v24.06.26-addon-x-linux-ai-v5.1.0.tar.gz

Then, copy the .sh script to your OpenSTLinux SDK directory:

  cp stm32mp1-openstlinux-6.1-yocto-mickledore-mpu-v24.06.26-addon-x-linux-ai-v5.1.0/st-image-ai-openstlinux-weston-stm32mp1-x86_64-toolchain-4.2.4-openstlinux-6.1-yocto-mickledore-mpu-v24.06.26-addon-x-linux-ai-v5.1.0.sh <working directory absolute path>/Developer-Package/SDK
Warning white.png Warning
It is mandatory run the script inside the OpenSTLinux SDK directory.

Finally, run the script contained in the tarball:

  cd <working directory absolute path>/Developer-Package/SDK
  ./st-image-ai-openstlinux-weston-stm32mp1-x86_64-toolchain-4.2.4-openstlinux-6.1-yocto-mickledore-mpu-v24.06.26-addon-x-linux-ai-v5.1.0.sh

Optionally, once the script is executed, you can delete it.

  rm *.sh

Install add-on for STM32MP25x lines More info.png

Once the X-LINUX-AI SDK add-on is downloaded, uncompress the add-on:

Info white.png Information
The name of the tarball depends on the chosen version. In the example below the last uploaded version is used.
  cd  ~/Downloads/
  tar xzf  en.sdk-x86_64-stm32mp2-openstlinux-6.1-yocto-mickledore-mpu-v24.06.26-addon-x-linux-ai-v5.1.0.tar.gz

Then, copy the .sh script to your OpenSTLinux SDK directory:

  cp stm32mp2-openstlinux-6.1-yocto-mickledore-mpu-v24.06.26-addon-x-linux-ai-v5.1.0/st-image-ai-openstlinux-weston-stm32mp2-x86_64-toolchain-4.2.4-openstlinux-6.1-yocto-mickledore-mpu-v24.06.26-addon-x-linux-ai-v5.1.0.sh <working directory absolute path>/Developer-Package/SDK
Warning white.png Warning
It is mandatory run the script inside the OpenSTLinux SDK directory.

Finally, run the script contained in the tarball:

  cd <working directory absolute path>/Developer-Package/SDK
  ./st-image-ai-openstlinux-weston-stm32mp2-x86_64-toolchain-4.2.4-openstlinux-6.1-yocto-mickledore-mpu-v24.06.26-addon-x-linux-ai-v5.1.0.sh

Optionally, once the script is executed, you can delete it.

  rm *.sh


3.3. Start the SDK[edit source]

Info white.png Information
The SDK environment setup script must be run once on each new working terminal on which you cross-compile.

The add-on is now installed into the OpenSTLinux SDK. You can start the SDK. Go to your OpenSTLinux SDK directory and source the environment:

  cd <working directory absolute path>/Developer-Package/SDK
  • On STM32MP2 series' boards More info green.png:
  source environment-setup-cortexa35-ostl-linux
  export SYSROOT="<working directory absolute path>/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi"
  • On STM32MP1 series' boards More info green.png:
  source environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
  export SYSROOT="<working directory absolute path>/Developer-Package/SDK/sysroots/cortexa35-ostl-linux"

Check that the SDK is properly installed:

  x-linux-ai -v
 X-LINUX-AI version: 5.1.0
Info white.png Information
With the x-linux-ai binary it is possible to check the X-LINUX-AI version and the supported frameworks/applications. Use x-linux-ai --help for more information.

4. Use the SDK[edit source]

4.1. Build an application with the SDK[edit source]

Info white.png Information
In this section, the image classification application is used as an example, but all the applications can be built with this method.

Once the SDK is correctly set up, the applications can be built easily. In this example, it is the image classification application that is built.

Download the github repository:

  git clone https://github.com/STMicroelectronics/meta-st-x-linux-ai
Warning white.png Warning
The version of the downloaded meta-st-x-linux-ai is be the same as the one of the X-LINUX-AI SDK add-on.

Go to the image classification directory:

  cd meta-st-x-linux-ai/recipes-samples/image-classification/files/stai-mpu

Then, use the make command to build the application:

  make

A new file is displayed, named stai_mpu_image_classification. This is a binary file, which has been generated using the make command. It is compiled for the architecture of the board corresponding to the chosen SDK. It must now be transferred to the board.

4.2. Use the application[edit source]

Warning white.png Warning
To use the application, it is mandatory to have an STM32MPU board with OpenSTLinux and X-LINUX-AI packages installed. If it is not the case, refer to the X-LINUX-AI installation guide.

Once the board is correctly set up and the X-LINUX-AI packages are installed with the right version, it is possible to send the application to the board.

Info white.png Information
The X-LINUX-AI packages versions must be the same as the ones in the X-LINUX-AI SDK add-on.

To do it, use the following command using your own IP address:

  scp -r -p stai_mpu_image_classification root@<ip_address>:/usr/local/x-linux-ai/image-classification/stai_mpu

Then, use the ssh protocol to connect to the board:

  ssh root@<ip_address>

On the board, go to the right directory and use the image classification script to launch the application:

  cd /usr/local/x-linux-ai/image-classification/stai_mpu
  ./launch_bin_image_classification.sh

This script is using the stai_mpu_image_classification application that has been compiled before.