Last edited 2 years ago

STM32 MPU device tree: Difference between revisions

Registered User
mNo edit summary
Registered User
mNo edit summary
 
(26 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{ReviewsComments|-- [[User:Gerald Baeza|Gerald Baeza]] ([[User talk:Gerald Baeza|talk]]) 15:04, 4 November 2021 (CET)<br />To be updated for STM32MP13}}
{{ApplicableFor
|MPUs list=STM32MP13x, STM32MP15x
|MPUs checklist=STM32MP13x, STM32MP15x
}}
This article describes how the [[Device tree|device tree]] files for STM32MPU are organized for Linux<sup>&reg;</sup>, U-Boot and TF-A but also how they are organized when they are generated from STM32CubeMX.
__TOC__
== Purpose and scope ==
== Purpose and scope ==
This article shows the structure of the device tree files as it is implemented in STM32MP15 for the following software components: [[STM32 MPU Linux kernel overview|Linux<sup>&reg;</sup> kernel]], [[U-Boot overview|U-Boot]], [[TF-A overview|TF-A]] and [[OP-TEE overview|OP-TEE]].
This article shows the structure of the device tree files as it is implemented in OpenSTLinux for [[STM32 MPU Linux kernel overview|Linux<sup>&reg;</sup> kernel]], [[U-Boot overview|U-Boot]], [[TF-A overview|TF-A]] and [[OP-TEE overview|OP-TEE]].


The purpose of this article is not to explain the [[Device tree|device tree]] concept and the [[:Category:Device tree configuration|device tree configuration]] supported by STM32MP15. A good knowledge of the concept is a prerequisite before reading this article. The articles regarding the configuration can be read afterwards.
The purpose of this article is not to explain the [[Device tree|device tree]] concept and the [[:Category:Device tree configuration|device tree configuration]] supported by {{MicroprocessorDevice | device=1}}. A good knowledge of the concept is a prerequisite before reading this article. The articles regarding the configuration can be read afterwards.


== Device tree structure for Linux, U-Boot, TF-A and OP-TEE ==
== Device tree structure==
=== STMicroelectronics software delivery ===
The device tree files are used during [[Boot chain overview|boot time]] by the FSBL (TF-A), the secure OS (OP-TEE), the SSBL (U-Boot) and, at run time, by the Linux kernel. <br />
The device tree files are used during [[Boot chain overview|boot time]] by the FSBL (TF-A), the secure OS (OP-TEE), the SSBL (U-Boot) and eventually by the Linux kernel. <br />


These files are stored in different github repositories (one for each first level bullet below), but source code reuse is maximized from one repository to another:
These files are stored in different github repositories (one for each first level bullet below), but source code reuse is maximized from one repository to another:
* The initial device tree files supporting STM32MP15 are created in the '''Linux''' kernel.
* The initial device tree files supporting {{MicroprocessorDevice | device=1}} are created in the '''Linux''' kernel.
** The source code path is {{CodeSource | Linux kernel | arch/arm/boot/dts/ | arch/arm/boot/dts/stm32mp15*}}.
** The source code path is {{CodeSource | Linux kernel | arch/arm/boot/dts/ | arch/arm/boot/dts/stm32mp1*}}.
* In '''U-Boot''', Linux files are copied and overloaded with U-Boot properties (including DDR configuration).
* In '''U-Boot''', Linux files are copied and overloaded with U-Boot properties.
** The source code path is {{CodeSource | U-Boot | arch/arm/dts/ | arch/arm/dts/stm32mp15*}}.
** The source code path is {{CodeSource | U-Boot | arch/arm/dts/ | arch/arm/dts/stm32mp1*}}.
** The U-Boot add-ons file, "<dts-file-name>-u-boot.dtsi", is automatically included at the end of "<dts-file-name>.dts" during device tree compilation (this is a generic U-Boot Makefile behavior).
** The U-Boot add-ons file, "<dts-file-name>-u-boot.dtsi", is automatically included at the end of "<board>.dts" during device tree compilation: this is a generic U-Boot Makefile behavior, see {{CodeSource | U-Boot | tools/binman/binman.rst | binman.rst}}.
* In '''TF-A''', Linux files are partly copied (for device tree blob size optimization), completed with the security configuration (firewalling) and the DDR configuration (same files as U-Boot). {{CodeSource | TF-A | docs/devicetree/bindings/ | TF-A device tree bindings}} reading is needed to understand which parts of the Linux device tree must be kept or can be deleted during the partial copy.
* In '''TF-A''', Linux files are copied, completed with the security configuration (firewalling) and the DDR configuration. TF-A BL2 is applying some 'delete-property' on useless nodes, to lighten the final dtb file.
** The source code path is {{CodeSource | TF-A | fdts/ | fdts/stm32mp15*}}.
** The source code path is {{CodeSource | TF-A | fdts/ | fdts/stm32mp1*}}.
* In '''OP-TEE''', TF-A files are reused, except the DDR configuration ones.
* In '''OP-TEE''', Linux files are reused.
** The source code path is {{CodeSource | OP-TEE_OS | core/arch/arm/dts/ | core/arch/arm/dts/stm32mp15*}}.
** The source code path is {{CodeSource | OP-TEE_OS | core/arch/arm/dts/ | core/arch/arm/dts/stm32mp1*}}.
The figure below shows the device tree creation flow for Linux, U-Boot, TF-A and OP-TEE:
The figure below shows the device tree files structure for Linux, U-Boot, TF-A and OP-TEE:
[[File:Device_tree_for_Linux_U-Boot_TF-A_OP-TEE.png|center|link=]]
[[File:Device_tree_for_Linux_U-Boot_TF-A_OP-TEE.png|center|link=]]
Color legend:
{{Info|
* <span style="color:#FFFFFF; background:{{STDarkBlue}};">&nbsp;Linux&nbsp;</span> in dark blue
* The '''board''' level device tree file completes and/or overloads the default peripherals nodes configuration, defined in the included '''SoC''' dtsi file.
* <span style="color:#FFFFFF; background:{{STLightGreen}};">&nbsp;U-Boot&nbsp;</span> add-ons in green
* The above figure reflects the current implementation on github and may be somehow in advance compare to the upstreamed version for all parts that are still under review.
* <span style="color:#FFFFFF; background:{{STPink}};">&nbsp;DDR configuration&nbsp;</span> for TF-A and U-Boot in pink
* For the sake of simplicity, the figure only shows the '''dtsi''' & '''dts''' '''files''' structure, without showing the '''h files''' that are also included.
* <span style="color:#FFFFFF; background:{{STLightBlue}};">&nbsp;STM32CubeMX generated parts&nbsp;</span> in light blue (not used above but visible in [[#STM32CubeMX_generated_device_tree|STM32CubeMX]] section down in this article)
* The '''dtb files''', resulting from the compilation with the dtc compiler, may be named differently when the compilation is launched with the [[Which STM32MPU Embedded Software Package better suits your needs|Distribution Package]].}}
* The '''hashed''' areas on Linux device tree files represent the fact that these files are modified, so partly copied and updated
The above color codes are used for all the figures included in this article.


=== Upstreamed device tree ===
== STM32CubeMX generated device tree ==
==== Overview ====
[[STM32CubeMX]] can help to '''generate''' the device tree files for a given project, for the various software components:
As explained in the STM32 MPU Embedded Software [[STM32MPU_Embedded_Software_architecture_overview#Open_Source_Software_(OSS)_philosophy| Open Source Software (OSS) philosophy]], STMicroelectronics maximizes the usage of open source software and the upstreaming to the communities.
* '''TF-A''': STM32CubeMX generates three files:
:* 'stm32mp15-mx.dtsi' is equivalent to 'stm32mp1*-<DDR type>.dtsi' in the diagram above, embedding DDR settings
:* 'stm32mp1*-<your_project_name>-mx.dts' is the board device tree file, that includes all dtsi files (directly or not)
:* 'stm32mp1*-<your_project_name>-mx-fw-config.dts' file corresponds to the [[TF-A_BL2_overview#FCONF | TF-A firmware configuration]] and is out of the file structure shown in the previous paragraph
* '''U-Boot''':
:* 'stm32mp1*-<your_project_name>-mx.dts' is the board device tree file, that includes all dtsi files (directly or not)
:* 'stm32mp1*-<your_project_name>-mx-u-boot.dts' is equivalent to the '<board>-u-boot.dtsi' file in the diagram above
* '''Linux''':
:* 'stm32mp1*-<your_project_name>-mx.dts' is the board device tree file, that includes all dtsi files (directly or not)
* '''OP-TEE''':
:* 'stm32mp1*-<your_project_name>-mx.dts' is the board device tree file, that includes all dtsi files (directly or not)


So, the device tree files supporting the [[STM32MP157x-EV1 - hardware description|evaluation board]] and the [[STM32MP157x-DKx - hardware description|discovery kit]] are '''upstreamed''' to their official respective repositories. But waiting for the upstream process completion, STMicroelectronics latest contributions are available in advance on github in {{CodeSource | Linux kernel | arch/arm/boot/dts/ | Linux}}, {{CodeSource | U-Boot | arch/arm/dts/ | U-Boot}}, {{CodeSource | TF-A | fdts/ | TF-A}} and {{CodeSource | OP-TEE_OS | core/arch/arm/dts/ | OP-TEE}} repositories.
{{Info|The figures shown below are reflecting the '''current implementation on github''' and they may be somehow in advance compare to the '''upstreamed''' version for all parts that are still under review.}}
{{Info|For the sake of simplicity, the figures below only show the '''dtsi''' & '''dts''' '''files''' structure, without showing the '''h files''' that are also included.}}
{{Info|The '''dtb files''', resulting from the compilation with the dtc compiler, may be named differently when the compilation is launched with the [[Which STM32MPU Embedded Software Package better suits your needs|Distribution Package]].}}
==== Linux ====
{{ReviewsComments|-- [[User:Gerald Baeza|Gerald Baeza]] ([[User talk:Gerald Baeza|talk]]) 11:44, 4 November 2021 (CET)<br />"SOC" to be renamed into something else, to be defined by Alex and Lionel}}
[[File:Device tree Linux upstreamed.png|center|link=]]
[[File:Device tree legend.png|center|link=]]<br />
==== U-Boot ====
[[File:Device tree U-Boot upstreamed.png|center|link=]]
[[File:Device tree legend.png|center|link=]]<br />
{{Info|'<board>-u-boot.dtsi' file inclusion at the end of '<board>.dts' file is not explicit (#include ...) but realized via an U-Boot generic mechanism (see {{CodeSource | U-Boot | tools/binman/README | README}})}}
==== TF-A ====
[[File:Device tree TF-A upstreamed.png|center|link=]]
[[File:Device tree legend.png|center|link=]]<br />
Note: The hashed areas on Linux device tree files represent the fact that these files are modified in TF-A.
==== OP-TEE ====
[[File:Device tree OP-TEE upstreamed.png|center|link=]]
[[File:Device tree legend.png|center|link=]]<br />
Note: The hashed areas on Linux device tree files represent the fact that these files are modified in OP-TEE.<br />
=== STM32CubeMX generated device tree ===
==== Overview ====
[[STM32CubeMX]] can be used to '''generate''' the device tree files for a given project. The tool generates the files <span style="color:#FFFFFF; background:{{STLightBlue}};">&nbsp;highlighted in light blue&nbsp;</span> in the following diagrams, including the upstreamed files shown in the previous chapter.<br />
<br />
The device tree files generated by STM32CubeMX can be '''built''' with the [[Which STM32MPU Embedded Software Package better suits your needs#Developer Package|Developer Package]] or [[Which STM32MPU Embedded Software Package better suits your needs#Distribution_Package|Distribution Package]]:
The device tree files generated by STM32CubeMX can be '''built''' with the [[Which STM32MPU Embedded Software Package better suits your needs#Developer Package|Developer Package]] or [[Which STM32MPU Embedded Software Package better suits your needs#Distribution_Package|Distribution Package]]:
* Use the '''Developer Package''' to store the STM32CubeMX-generated files in the folder of your choice. Then, manually copy or link them into Linux, U-Boot and TF-A device tree folders (see [[#Introduction|introduction]]). Do not forget to add your device tree file name in '''../Makefile.sdk''' (for [[STM32MP1 Developer Package - TF-A|TF-A SDK]] and [[STM32MP1 Developer Package - U-Boot|U-Boot SDK]]) and in '''arch/arm/boot/dts/Makefile''' (for [[STM32MP1 Developer Package - Linux kernel|Linux kernel SDK]]), before compiling them as expalined in [[How to cross-compile with the Developer Package]].
* Use the '''Developer Package''' to store the STM32CubeMX-generated files in the folder of your choice. Then, manually copy or link them into Linux, U-Boot and TF-A device tree folders (see [[#Device tree structure|Device tree structure]]). Do not forget to add your device tree file name in '''../Makefile.sdk''' (for TF-A SDK and U-Boot SDK) and in '''arch/arm/boot/dts/Makefile''' (for Linux kernel SDK), before compiling them as explained in [[How to cross-compile with the Developer Package]].
* Use the '''Distribution Package''' to store the STM32CubeMX-generated files in '''meta-st/meta-st-stm32mp-addons/mx''', as explained in the [[How to create your own machine]] article. This article also describes how to build the complete image. Examples of Linux (device tree), U-Boot and TF-A individual compiling can be found in the [[How to cross-compile with the Distribution Package]] article.
* Use the '''Distribution Package''' to store the STM32CubeMX-generated files in '''meta-st/meta-st-stm32mp-addons/mx''', as explained in the [[How to create your own machine]] article. This article also describes how to build the complete image. Examples of Linux (device tree), U-Boot and TF-A individual compiling can be found in the [[How to cross-compile with the Distribution Package]] article.
==== Linux ====
[[File:Device tree Linux STM32CubeMX.png|center|link=]]<br />
==== U-Boot ====
[[File:Device tree U-Boot STM32CubeMX.png|center|link=]]<br />
==== TF-A ====
[[File:Device tree TF-A STM32CubeMX.png|center|link=]]<br />
==== OP-TEE ====
STM32CubeMX does not generate any device tree source files dedicated to OP-TEE, but these can be derived from the device tree source files generated for TF-A. In {{CodeSource | OP-TEE_OS | / | OP-TEE github release}}, OP-TEE files are the very TF-A source files with the DDR dtsi files removed since fully unused. However, one can copy TF-A device tree source files stm32mp15* to {{CodeSource | OP-TEE_OS | core/arch/arm/dts/ | OP-TEE dts/}}&nbsp; source directory and build OP-TEE with.


<noinclude>
<noinclude>

Latest revision as of 18:30, 31 January 2023

Applicable for STM32MP13x lines, STM32MP15x lines

This article describes how the device tree files for STM32MPU are organized for Linux®, U-Boot and TF-A but also how they are organized when they are generated from STM32CubeMX.

1. Purpose and scope[edit source]

This article shows the structure of the device tree files as it is implemented in OpenSTLinux for Linux® kernel, U-Boot, TF-A and OP-TEE.

The purpose of this article is not to explain the device tree concept and the device tree configuration supported by STM32MP1 Series. A good knowledge of the concept is a prerequisite before reading this article. The articles regarding the configuration can be read afterwards.

2. Device tree structure[edit source]

The device tree files are used during boot time by the FSBL (TF-A), the secure OS (OP-TEE), the SSBL (U-Boot) and, at run time, by the Linux kernel.

These files are stored in different github repositories (one for each first level bullet below), but source code reuse is maximized from one repository to another:

  • The initial device tree files supporting STM32MP1 Series are created in the Linux kernel.
  • In U-Boot, Linux files are copied and overloaded with U-Boot properties.
    • The source code path is arch/arm/dts/stm32mp1* .
    • The U-Boot add-ons file, "<dts-file-name>-u-boot.dtsi", is automatically included at the end of "<board>.dts" during device tree compilation: this is a generic U-Boot Makefile behavior, see binman.rst .
  • In TF-A, Linux files are copied, completed with the security configuration (firewalling) and the DDR configuration. TF-A BL2 is applying some 'delete-property' on useless nodes, to lighten the final dtb file.
  • In OP-TEE, Linux files are reused.

The figure below shows the device tree files structure for Linux, U-Boot, TF-A and OP-TEE:

Device tree for Linux U-Boot TF-A OP-TEE.png
Info white.png Information
  • The board level device tree file completes and/or overloads the default peripherals nodes configuration, defined in the included SoC dtsi file.
  • The above figure reflects the current implementation on github and may be somehow in advance compare to the upstreamed version for all parts that are still under review.
  • For the sake of simplicity, the figure only shows the dtsi & dts files structure, without showing the h files that are also included.
  • The dtb files, resulting from the compilation with the dtc compiler, may be named differently when the compilation is launched with the Distribution Package.

3. STM32CubeMX generated device tree[edit source]

STM32CubeMX can help to generate the device tree files for a given project, for the various software components:

  • TF-A: STM32CubeMX generates three files:
  • 'stm32mp15-mx.dtsi' is equivalent to 'stm32mp1*-<DDR type>.dtsi' in the diagram above, embedding DDR settings
  • 'stm32mp1*-<your_project_name>-mx.dts' is the board device tree file, that includes all dtsi files (directly or not)
  • 'stm32mp1*-<your_project_name>-mx-fw-config.dts' file corresponds to the TF-A firmware configuration and is out of the file structure shown in the previous paragraph
  • U-Boot:
  • 'stm32mp1*-<your_project_name>-mx.dts' is the board device tree file, that includes all dtsi files (directly or not)
  • 'stm32mp1*-<your_project_name>-mx-u-boot.dts' is equivalent to the '<board>-u-boot.dtsi' file in the diagram above
  • Linux:
  • 'stm32mp1*-<your_project_name>-mx.dts' is the board device tree file, that includes all dtsi files (directly or not)
  • OP-TEE:
  • 'stm32mp1*-<your_project_name>-mx.dts' is the board device tree file, that includes all dtsi files (directly or not)

The device tree files generated by STM32CubeMX can be built with the Developer Package or Distribution Package:

  • Use the Developer Package to store the STM32CubeMX-generated files in the folder of your choice. Then, manually copy or link them into Linux, U-Boot and TF-A device tree folders (see Device tree structure). Do not forget to add your device tree file name in ../Makefile.sdk (for TF-A SDK and U-Boot SDK) and in arch/arm/boot/dts/Makefile (for Linux kernel SDK), before compiling them as explained in How to cross-compile with the Developer Package.
  • Use the Distribution Package to store the STM32CubeMX-generated files in meta-st/meta-st-stm32mp-addons/mx, as explained in the How to create your own machine article. This article also describes how to build the complete image. Examples of Linux (device tree), U-Boot and TF-A individual compiling can be found in the How to cross-compile with the Distribution Package article.