In this section, you will deploy the model directly on the STM32 board.
STM32CubeMX
is a graphical tool for configuring STM32 microcontrollers.
STM32Cube.AI
is an extension of STM32CubeMX to import ML models.
X-CUBE-AI 7.0.0
. Please select this version when installing. Later versions may not connect successfully.Download the Windows installer for STM32CubeMX from the STM32CubeMX product page .
Run the Windows installer and install in desired location of your Windows Machine.
Open STM32CubeMX IDE.
Click Access to Board Selector
. Find your B-L475E-IOT01A
board and click Start Project
.
Go to Project Manager
. Enter a project name and select the project location where the project will be saved.
Under Pinout & Configuration
, expand Pinout
menu, and click Clear pinouts
.
Now install Cube AI and enable it for your project.
Expand Software Packs
menu, and click Select Components
.
Locate X-CUBE-AI
, and click its Install
button.
Expand the menu and enable X-CUBE-AI
> Core
. For device application, choose Validation
. If the status shows a yellow warning, click Resolve
to install any necessary dependencies.
Click OK
when done.
Open STM32CubeMX.
Click Access to Board Selector
.
Find the B-L475E-IOT01A2
board and click Start Project
. Accept any defaults.
Go to Project Manager
. Set the project name and save location.
Set Toolchain/IDE
as STM32CubeIDE
Pinout & Configuration
and clear pinouts from the Pinout
menu.Software Packs
menu, click Select Components
. Enable X-CUBE-AI
. For device application, choose Validation
. Click OK
to save.Navigate to X-CUBE-AI
configuration.
Click Add network
. Browse to the model provided (Data/models/cifar10_model.h5
) or the model you trained by yourself (Data/models/own_cifar10_model.h5
).
Click Analyze
to check the model.
Generate the validation code for the model by clicking Generate Code
.
Open STM32CubeIDE.
Navigate to File
> New
> Project
> ST
> STM32 Project from an Existing STM32CubeMX Configuration File
.
Go to the project folder and open the .ioc
file.
Ensure that the board is connected to your computer. If it is correctly connected, build and flash the code by clicking Run As
.
Core/Src/main.c
. Remove static
from the declaration of the MX_USART1_UART_Init()
function and also from its definition. Try Run As
again.With the model now deployed on the STM32 board, you are ready to test it.