Building Torizon OS for STM32MP1 and STM32MP2
1. Overview
This page describes how to build the Torizon OS for the STM32MPx development boards, including:
STM32MP257x-EV1
STM32MP257x-DKx
STM32MP157x-DKx.
2. Understanding Build Structure
The base principles for building Torizon OS for the STM32MP architecture are the same as for the other targets described in the official Torizon OS documentation: https://developer.toradex.com/torizon/in-depth/build-torizoncore-from-source-with-yocto-projectopenembedded/.
The main difference is that the STM32MP build requires 2 additional meta-layers. These are:
meta-st-stm32mp- BSP Layer for the STM32MP targets developed by STMicroelectonics for the OpenSTLinux project:
Category:Yocto-based OpenSTLinux embedded software - stm32mpu meta-emcraft-torizon-st- adaptation of the STM32MP BSP for Torizon OS developed by Emcraft.
What follows is the instructions on how to integrate these two layers in to the general Torizon OS Yocto project and then build Torizon OS for the STM32MP targets.
3. Preparing BSP for Build
Perform the following steps:
Set up the default
gituser and e-mail:$ git config --global user.email "you@example.com" $ git config --global user.name "Your Name"Install the
repoutility to the development host:$ mkdir ~/bin $ PATH=~/bin:$PATH $ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repoCreate a working directory for the Yocto build, go into that directory:
$ cd ~ $ mkdir ~/yocto-workdir $ cd ~/yocto-workdirInitialize the Torizon OS repository:
$ repo init -u git://git.toradex.com/toradex-manifest.git -b scarthgap-7.x.y -m torizon/default.xmlSync the repositories:
$ repo syncDownload the ST32MP BSP layer:
$ git -C layers clone -b openstlinux-6.6-yocto-scarthgap-mpu-v25.03.19 https://github.com/STMicroelectronics/meta-st-stm32mpDownload the ST32MP Torizon compatibility layer:
$ git -C layers clone -b scarthgap git@github.com:EmcraftSystems/meta-emcraft-torizon-st.gitReplace the setup environment link:
$ ln -sf layers/meta-emcraft-torizon-st/scripts/setup-environment setup-environment
4. Building BSP Images
Perform the following steps:
Use the Docker container provided by Toradex to setup the build environment in the work directory
~/yocto-workdirprepared in previous steps:$ docker run --rm -it --name=crops -v ~/yocto-workdir:/workdir --workdir=/workdir torizon/crops:scarthgap-7.x.y /bin/bashIn the Docker console set up the environment for a specific STM32MP board:
MACHINE=<MACHINE> source setup-environment [BUILDDIR], whereMACHINEis one of the supported STM32MP targets:stm32mp25-evalfor the STM32MP2 Evaluation kitstm32mp25-discofor the STM32MP2 Discovery kitstm32mp15-discofor STM32MP157 Discovery kit,BUILDDIRis the directory where you would like to to store the build files. For example:$$ MACHINE=stm32mp25-eval source setup-environment build-stm32mp25-evalRepeat the step of configuring the Git user name and email:
$$ git config --global user.email "you@example.com" $$ git config --global user.name "Your Name"Build the Torizon OS images:
$$ bitbake torizon-docker
5. Understanding Build Outcome
When the build has successfully completed, the following build artifacts located in the $BUILDDIR/deploy/images/$MACHINE can be used to install Torizon OS to the STM32MP target board (refer to Installing Torizon OS to STM32MP Targets):
arm-trusted-firmware/- the directory with FSBL (= Trusted Firmware-A) images:fip/- the directory with FIP (= U-Boot) images to be installed to eMMC or SD card:flashlayout_torizon-docker/optee/- the directory with eMMC or SD card layout to be used with the STM32_Programmertorizon-docker-<MACHINE>.ota-ext4- main TorizonOS OSTree based image, including the Linux kernel images and the root file system.
For example, the following images will be deployed for the STM32MP2 Evaluation kit:
arm-trusted-firmware/:tf-a-stm32mp257f-ev1-usb.stm32- FSBL to boot the STM32MP2 targets over USB for the initial installationtf-a-stm32mp257f-ev1-optee-emmc.stm32- FSBL to be installed and boot the STM32MP2 targets from eMMCtf-a-stm32mp257f-ev1-optee-sdcard.stm32- FSBL to be installed and boot the STM32MP2 targets from SD cardmetadata.bin- FSBL metadata.
fip/:fip-stm32mp257f-ev1-ddr-optee-emmc.bin- required to initialize DDRfip-stm32mp257f-ev1-ddr-optee-sdcard.bin- required to initialize DDRfip-stm32mp257f-ev1-optee-emmc.bin- main bootloader image for eMMCfip-stm32mp257f-ev1-optee-sdcard.bin- main bootloader image for SD card
flashlayout_torizon-core-docker/optee/:FlashLayout_emmc_stm32mp257f-ev1-optee.tsv- eMMC layout to be used with the STM32_ProgrammerFlashLayout_sdcard_stm32mp257f-ev1-optee.tsv- SD card layout to be used with the STM32_Programmer
torizon-docker-stm32mp25-eval.ota-ext4- main Torizon OS OSTree based image, including the Linux kernel images and the root file system.