Registered User mNo edit summary |
Registered User (Merge articles) |
||
Line 20: | Line 20: | ||
The add-on is delivered through a tarball file that can be downloaded here: | The add-on is delivered through a tarball file that can be downloaded here: | ||
*For beta: | *For beta: | ||
:To download the archive, | :To download the archive, Follow instructions given in the [[How_to_download_STM32MP25_packages|downloading instructions page]], if you didn't retrieve yet the files and download the {{X-LINUXRelease/Package | version={{X-LINUXRelease/Revision | revision=latest | name=AI | type=release}} | package=AI SDK package | request=name}} archive. | ||
{{warning| The '''X-LINUX-AI SDK add-on''' version must be the same as the '''OpenSTLinux SDK'''. If the version are not aligned, it might not work correctly.}} | {{warning| The '''X-LINUX-AI SDK add-on''' version must be the same as the '''OpenSTLinux SDK'''. If the version are not aligned, it might not work correctly.}} | ||
Line 59: | Line 59: | ||
Go to the image classification directory: | Go to the image classification directory: | ||
{{PC$}} cd meta-st-x-linux-ai/recipes-samples/image-classification/tflite/ | {{PC$}} cd meta-st-x-linux-ai/recipes-samples/image-classification/tflite/ | ||
{{info| To be able to compile AI applications for {{Board | type=MP2}} with hardware acceleration it is necessary to export an environment variable named '''ARCHITECTURE''' which is used in the makefile provided in X-LINUX-AI repository.}} | |||
Export '''ARCHITECTURE''' variable to build AI applications with NPU acceleration : | |||
{{PC$}} export ARCHITECTURE=stm32mp2_npu | |||
Then, use the '''make''' command to build the application: | Then, use the '''make''' command to build the application: | ||
{{PC$}} make | {{PC$}} make | ||
A new file is displayed, named '''tflite_image_classification'''. This is a binary file, which has been generated using the '''make''' command. It is compiled for the STM32MP2x architecture. It must now be transferred to the board. | A new file is displayed, named '''tflite_image_classification'''. This is a binary file, which has been generated using the '''make''' command. It is compiled for the STM32MP2x architecture. It must now be transferred to the board. | ||
=== Use the application === | === Use the application === | ||
{{warning| To use the application, it is '''mandatory''' to have an STM32MP2x board with '''OpenSTLinux and X-LINUX-AI packages''' installed. If it is not the case, refer to the [[X-LINUX-AI_OpenSTLinux_Expansion_Package| X-LINUX-AI installation guide]].}} | {{warning| To use the application, it is '''mandatory''' to have an STM32MP2x board with '''OpenSTLinux and X-LINUX-AI packages''' installed. If it is not the case, refer to the [[X-LINUX-AI_OpenSTLinux_Expansion_Package| X-LINUX-AI installation guide]].}} |
Revision as of 13:49, 14 May 2024
1. Developer package : build AI application from the X-LINUX-AI add-on SDK[edit | 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 | edit source]
2.1. Install the OpenSTLinux SDK[edit | 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 STM32MP2 Developer Package : Installing the SDK chapter. Once this has been done, you should have a directory containing the OpenSTLinux SDK.
3. X-LINUX-AI SDK add-on installation[edit | edit source]
3.1. Download the X-LINUX-AI SDK add-on[edit | 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:
- For beta:
- To download the archive, Follow instructions given in the downloading instructions page, if you didn't retrieve yet the files and download the SDK-x86_64-stm32mp25-openstlinux-6.1-yocto-mickledore-mp2-v23.12.06-addon-x-linux-ai-STM32MP25-beta.tar.gz archive.
3.2. Install the X-LINUX-AI SDK add-on[edit | edit source]
Once the X-LINUX-AI SDK add-on is downloaded, uncompress the add-on:
SDK-x86_64-stm32mp25-openstlinux-6.1-yocto-mickledore-mp2-v23.12.06-addon-x-linux-ai-STM32MP25-beta.tar.gzcd ~/Downloads/ tar xzf
Then, copy the .sh script to your OpenSTLinux SDK directory:
SDKcp stm32mp25-openstlinux-6.1-yocto-mickledore-mp2-v23.12.06-addon-x-linux-ai-STM32MP25-beta/st-image-ai-openstlinux-weston-stm32mp25-x86_64-toolchain-4.2.2-openstlinux-6.1-yocto-mickledore-mp2-v23.12.06-addon-x-linux-ai-STM32MP25-beta.sh $HOME/STM32MPU_workspace/STM32MPU-Ecosystem-v5.0.2.BETA/Developer-Package/
Finally, run the script contained in the tarball:
SDK ./st-image-ai-openstlinux-weston-stm32mp25-x86_64-toolchain-4.2.2-openstlinux-6.1-yocto-mickledore-mp2-v23.12.06-addon-x-linux-ai-STM32MP25-beta.shcd $HOME/STM32MPU_workspace/STM32MPU-Ecosystem-v5.0.2.BETA/Developer-Package/
Optionally, once the script is executed, you can delete it.
rm *.sh
3.3. Start the SDK[edit | edit source]
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:
SDK source environment-setup-cortexa35-ostl-linuxcd $HOME/STM32MPU_workspace/STM32MPU-Ecosystem-v5.0.2.BETA/Developer-Package/
Check that the SDK is properly installed:
AI version: STM32MP25-betax-linux-ai -v X-LINUX-
4. Use the SDK[edit | edit source]
4.1. Build an application with the SDK[edit | edit source]
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:
https://github.com/PRG-MPU-ALPHA/meta-st-x-linux-aigit clone
Go to the image classification directory:
cd meta-st-x-linux-ai/recipes-samples/image-classification/tflite/
Export ARCHITECTURE variable to build AI applications with NPU acceleration :
export ARCHITECTURE=stm32mp2_npu
Then, use the make command to build the application:
make
A new file is displayed, named tflite_image_classification. This is a binary file, which has been generated using the make command. It is compiled for the STM32MP2x architecture. It must now be transferred to the board.
4.2. Use the application[edit | edit source]
Once the STM32MP2x 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.
To do it, use the following command using your own IP address:
scp -r -p tflite_image_classification root@<ip_address>:/usr/local/demo-ai/image-classification/tflite
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/demo-ai/image-classification/tflite
./launch_bin_image_classification.sh
This script is using the tflite_image_classification application that has been compiled before.