Registered User |
Registered User Tag: 2017 source edit |
||
(282 intermediate revisions by 14 users not shown) | |||
Line 1: | Line 1: | ||
<noinclude>{{ApplicableFor | |||
|MPUs list=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x | |||
|MPUs checklist=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x | |||
}}</noinclude> | |||
==Purpose== | ==Purpose== | ||
This article explains how to update the [[Boot_chain_overview|boot chain]] ( | This article explains how to update the [[Boot_chain_overview|boot chain]] (OP-TEE with FIP) for a "custom" device tree. <br/> | ||
This article concentrates in particular on generating a "custom" device tree based on the STM32CubeMX.<br/> | |||
This article describes how to update the device tree compiled (DTB) part of the boot binaries. | This article describes how to update the device tree compiled (DTB) part of the boot binaries. | ||
== | ==Rational== | ||
There are various | There are various reasons for using a custom ''device tree'', such as: | ||
* the description of a new and private board | * the description of a new and private board | ||
* the swapping of some internal peripherals from Cortex<sup>®</sup>-M side to Cortex-A side ( | * the swapping of some internal peripherals from Cortex<sup>®</sup>-M side to Cortex<sup>®</sup>-A side (and vice versa) | ||
==Prerequisites== | ==Prerequisites== | ||
{{Info|Even if STMicroelectronics strongly recommends to use a Linux<sup>®</sup> environment, the steps described in this article can be executed in a [[PC_prerequisites#WSL2_-28experimental-29|WSL2]] (Windows Sub-system Linux 2) environment. }} | {{Info|Even if STMicroelectronics strongly recommends to use a Linux<sup>®</sup> environment, the steps described in this article can be executed in a [[PC_prerequisites#WSL2_-28experimental-29|WSL2]] (Windows Sub-system Linux 2) environment. }} | ||
Compiling a new device tree means updating three software components belonging to the complete [[Boot_chain_overview|boot chain]] | Compiling a new device tree means updating three software components belonging to the complete [[Boot_chain_overview|boot chain]], Trusted Firmware-A (TF-A), U-Boot, and Linux kernel.<br/> | ||
The material required to update the above software components is the following: | |||
* '''[[:Category:Starter Package|Starter Package]]''': | |||
** For ''{{MicroprocessorDevice | device=1}}'': '''[https://www.st.com/en/embedded-software/stm32mp1starter.html#get-software {{EcosystemRelease/Package | package=Images package | request=name | device=MP1 | revision=6.1.0 }}]''' | |||
** For ''{{MicroprocessorDevice | device=2}}'': '''[https://www.st.com/en/embedded-software/stm32mp2starter.html#get-software {{EcosystemRelease/Package | package=Images package | request=name | device=MP2_A35_TD | revision=latest }}]''' | |||
* '''[[Which STM32MPU Embedded Software Package better suits your needs#Developer Package for the Yocto-based OpenSTLinux embedded software|Developer package]]''': | |||
** the component sources and patches: '''[https://www.st.com/en/embedded-software/stm32mp1dev.html#get-software {{EcosystemRelease/Package | package=OpenSTLinux BSP package | request=name | revision=6.1.0}}]''' | |||
** the SDK toolchain: | |||
*** For ''{{MicroprocessorDevice | device=1}}'': '''[https://www.st.com/en/embedded-software/stm32mp1dev.html#get-software {{EcosystemRelease/Package | package=SDK package | device=MP1 | request=name | revision=6.1.0}}]''' | |||
*** For ''{{MicroprocessorDevice | device=2}}'': '''[https://www.st.com/en/embedded-software/stm32mp2dev.html#get-software {{EcosystemRelease/Package | package=SDK package | device=MP2 | request=name | revision=6.1.0}}]''' | |||
* the '''[[STM32CubeProgrammer]]''', which is the tool used to flash the images and binaries into the target. | * the '''[[STM32CubeProgrammer]]''', which is the tool used to flash the images and binaries into the target. | ||
<br/> | <br/> | ||
* '''Custom device tree sources''': | * '''Custom device tree sources''': | ||
** In the rest of this document, we assume that the custom device tree is generated by [[STM32CubeMX]] and stored in a ''MyDeviceTree_fromCubeMX.tar.xz'' tarball with following file tree: | ** In the rest of this document, we assume that the custom device tree is generated by [[STM32CubeMX]] and stored in a ''MyDeviceTree_fromCubeMX.tar.xz'' tarball with following file tree: | ||
< | {{STLightBlue|MyDeviceTree_fromCubeMX}} | ||
|-- | ├── {{HighlightParam|<CortexA>}} | ||
| | │ └── {{STLightBlue|DeviceTree}} | ||
| | │ └── {{HighlightParam|''<ProjectName>''}} | ||
│ ├── {{STLightBlue|kernel}} {{Highlight|Device tree files for Linux kernel}} | |||
| |-- | │ │ │── {{HighlightParam|<soc-machine>}}-{{HighlightParam|<ProjectName>}}-mx.dts | ||
|-- | │ │ └── [...] | ||
| |-- | │ ├── {{STLightBlue|optee-os}} {{Highlight|Device tree files for OP-TEE}} | ||
| | │ │ │── {{HighlightParam|<soc-machine>}}-{{HighlightParam|<ProjectName>}}-mx.dts | ||
| | │ │ └── [...] | ||
< | │ ├── {{STLightBlue|tf-a}} {{Highlight|Device tree files for TF-A}} | ||
< | │ │ │── {{HighlightParam|<soc-machine>}}-{{HighlightParam|<ProjectName>}}-mx.dts | ||
* Make sure the hardware configuration described in '''[[PC_prerequisites#Linux PC]] has been executed''' (even with a [[PC_prerequisites#WSL2_-28experimental-29|WSL2]] setup) | │ │ └── [...] | ||
│ └── {{STLightBlue|u-boot}} {{Highlight|Device tree files for U-BOOT}} | |||
│ │── {{HighlightParam|<soc-machine>}}-{{HighlightParam|<ProjectName>}}-mx.dts | |||
│ └── [...] | |||
├── {{STLightBlue|CM33}} {{Highlight|(Availability depending of configuration used with STM32CubeMX tool)}} | |||
│ └── {{STLightBlue|DeviceTree}} | |||
│ └── {{HighlightParam|''<ProjectName>''}} | |||
│ ├── {{STLightBlue|mcuboot}} {{Highlight|Device tree files for MCUBOOT}} | |||
│ │ │── {{HighlightParam|<soc-machine>}}-{{HighlightParam|<ProjectName>}}-mx.dts | |||
│ │ └── [...] | |||
│ └── {{STLightBlue|tf-m}} {{Highlight|Device tree files for TF-M}} | |||
│ │── {{HighlightParam|<soc-machine>}}-{{HighlightParam|<ProjectName>}}-mx.dts | |||
│ └── [...] | |||
└── {{STLightBlue|ExtMemLoader}} {{Highlight|(Availability depending of configuration used with STM32CubeMX tool)}} | |||
└── {{HighlightParam|''<ProjectName>''}} | |||
├── {{STLightBlue|optee-os}} {{Highlight|Specific device tree files to generate FIP programmer binary}} | |||
│ │── {{HighlightParam|<soc-machine>}}-{{HighlightParam|<ProjectName>}}-mx.dts | |||
│ └── [...] | |||
├── {{STLightBlue|tf-a}} {{Highlight|Specific device tree files to generate TF-A and FIP programmer binaries}} | |||
│ │── {{HighlightParam|<soc-machine>}}-{{HighlightParam|<ProjectName>}}-mx.dts | |||
│ └── [...] | |||
└── {{STLightBlue|u-boot}} {{Highlight|Specific device tree files to generate FIP programmer binary}} | |||
│── {{HighlightParam|<soc-machine>}}-{{HighlightParam|<ProjectName>}}-mx.dts | |||
└── [...] | |||
Description: | |||
{{HighlightParam|''<CortexA>''}}: ''CA7'' or ''CA35'' depending of configuration selected with STM32CubeMX tool | |||
{{HighlightParam|''<soc-machine>''}}: the soc name without '-dkX' or '-evX' extension (e.g. ''stm32mp135f'', ''stm32mp157f'', ''stm32mp257f'', etc) | |||
{{HighlightParam|''<ProjectName>''}}: the ''[[STM32CubeMX]] user project name'' | |||
* Make sure the hardware configuration described in the '''[[PC_prerequisites#Linux-C2-AE_PC|PC prerequisites article]] has been executed''' (even with a [[PC_prerequisites#WSL2_-28experimental-29|WSL2]] setup) | |||
{{Important|The rest of the document is as example for a {{Highlight|{{Board | type=135F-DK | name=short}}}} board.<br/> The supported configuration used is {{Highlight|''optee''}} boot scheme on {{Highlight|''sdcard''}} storage. And for the ''MyDeviceTree_fromCubeMX.tar.xz'' tarball, the ''<CortexA>'' is set to ''CA7'', ''<soc-machine>'' to ''stm32mp135f'' and ''<ProjectName>'' to ''my_demo'', giving tarball file tree as: | |||
{{STLightBlue|MyDeviceTree_fromCubeMX}} | |||
└── {{STLightBlue|CA7}} | |||
└── {{STLightBlue|DeviceTree}} | |||
└── {{STLightBlue|MY_DEMO}} | |||
├── {{STLightBlue|kernel}} {{Highlight|Device tree files for Linux kernel}} | |||
│ │── stm32mp135f-my_demo-mx.dts | |||
│ └── [...] | |||
├── {{STLightBlue|optee-os}} {{Highlight|Device tree files for OP-TEE}} | |||
│ │── stm32mp135f-my_demo-mx.dts | |||
│ └── [...] | |||
├── {{STLightBlue|tf-a}} {{Highlight|Device tree files for TF-A}} | |||
│ │── stm32mp135f-my_demo-mx.dts | |||
│ └── [...] | |||
└── {{STLightBlue|u-boot}} {{Highlight|Device tree files for U-BOOT}} | |||
│── stm32mp135f-my_demo-mx.dts | |||
└── [...] | |||
However the procedure below is applicable for '''{{MicroprocessorDevice | device=1}}''' and '''{{MicroprocessorDevice | device=2}}'''.}} | |||
==Preparing your environment== | ==Preparing your environment== | ||
It is recommended to organize the numerous inputs described in [[#Prerequisites]] in your environment.<br/> | It is recommended to organize the numerous inputs described in [[#Prerequisites|prerequisites]] in your environment.<br/> | ||
First create a dedicated ''WORKDIR'' under your ''HOME'' folder and copy there all the inputs listed in [[#Prerequisites]]: | First create a dedicated ''WORKDIR'' under your ''HOME'' folder and copy there all the inputs listed in [[#Prerequisites|prerequisites]]: | ||
{{PC$}}cd $HOME | |||
{{PC$}}mkdir WORKDIR | |||
{{PC$}}cd WORKDIR | |||
{{PC$}}export WORKDIR="$PWD" | |||
{{PC$}}tar --strip-components=1 -xf {{EcosystemRelease/Package | package=Images package | request=name | revision=6.1.0}} -C $WORKDIR/ | |||
{{PC$}}tar --strip-components=1 -xf {{EcosystemRelease/Package | package=OpenSTLinux BSP package | request=name | revision=6.1.0}} -C $WORKDIR/ | |||
{{PC$}}tar --strip-components=1 -xf {{EcosystemRelease/Package| package=SDK package | request=name | revision=6.1.0}} -C $WORKDIR/ | |||
{{PC$}}tar xf MyDeviceTree_fromCubeMX.tar.xz -C $WORKDIR/ | |||
Set-up a dedicated {{highlight|''EXTDT_DIR''}} variable to access the device tree source file | |||
{{PC$}}pushd $WORKDIR/MyDeviceTree_fromCubeMX | |||
{{PC$}}export EXTDT_DIR="$PWD" | |||
{{PC$}}popd | |||
Set-up a dedicated {{highlight|''FWDDR_DIR''}} variable to access the DDR firmware source file | |||
{{PC$}}pushd $WORKDIR/sources/ostl-linux/stm32mp-ddr-phy-* | |||
{{PC$}}export FWDDR_DIR="$PWD" | |||
{{PC$}}popd | |||
Set-up a dedicated {{highlight|''FIP_DEPLOYDIR_ROOT''}} variable to store all build output artifacts to generate FIP binaries. | |||
{{PC$}}mkdir -p $WORKDIR/FIP_artifacts | |||
{{PC$}}pushd $WORKDIR/FIP_artifacts | |||
{{PC$}}export FIP_DEPLOYDIR_ROOT=$PWD | |||
{{PC$}}popd | |||
Then proceed with the [[STM32MPU_Developer_Package#Installing_the_SDK]] chapter. | |||
The commands described in the rest of the document must be run in an SDK environment context: ([[ | The commands described in the rest of the document must be run in an SDK environment context: ([[STM32MPU_Developer_Package#Starting_up_the_SDK]]). | ||
==Updating the kernel device tree == | ==Updating the kernel device tree == | ||
{{Info|The procedure below is an extract of the README.HOW_TO.txt.stm32mp1 file which is available in ''$WORKDIR/sources/ostl-linux/linux-stm32mp-*''. Note: the "README.HOW_TO.txt.{{HighlightParam|<board flavor>}}" file contains some useful ''grep "$> commands that are needed to build the artifact of kernel.}} | |||
* unpack and patch sources | |||
{{PC$}}pushd $WORKDIR | |||
{{PC$}}mkdir -p kernel | |||
{{PC$}}tar xf sources/ostl-linux/linux-stm32mp-*/linux-*.tar.xz -C kernel | |||
{{PC$}}mv kernel/linux-* kernel/kernel-sources/ | |||
{{PC$}}pushd kernel/kernel-sources/ | |||
{{PC$}}for p in $(ls -1 ../../sources/ostl-linux/linux-stm32mp-*/*.patch); do patch -p1 < $p; done | |||
{{PC$}}popd | |||
{{PC$}}popd | |||
* regenerate the kernel DTB | |||
<u>'''For our example:'''</u> | |||
{{PC$}}pushd $WORKDIR/kernel/kernel-sources | |||
{{PC$}}export OUTPUT_BUILD_DIR=$PWD/../build | |||
{{PC$}}mkdir -p ${OUTPUT_BUILD_DIR} | |||
{{PC$}}make O="${OUTPUT_BUILD_DIR}" {{HighlightParam|multi_v7_defconfig}} fragment*.config | |||
{{PC$}}for f in `ls -1 ../../sources/ostl-linux/linux-stm32mp-*/fragment*.config`; do scripts/kconfig/merge_config.sh -m -r -O ${OUTPUT_BUILD_DIR} ${OUTPUT_BUILD_DIR}/.config $f; done | |||
{{PC$}}(yes "" || true ) | make oldconfig O="${OUTPUT_BUILD_DIR}" | |||
{{PC$}}make O="${OUTPUT_BUILD_DIR}" KBUILD_EXTDTS="${EXTDT_DIR}/{{HighlightParam|CA7}}/DeviceTree/MY_DEMO/linux" {{HighlightParam|stm32mp135f}}-my_demo-mx.dtb | |||
{{PC$}}popd | |||
{{PC$}}ls -l ${OUTPUT_BUILD_DIR}/arch/${ARCH}/boot/dts/{{HighlightParam|stm32mp135f}}-my_demo-mx.dtb | |||
<u>'''For other examples ({{MicroprocessorDevice | device=1}} or {{MicroprocessorDevice | device=2}}):'''</u><br/> | |||
Please replace green words with cell content: | |||
{| class="st-table" | |||
! style="text-align:center" class="col-blue-light-bg" | '''Example''' | |||
! style="text-align:center" class="col-blue-dark-bg" |'''{{MicroprocessorDevice | device=1}}''' | |||
! colspan="3" style="text-align:center" class="col-blue-dark-bg" | '''{{MicroprocessorDevice | device=2}}''' | |||
|- | |||
! style="text-align:center" class="col-blue-light-bg" | ''{{Board | type=135F-DK | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=157F-EV1 | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=215F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=235F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=257F-EV1 |name=short}}'' | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp135f}} | |||
| style="text-align:center" | stm32mp157f | |||
| style="text-align:center" | stm32mp215f | |||
| style="text-align:center" | stm32mp235f | |||
| style="text-align:center" | stm32mp257f | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|CA7}} | |||
| style="text-align:center" | CA7 | |||
| colspan="3" style="text-align:center" | CA35 | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|multi_v7_defconfig}} | |||
| style="text-align:center" | multi_v7_defconfig | |||
| colspan="3" style="text-align:center" | defconfig | |||
|} | |||
==Updating BOOT firmware == | |||
===Updating the TF-A device tree === | |||
{{Info|The procedure below is an extract of the README.HOW_TO.txt.stm32mp1 file which is available in ''$WORKDIR/sources/ostl-linux/tf-a-stm32mp-*''. Note: the "README.HOW_TO.txt.{{HighlightParam|<board flavor>}}" file contains some useful ''grep "$> commands that are needed to build the artifact of tf-a.}} | |||
* unpack and patch sources | |||
{{PC$}}pushd $WORKDIR | |||
{{PC$}}pushd sources/ostl-linux/tf-a-stm32mp-v[0-9]* | |||
{{PC$}}mkdir -p tf-a-sources | |||
{{PC$}}tar xf tf-a-stm32mp-v[0-9]*.tar.* --one-top-level=tf-a-sources --strip-components=1 | |||
{{PC$}}pushd tf-a-sources | |||
{{PC$}}for p in `ls -1 ../*.patch`; do patch -p1 < $p; done | |||
{{PC$}}popd | |||
{{PC$}}popd | |||
* regenerate TF-A | |||
<u>'''For our example:'''</u> | |||
{{ | {{PC$}}pushd $WORKDIR/sources/ostl-linux/tf-a-stm32mp-v[0-9]*/tf-a-sources | ||
{{PC$}}export EXTDT_DIR_TF_A={{HighlightParam|CA7}}/DeviceTree/MY_DEMO/tf-a | |||
{{PC$}}export EXTDT_DIR_TF_A_SERIAL={{HighlightParam|CA7}}/DeviceTree/MY_DEMO/tf-a | |||
{{PC$}}make -f ../Makefile.sdk.{{HighlightParam|stm32mp1}} DEPLOYDIR=${FIP_DEPLOYDIR_ROOT}/arm-trusted-firmware TF_A_DEVICETREE={{HighlightParam|stm32mp135f}}-my_demo-mx TF_A_CONFIG="optee-sdcard optee-programmer-usb" '''stm32''' | |||
{{PC$}}popd | |||
<u>'''For other examples ({{MicroprocessorDevice | device=1}} or {{MicroprocessorDevice | device=2}}):'''</u><br/> | |||
:{{ | Please replace green words with cell content: | ||
:{{ | {| class="st-table" | ||
:{{ | ! style="text-align:center" class="col-blue-light-bg" | '''Example''' | ||
:{{ | ! style="text-align:center" class="col-blue-dark-bg" |'''{{MicroprocessorDevice | device=1}}''' | ||
! colspan="3" style="text-align:center" class="col-blue-dark-bg" | '''{{MicroprocessorDevice | device=2}}''' | |||
:{{ | |- | ||
! style="text-align:center" class="col-blue-light-bg" | ''{{Board | type=135F-DK | name=short}}'' | |||
:{{ | ! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=157F-EV1 | name=short}}'' | ||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=215F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=235F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=257F-EV1 |name=short}}'' | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp135f}} | |||
| style="text-align:center" | stm32mp157f | |||
| style="text-align:center" | stm32mp215f | |||
| style="text-align:center" | stm32mp235f | |||
| style="text-align:center" | stm32mp257f | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|CA7}} | |||
| style="text-align:center" | CA7 | |||
| colspan="3" style="text-align:center" | CA35 | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp1}} | |||
| style="text-align:center" | stm32mp1 | |||
| colspan="3" style="text-align:center" | stm32mp2 | |||
|} | |||
=== | === Updating the OP-TEE device tree === | ||
{{Info|The procedure below is an extract of the README.HOW_TO.txt.stm32mp1 file which is available in ''$WORKDIR/sources/ostl-linux/optee-os-stm32mp-*''. Note: the "README.HOW_TO.txt.{{HighlightParam|<board flavor>}}" file contains some useful ''grep "$> commands that are needed to build the artifact of OP-TEE.}} | |||
:{{ | |||
* unpack and patch sources | |||
{{ | {{PC$}}pushd $WORKDIR | ||
{{PC$}}pushd sources/ostl-linux/optee-os-stm32mp-[0-9]* | |||
{{PC$}}tar xf optee-os-stm32mp-[0-9]*.tar.* --one-top-level=optee-os-sources --strip-components=1 | |||
{{PC$}}pushd optee-os-sources | |||
{{PC$}}tar xfz ../fonts.tar.gz | |||
{{PC$}}for p in `ls -1 ../*.patch`; do patch -p1 < $p; done | |||
{{PC$}}popd | |||
{{PC$}}popd | |||
:{{PC$}} pushd $WORKDIR/ | * regenerate OP-TEE binaries | ||
<u>'''For our example:'''</u> | |||
{{PC$}}pushd $WORKDIR/sources/ostl-linux/optee-os-stm32mp-[0-9]*/optee-os-sources | |||
{{PC$}}export EXTDT_DIR_OPTEE={{HighlightParam|CA7}}/DeviceTree/MY_DEMO/optee-os | |||
{{PC$}}export EXTDT_DIR_OPTEE_SERIAL={{HighlightParam|CA7}}/DeviceTree/MY_DEMO/optee-os | |||
{{PC$}}make -f ../Makefile.sdk.{{HighlightParam|stm32mp1}} DEPLOYDIR=${FIP_DEPLOYDIR_ROOT}/optee CFG_EMBED_DTB_SOURCE_FILE={{HighlightParam|stm32mp135f}}-my_demo-mx.dtb OPTEE_CONFIG="optee-sdcard optee-programmer-usb" '''optee''' | |||
{{PC$}}popd | |||
=== | <u>'''For other examples ({{MicroprocessorDevice | device=1}} or {{MicroprocessorDevice | device=2}}):'''</u><br/> | ||
Please replace green words with cell content: | |||
{| class="st-table" | |||
! style="text-align:center" class="col-blue-light-bg" | '''Example''' | |||
! style="text-align:center" class="col-blue-dark-bg" |'''{{MicroprocessorDevice | device=1}}''' | |||
! colspan="3" style="text-align:center" class="col-blue-dark-bg" | '''{{MicroprocessorDevice | device=2}}''' | |||
|- | |||
! style="text-align:center" class="col-blue-light-bg" | ''{{Board | type=135F-DK | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=157F-EV1 | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=215F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=235F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=257F-EV1 |name=short}}'' | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp135f}} | |||
| style="text-align:center" | stm32mp157f | |||
| style="text-align:center" | stm32mp215f | |||
| style="text-align:center" | stm32mp235f | |||
| style="text-align:center" | stm32mp257f | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|CA7}} | |||
| style="text-align:center" | CA7 | |||
| colspan="3" style="text-align:center" | CA35 | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp1}} | |||
| style="text-align:center" | stm32mp1 | |||
| colspan="3" style="text-align:center" | stm32mp2 | |||
|} | |||
=== Updating the U-Boot device tree === | |||
{{Info|The procedure below is an extract of the README.HOW_TO.txt.stm32mp1 file which is available in ''$WORKDIR/sources/ostl-linux/u-boot-stm32mp-*''. Note: the "README.HOW_TO.txt.{{HighlightParam|<board flavor>}}" file contains some useful ''grep "$> commands that are needed to build the artifact of U-Boot.}} | |||
* unpack and patch sources | |||
{{PC$}}pushd $WORKDIR | |||
{{PC$}}pushd sources/ostl-linux/u-boot-stm32mp-v[0-9]* | |||
{{PC$}}tar xf u-boot-stm32mp-v[0-9]*.tar.* --one-top-level=u-boot-sources --strip-components=1 | |||
{{PC$}}pushd u-boot-sources | |||
{{ | {{PC$}}for p in `ls -1 ../*.patch`; do patch -p1 < $p; done | ||
{{PC$}}popd | |||
{{PC$}}popd | |||
:{{PC$}} pushd $WORKDIR | * regenerate U-Boot binaries | ||
<u>'''For our example:'''</u> | |||
{{PC$}}pushd $WORKDIR/sources/ostl-linux/u-boot-stm32mp-v[0-9]*/u-boot-sources | |||
{{PC$}}export EXTDT_DIR_UBOOT={{HighlightParam|CA7}}/DeviceTree/MY_DEMO/u-boot | |||
{{PC$}}export EXTDT_DIR_UBOOT_SERIAL={{HighlightParam|CA7}}/DeviceTree/MY_DEMO/u-boot | |||
{{PC$}}make -f ../Makefile.sdk.{{HighlightParam|stm32mp1}} DEPLOYDIR=${FIP_DEPLOYDIR_ROOT}/u-boot UBOOT_DEFCONFIG_default={{HighlightParam|stm32mp13_defconfig}} UBOOT_DEFCONFIG_programmer={{HighlightParam|stm32mp13_defconfig}} DEVICE_TREE={{HighlightParam|stm32mp135f}}-my_demo-mx '''uboot''' | |||
{{PC$}}popd | |||
=== | <u>'''For other examples ({{MicroprocessorDevice | device=1}} or {{MicroprocessorDevice | device=2}}):'''</u><br/> | ||
:{{ | Please replace green words with cell content: | ||
:{{ | {| class="st-table" | ||
:{{ | ! style="text-align:center" class="col-blue-light-bg" | '''Example''' | ||
! style="text-align:center" class="col-blue-dark-bg" |'''{{MicroprocessorDevice | device=1}}''' | |||
! colspan="3" style="text-align:center" class="col-blue-dark-bg" | '''{{MicroprocessorDevice | device=2}}''' | |||
|- | |||
! style="text-align:center" class="col-blue-light-bg" | ''{{Board | type=135F-DK | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=157F-EV1 | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=215F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=235F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=257F-EV1 |name=short}}'' | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp135f}} | |||
| style="text-align:center" | stm32mp157f | |||
| style="text-align:center" | stm32mp215f | |||
| style="text-align:center" | stm32mp235f | |||
| style="text-align:center" | stm32mp257f | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp13_defconfig}} | |||
| style="text-align:center" | stm32mp15_defconfig | |||
| style="text-align:center" | stm32mp21_defconfig | |||
| style="text-align:center" | stm32mp23_defconfig | |||
| style="text-align:center" | stm32mp25_defconfig | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|CA7}} | |||
| style="text-align:center" | CA7 | |||
| colspan="3" style="text-align:center" | CA35 | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp1}} | |||
| style="text-align:center" | stm32mp1 | |||
| colspan="3" style="text-align:center" | stm32mp2 | |||
|} | |||
=== Updating the FIP image === | |||
Once all BOOT binaries have been generated, the FIP image can be generated using the fiptool wrapper script available from any of the BOOT source code location: | |||
:- $WORKDIR/sources/ostl-linux/tf-a-stm32mp-v[0-9]*/tf-a-sources | |||
:or | |||
:- $WORKDIR/sources/ostl-linux/optee-os-stm32mp-[0-9]*/optee-os-sources | |||
:or | |||
:- $WORKDIR/sources/ostl-linux/u-boot-stm32mp-v[0-9]*/u-boot-sources | |||
<u>'''For our example:'''</u> | |||
{{ | {{PC$}}pushd $WORKDIR/sources/ostl-linux/u-boot-stm32mp-v[0-9]*/u-boot-sources | ||
{{PC$}}export FIP_CONFIG="optee-sdcard optee-programmer-usb" | |||
{{PC$}}export FIP_DEVICETREE={{HighlightParam|stm32mp135f}}-my_demo-mx | |||
{{PC$}}../fiptool-stm32mp.{{HighlightParam|stm32mp1}} | |||
{{PC$}}popd | |||
<u>'''For other examples ({{MicroprocessorDevice | device=1}} or {{MicroprocessorDevice | device=2}}):'''</u><br/> | |||
:{{ | Please replace green words with cell content: | ||
: '' | {| class="st-table" | ||
:{{ | ! style="text-align:center" class="col-blue-light-bg" | '''Example''' | ||
: '' | ! style="text-align:center" class="col-blue-dark-bg" |'''{{MicroprocessorDevice | device=1}}''' | ||
! colspan="3" style="text-align:center" class="col-blue-dark-bg" | '''{{MicroprocessorDevice | device=2}}''' | |||
:{{ | |- | ||
! style="text-align:center" class="col-blue-light-bg" | ''{{Board | type=135F-DK | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=157F-EV1 | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=215F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=235F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=257F-EV1 |name=short}}'' | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp135f}} | |||
| style="text-align:center" | stm32mp157f | |||
| style="text-align:center" | stm32mp215f | |||
| style="text-align:center" | stm32mp235f | |||
| style="text-align:center" | stm32mp257f | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp1}} | |||
| style="text-align:center" | stm32mp1 | |||
| colspan="3" style="text-align:center" | stm32mp2 | |||
|} | |||
== | == Update target board == | ||
=== Copy new boot chain firmware into the target === | |||
The [[STM32CubeProgrammer]] is used to populate the new boot chain firmware to the target storage. | |||
The | |||
<u>'''For our example:'''</u><br/> | |||
The binaries needed to program the microSD card from target board with [[STM32CubeProgrammer]] are: | |||
{{ | - ${FIP_DEPLOYDIR_ROOT}/arm-trusted-firmware/tf-a-{{HighlightParam|stm32mp135f}}-my_demo-mx-optee-programmer-usb.stm32 (''fsbl-boot'' partition) | ||
- ${FIP_DEPLOYDIR_ROOT}/fip/fip-{{HighlightParam|stm32mp135f}}-my_demo-mx-optee-programmer-usb.bin (''fip-boot'' partition) | |||
: | The binaries to use to populate microSD card partitions are: | ||
- ${FIP_DEPLOYDIR_ROOT}/arm-trusted-firmware/tf-a-{{HighlightParam|stm32mp135f}}-my_demo-mx-optee-sdcard.stm32 ({{HighlightParam|fsbl1}} and {{HighlightParam|fsbl2}} partitions) | |||
- ${FIP_DEPLOYDIR_ROOT}/fip/fip-{{HighlightParam|stm32mp135f}}-my_demo-mx-optee-sdcard.bin (''fip-a'' partition) | |||
=== | <u>'''For other examples ({{MicroprocessorDevice | device=1}} or {{MicroprocessorDevice | device=2}}):'''</u><br/> | ||
:{{ | Please replace green words with cell content: | ||
:{{ | {| class="st-table" | ||
:{{ | ! style="text-align:center" class="col-blue-light-bg" | '''Example''' | ||
! style="text-align:center" class="col-blue-dark-bg" |'''{{MicroprocessorDevice | device=1}}''' | |||
! colspan="3" style="text-align:center" class="col-blue-dark-bg" | '''{{MicroprocessorDevice | device=2}}''' | |||
|- | |||
! style="text-align:center" class="col-blue-light-bg" | ''{{Board | type=135F-DK | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=157F-EV1 | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=215F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=235F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=257F-EV1 |name=short}}'' | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp135f}} | |||
| style="text-align:center" | stm32mp157f | |||
| style="text-align:center" | stm32mp215f | |||
| style="text-align:center" | stm32mp235f | |||
| style="text-align:center" | stm32mp257f | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|fsbl1}} | |||
| style="text-align:center" | fsbl1 | |||
| colspan="3" style="text-align:center" | fsbla1 | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|fsbl2}} | |||
| style="text-align:center" | fsbl2 | |||
| colspan="3" style="text-align:center" | fsbla2 | |||
|} | |||
{{info|Note according to what have been modified in device tree files, it might be needed to reset the ''u-boot-env'' partition.}} | |||
{{ | |||
=== Copy the new DTB into bootfs partition=== | |||
There are two methods to update the ''bootfs'' partition with new kernel DTB on target. | |||
: | ==== Option 1: On an up and running target==== | ||
For this method, the board IP address ({{Highlight|<Target_IP>}}) is needed | |||
<u>'''For our example:'''</u><br/> | |||
{{PC$}}scp ${OUTPUT_BUILD_DIR}/arch/${ARCH}/boot/dts/{{HighlightParam|stm32mp135f}}-my_demo-mx.dtb root@{{Highlight|<Target_IP>}}:/boot/ | |||
{{ | |||
<u>'''For other examples ({{MicroprocessorDevice | device=1}} or {{MicroprocessorDevice | device=2}}):'''</u><br/> | |||
Please replace green words with cell content: | |||
{| class="st-table" | |||
! style="text-align:center" class="col-blue-light-bg" | '''Example''' | |||
! style="text-align:center" class="col-blue-dark-bg" |'''{{MicroprocessorDevice | device=1}}''' | |||
! colspan="3" style="text-align:center" class="col-blue-dark-bg" | '''{{MicroprocessorDevice | device=2}}''' | |||
|- | |||
! style="text-align:center" class="col-blue-light-bg" | ''{{Board | type=135F-DK | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=157F-EV1 | name=short}}'' | |||
:{{ | ! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=215F-DK |name=short}}'' | ||
:{{ | ! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=235F-DK |name=short}}'' | ||
:{{ | ! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=257F-EV1 |name=short}}'' | ||
:{{ | |- | ||
:{{ | | style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp135f}} | ||
: | | style="text-align:center" | stm32mp157f | ||
| style="text-align:center" | stm32mp215f | |||
| style="text-align:center" | stm32mp235f | |||
| style="text-align:center" | stm32mp257f | |||
|} | |||
{{info|The new DTB will be taken into account on the next reboot of the target.}} | |||
==== Option 2: Directly into bootfs image==== | |||
With this method, the original ''bootfs'' partition image file is updated through a loopback mount on local host. | |||
This utility is available within any Linux Distribution (even through [[PC_prerequisites#WSL2_-28experimental-29|WSL2]])/ | |||
<u>'''For our example:'''</u><br/> | |||
{{PC$}}mkdir -p $WORKDIR/bootfs | |||
{{PC$}}mount -o loop st-image-bootfs-openstlinux-weston-{{HighlightParam|stm32mp1}}.ext4 $WORKDIR/bootfs | |||
{{PC$}}cp -f ${OUTPUT_BUILD_DIR}/arch/${ARCH}/boot/dts/{{HighlightParam|stm32mp135f}}-my_demo-mx.dtb $WORKDIR/bootfs | |||
{{PC$}}umount $WORKDIR/bootfs | |||
{{PC$}}sync | |||
=== | <u>'''For other examples ({{MicroprocessorDevice | device=1}} or {{MicroprocessorDevice | device=2}}):'''</u><br/> | ||
Please replace green words with cell content: | |||
{| class="st-table" | |||
! style="text-align:center" class="col-blue-light-bg" | '''Example''' | |||
:{{ | ! style="text-align:center" class="col-blue-dark-bg" |'''{{MicroprocessorDevice | device=1}}''' | ||
:{{ | ! colspan="3" style="text-align:center" class="col-blue-dark-bg" | '''{{MicroprocessorDevice | device=2}}''' | ||
|- | |||
! style="text-align:center" class="col-blue-light-bg" | ''{{Board | type=135F-DK | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=157F-EV1 | name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=215F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=235F-DK |name=short}}'' | |||
! style="text-align:center" class="col-blue-dark-bg" | ''{{Board | type=257F-EV1 |name=short}}'' | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp135f}} | |||
| style="text-align:center" | stm32mp157f | |||
| style="text-align:center" | stm32mp215f | |||
| style="text-align:center" | stm32mp235f | |||
| style="text-align:center" | stm32mp257f | |||
|- | |||
| style="text-align:center" class="col-blue-light-bg" | {{HighlightParam|stm32mp1}} | |||
| style="text-align:center" | stm32mp1 | |||
| colspan="3" style="text-align:center" | stm32mp2 | |||
|} | |||
Then use [[STM32CubeProgrammer]] to update the ''bootfs'' partition on target with the updated ''ext4'' image. | |||
<noinclude> | <noinclude> | ||
{{PublicationRequestId | 24428| 2022-08-29 | }} | |||
[[Category:How to build software]] | [[Category:How to build software]] | ||
</noinclude> | </noinclude> |
Latest revision as of 15:09, 1 July 2025
1. Purpose[edit | edit source]
This article explains how to update the boot chain (OP-TEE with FIP) for a "custom" device tree.
This article concentrates in particular on generating a "custom" device tree based on the STM32CubeMX.
This article describes how to update the device tree compiled (DTB) part of the boot binaries.
2. Rational[edit | edit source]
There are various reasons for using a custom device tree, such as:
- the description of a new and private board
- the swapping of some internal peripherals from Cortex®-M side to Cortex®-A side (and vice versa)
3. Prerequisites[edit | edit source]
![]() |
Even if STMicroelectronics strongly recommends to use a Linux® environment, the steps described in this article can be executed in a WSL2 (Windows Sub-system Linux 2) environment. |
Compiling a new device tree means updating three software components belonging to the complete boot chain, Trusted Firmware-A (TF-A), U-Boot, and Linux kernel.
The material required to update the above software components is the following:
- Starter Package:
- For STM32MP1 series: FLASH-stm32mp1-openstlinux-6.6-yocto-scarthgap-mpu-v25.06.11.tar.gz
- For STM32MP2 series: FLASH-stm32mp2-openstlinux-6.6-yocto-scarthgap-mpu-v25.06.11.tar.gz
- Developer package:
- the component sources and patches: SOURCES-stm32mp-openstlinux-6.6-yocto-scarthgap-mpu-v25.06.11.tar.gz
- the SDK toolchain:
- For STM32MP1 series: SDK-x86_64-stm32mp1-openstlinux-6.6-yocto-scarthgap-mpu-v25.06.11.tar.gz
- For STM32MP2 series: SDK-x86_64-stm32mp2-openstlinux-6.6-yocto-scarthgap-mpu-v25.06.11.tar.gz
- the STM32CubeProgrammer, which is the tool used to flash the images and binaries into the target.
- Custom device tree sources:
- In the rest of this document, we assume that the custom device tree is generated by STM32CubeMX and stored in a MyDeviceTree_fromCubeMX.tar.xz tarball with following file tree:
MyDeviceTree_fromCubeMX ├── <CortexA> │ └── DeviceTree │ └── <ProjectName> │ ├── kernel Device tree files for Linux kernel │ │ │── <soc-machine>-<ProjectName>-mx.dts │ │ └── [...] │ ├── optee-os Device tree files for OP-TEE │ │ │── <soc-machine>-<ProjectName>-mx.dts │ │ └── [...] │ ├── tf-a Device tree files for TF-A │ │ │── <soc-machine>-<ProjectName>-mx.dts │ │ └── [...] │ └── u-boot Device tree files for U-BOOT │ │── <soc-machine>-<ProjectName>-mx.dts │ └── [...] ├── CM33 (Availability depending of configuration used with STM32CubeMX tool) │ └── DeviceTree │ └── <ProjectName> │ ├── mcuboot Device tree files for MCUBOOT │ │ │── <soc-machine>-<ProjectName>-mx.dts │ │ └── [...] │ └── tf-m Device tree files for TF-M │ │── <soc-machine>-<ProjectName>-mx.dts │ └── [...] └── ExtMemLoader (Availability depending of configuration used with STM32CubeMX tool) └── <ProjectName> ├── optee-os Specific device tree files to generate FIP programmer binary │ │── <soc-machine>-<ProjectName>-mx.dts │ └── [...] ├── tf-a Specific device tree files to generate TF-A and FIP programmer binaries │ │── <soc-machine>-<ProjectName>-mx.dts │ └── [...] └── u-boot Specific device tree files to generate FIP programmer binary │── <soc-machine>-<ProjectName>-mx.dts └── [...]
Description:
<CortexA>: CA7 or CA35 depending of configuration selected with STM32CubeMX tool <soc-machine>: the soc name without '-dkX' or '-evX' extension (e.g. stm32mp135f, stm32mp157f, stm32mp257f, etc) <ProjectName>: the STM32CubeMX user project name
- Make sure the hardware configuration described in the PC prerequisites article has been executed (even with a WSL2 setup)
4. Preparing your environment[edit | edit source]
It is recommended to organize the numerous inputs described in prerequisites in your environment.
First create a dedicated WORKDIR under your HOME folder and copy there all the inputs listed in prerequisites:
SDK-x86_64-stm32mp1-openstlinux-6.6-yocto-scarthgap-mpu-v25.06.11.tar.gz -C $WORKDIR/ PC $>tar xf MyDeviceTree_fromCubeMX.tar.xz -C $WORKDIR/PC $>cd $HOME PC $>mkdir WORKDIR PC $>cd WORKDIR PC $>export WORKDIR="$PWD" PC $>tar --strip-components=1 -xf FLASH-stm32mp1-openstlinux-6.6-yocto-scarthgap-mpu-v25.06.11.tar.gz -C $WORKDIR/ PC $>tar --strip-components=1 -xf SOURCES-stm32mp-openstlinux-6.6-yocto-scarthgap-mpu-v25.06.11.tar.gz -C $WORKDIR/ PC $>tar --strip-components=1 -xf
Set-up a dedicated EXTDT_DIR variable to access the device tree source file
PC $>pushd $WORKDIR/MyDeviceTree_fromCubeMX
PC $>export EXTDT_DIR="$PWD"
PC $>popd
Set-up a dedicated FWDDR_DIR variable to access the DDR firmware source file
PC $>pushd $WORKDIR/sources/ostl-linux/stm32mp-ddr-phy-*
PC $>export FWDDR_DIR="$PWD"
PC $>popd
Set-up a dedicated FIP_DEPLOYDIR_ROOT variable to store all build output artifacts to generate FIP binaries.
FIP_artifacts PC $>pushd $WORKDIR/FIP_artifacts PC $>export FIP_DEPLOYDIR_ROOT=$PWD PC $>popdPC $>mkdir -p $WORKDIR/
Then proceed with the STM32MPU_Developer_Package#Installing_the_SDK chapter.
The commands described in the rest of the document must be run in an SDK environment context: (STM32MPU_Developer_Package#Starting_up_the_SDK).
5. Updating the kernel device tree[edit | edit source]
![]() |
The procedure below is an extract of the README.HOW_TO.txt.stm32mp1 file which is available in $WORKDIR/sources/ostl-linux/linux-stm32mp-*. Note: the "README.HOW_TO.txt.<board flavor>" file contains some useful grep "$> commands that are needed to build the artifact of kernel. |
- unpack and patch sources
PC $>pushd $WORKDIR
PC $>mkdir -p kernel
PC $>tar xf sources/ostl-linux/linux-stm32mp-*/linux-*.tar.xz -C kernel
PC $>mv kernel/linux-* kernel/kernel-sources/
PC $>pushd kernel/kernel-sources/
PC $>for p in $(ls -1 ../../sources/ostl-linux/linux-stm32mp-*/*.patch); do patch -p1 < $p; done
PC $>popd
PC $>popd
- regenerate the kernel DTB
For our example:
multi_v7_defconfig fragment*.config PC $>for f in `ls -1 ../../sources/ostl-linux/linux-stm32mp-*/fragment*.config`; do scripts/kconfig/merge_config.sh -m -r -O ${OUTPUT_BUILD_DIR} ${OUTPUT_BUILD_DIR}/.config $f; done PC $>(yes "" || true ) | make oldconfig O="${OUTPUT_BUILD_DIR}" PC $>make O="${OUTPUT_BUILD_DIR}" KBUILD_EXTDTS="${EXTDT_DIR}/CA7/DeviceTree/MY_DEMO/linux" stm32mp135f-my_demo-mx.dtb PC $>popd PC $>ls -l ${OUTPUT_BUILD_DIR}/arch/${ARCH}/boot/dts/stm32mp135f-my_demo-mx.dtbPC $>pushd $WORKDIR/kernel/kernel-sources PC $>export OUTPUT_BUILD_DIR=$PWD/../build PC $>mkdir -p ${OUTPUT_BUILD_DIR} PC $>make O="${OUTPUT_BUILD_DIR}"
For other examples (STM32MP1 series or STM32MP2 series):
Please replace green words with cell content:
6. Updating BOOT firmware[edit | edit source]
6.1. Updating the TF-A device tree[edit | edit source]
![]() |
The procedure below is an extract of the README.HOW_TO.txt.stm32mp1 file which is available in $WORKDIR/sources/ostl-linux/tf-a-stm32mp-*. Note: the "README.HOW_TO.txt.<board flavor>" file contains some useful grep "$> commands that are needed to build the artifact of tf-a. |
- unpack and patch sources
PC $>pushd $WORKDIR
PC $>pushd sources/ostl-linux/tf-a-stm32mp-v[0-9]*
PC $>mkdir -p tf-a-sources
PC $>tar xf tf-a-stm32mp-v[0-9]*.tar.* --one-top-level=tf-a-sources --strip-components=1
PC $>pushd tf-a-sources
PC $>for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
PC $>popd
PC $>popd
- regenerate TF-A
For our example:
CA7/DeviceTree/MY_DEMO/tf-a PC $>export EXTDT_DIR_TF_A_SERIAL=CA7/DeviceTree/MY_DEMO/tf-a PC $>make -f ../Makefile.sdk.stm32mp1 DEPLOYDIR=${FIP_DEPLOYDIR_ROOT}/arm-trusted-firmware TF_A_DEVICETREE=stm32mp135f-my_demo-mx TF_A_CONFIG="optee-sdcard optee-programmer-usb" stm32 PC $>popdPC $>pushd $WORKDIR/sources/ostl-linux/tf-a-stm32mp-v[0-9]*/tf-a-sources PC $>export EXTDT_DIR_TF_A=
For other examples (STM32MP1 series or STM32MP2 series):
Please replace green words with cell content:
6.2. Updating the OP-TEE device tree[edit | edit source]
![]() |
The procedure below is an extract of the README.HOW_TO.txt.stm32mp1 file which is available in $WORKDIR/sources/ostl-linux/optee-os-stm32mp-*. Note: the "README.HOW_TO.txt.<board flavor>" file contains some useful grep "$> commands that are needed to build the artifact of OP-TEE. |
- unpack and patch sources
PC $>pushd $WORKDIR
PC $>pushd sources/ostl-linux/optee-os-stm32mp-[0-9]*
PC $>tar xf optee-os-stm32mp-[0-9]*.tar.* --one-top-level=optee-os-sources --strip-components=1
PC $>pushd optee-os-sources
PC $>tar xfz ../fonts.tar.gz
PC $>for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
PC $>popd
PC $>popd
- regenerate OP-TEE binaries
For our example:
CA7/DeviceTree/MY_DEMO/optee-os PC $>export EXTDT_DIR_OPTEE_SERIAL=CA7/DeviceTree/MY_DEMO/optee-os PC $>make -f ../Makefile.sdk.stm32mp1 DEPLOYDIR=${FIP_DEPLOYDIR_ROOT}/optee CFG_EMBED_DTB_SOURCE_FILE=stm32mp135f-my_demo-mx.dtb OPTEE_CONFIG="optee-sdcard optee-programmer-usb" optee PC $>popdPC $>pushd $WORKDIR/sources/ostl-linux/optee-os-stm32mp-[0-9]*/optee-os-sources PC $>export EXTDT_DIR_OPTEE=
For other examples (STM32MP1 series or STM32MP2 series):
Please replace green words with cell content:
6.3. Updating the U-Boot device tree[edit | edit source]
![]() |
The procedure below is an extract of the README.HOW_TO.txt.stm32mp1 file which is available in $WORKDIR/sources/ostl-linux/u-boot-stm32mp-*. Note: the "README.HOW_TO.txt.<board flavor>" file contains some useful grep "$> commands that are needed to build the artifact of U-Boot. |
- unpack and patch sources
PC $>pushd $WORKDIR
PC $>pushd sources/ostl-linux/u-boot-stm32mp-v[0-9]*
PC $>tar xf u-boot-stm32mp-v[0-9]*.tar.* --one-top-level=u-boot-sources --strip-components=1
PC $>pushd u-boot-sources
PC $>for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
PC $>popd
PC $>popd
- regenerate U-Boot binaries
For our example:
CA7/DeviceTree/MY_DEMO/u-boot PC $>export EXTDT_DIR_UBOOT_SERIAL=CA7/DeviceTree/MY_DEMO/u-boot PC $>make -f ../Makefile.sdk.stm32mp1 DEPLOYDIR=${FIP_DEPLOYDIR_ROOT}/u-boot UBOOT_DEFCONFIG_default=stm32mp13_defconfig UBOOT_DEFCONFIG_programmer=stm32mp13_defconfig DEVICE_TREE=stm32mp135f-my_demo-mx uboot PC $>popdPC $>pushd $WORKDIR/sources/ostl-linux/u-boot-stm32mp-v[0-9]*/u-boot-sources PC $>export EXTDT_DIR_UBOOT=
For other examples (STM32MP1 series or STM32MP2 series):
Please replace green words with cell content:
6.4. Updating the FIP image[edit | edit source]
Once all BOOT binaries have been generated, the FIP image can be generated using the fiptool wrapper script available from any of the BOOT source code location:
- - $WORKDIR/sources/ostl-linux/tf-a-stm32mp-v[0-9]*/tf-a-sources
- or
- - $WORKDIR/sources/ostl-linux/optee-os-stm32mp-[0-9]*/optee-os-sources
- or
- - $WORKDIR/sources/ostl-linux/u-boot-stm32mp-v[0-9]*/u-boot-sources
For our example:
FIP_CONFIG="optee-sdcard optee-programmer-usb" PC $>export FIP_DEVICETREE=stm32mp135f-my_demo-mx PC $>../fiptool-stm32mp.stm32mp1 PC $>popdPC $>pushd $WORKDIR/sources/ostl-linux/u-boot-stm32mp-v[0-9]*/u-boot-sources PC $>export
For other examples (STM32MP1 series or STM32MP2 series):
Please replace green words with cell content:
7. Update target board[edit | edit source]
7.1. Copy new boot chain firmware into the target[edit | edit source]
The STM32CubeProgrammer is used to populate the new boot chain firmware to the target storage.
For our example:
The binaries needed to program the microSD card from target board with STM32CubeProgrammer are:
FIP_DEPLOYDIR_ROOT}/arm-trusted-firmware/tf-a-stm32mp135f-my_demo-mx-optee-programmer-usb.stm32 (fsbl-boot partition) - ${FIP_DEPLOYDIR_ROOT}/fip/fip-stm32mp135f-my_demo-mx-optee-programmer-usb.bin (fip-boot partition)- ${
The binaries to use to populate microSD card partitions are:
FIP_DEPLOYDIR_ROOT}/arm-trusted-firmware/tf-a-stm32mp135f-my_demo-mx-optee-sdcard.stm32 (fsbl1 and fsbl2 partitions) - ${FIP_DEPLOYDIR_ROOT}/fip/fip-stm32mp135f-my_demo-mx-optee-sdcard.bin (fip-a partition)- ${
For other examples (STM32MP1 series or STM32MP2 series):
Please replace green words with cell content:
![]() |
Note according to what have been modified in device tree files, it might be needed to reset the u-boot-env partition. |
7.2. Copy the new DTB into bootfs partition[edit | edit source]
There are two methods to update the bootfs partition with new kernel DTB on target.
7.2.1. Option 1: On an up and running target[edit | edit source]
For this method, the board IP address (<Target_IP>) is needed
For our example:
stm32mp135f-my_demo-mx.dtb root@<Target_IP>:/boot/PC $>scp ${OUTPUT_BUILD_DIR}/arch/${ARCH}/boot/dts/
For other examples (STM32MP1 series or STM32MP2 series):
Please replace green words with cell content:
![]() |
The new DTB will be taken into account on the next reboot of the target. |
7.2.2. Option 2: Directly into bootfs image[edit | edit source]
With this method, the original bootfs partition image file is updated through a loopback mount on local host. This utility is available within any Linux Distribution (even through WSL2)/
For our example:
stm32mp1.ext4 $WORKDIR/bootfs PC $>cp -f ${OUTPUT_BUILD_DIR}/arch/${ARCH}/boot/dts/stm32mp135f-my_demo-mx.dtb $WORKDIR/bootfs PC $>umount $WORKDIR/bootfs PC $>syncPC $>mkdir -p $WORKDIR/bootfs PC $>mount -o loop st-image-bootfs-openstlinux-weston-
For other examples (STM32MP1 series or STM32MP2 series):
Please replace green words with cell content:
Then use STM32CubeProgrammer to update the bootfs partition on target with the updated ext4 image.