STM32MP15 device tree

来自百问网嵌入式Linux wiki

Purpose and scope

This article shows the structure of the device tree files as it is implemented in STM32MP15 for the following software components: Linux® kernel, U-Boot and TF-A.

The purpose of this article is not to explain the device tree concept and the 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.

Device tree structure for Linux, U-Boot and TF-A

Introduction

The device tree files are used during boot time by the FSBL (TF-A / U-Boot SPL), the SSBL (U-Boot), and eventually by the Linux kernel.
These files are stored in different repositories, but source code reuse is maximized from one repository to another:


The figure below shows the device tree creation flow for Linux, U-Boot and TF-A:

Color legend:

  •  Linux  in dark blue
  •  U-Boot  in green
  •  TF-A  in pink
  •  STM32CubeMX generated parts  in light blue

The above color codes are used for all the figures included in this article.

Upstreamed device tree

Overview

As explained in the STM32 MPU Embedded Software Open Source Software (OSS) philosophy, STMicroelectronics maximizes the usage of open source software and the upstreaming to the communities.

As a result, the device tree files supporting the evaluation board and the Discovery kit are upstreamed to arch/arm/boot/dts/ | |}} Linux , arch/arm/dts/ | |}} U-Boot and fdts/ | |}} TF-A repositories.

TF-A


Note: The hashed areas on Linux device tree files represent the fact that these files are partly copied in TF-A.
<securetransclude src="ProtectedTemplate:ReviewsComments" params="YGA: You don't mention the .h files in include/dt-bindings?"></securetransclude>{{#set:Has reviews comments=true}} <securetransclude src="ProtectedTemplate:ReviewsComments" params="YGA: When compiling TF-A (outside yocto) the dtb files are stm32mp157c-ev1.dtb and so on. I don't know if that should be changed in the image?"></securetransclude>{{#set:Has reviews comments=true}}

Manual customization of STM32MP15 reference device tree

As explained in the above sections, the current device tree structure is based on STM32MP157C configuration, so one could wonder how to proceed for another STM32MP15 part number (see STM32MP15 microprocessor diversity for details).
Below guidelines on how to customize the device tree for another STM32MP15 MPU device.

Generic setup

This first step enables to boot with any STM32MP15 MPU. Warning or error messages are displayed on the console without any consequences with the boot success.

Include "stm32mp157c.dtsi", whatever your device part number

This is the superset of device tree declaration corresponding to the largest set of STM32MP15 microprocessor features.

Include the pinctrl reference file corresponding to your package size (a, b, c or d)
  • stm32mp157caa-pinctrl.dtsi for 18x18 package
  • stm32mp157cab-pinctrl.dtsi for 16x16 package
  • stm32mp157cac-pinctrl.dtsi for 14x14 package
  • stm32mp157cad-pinctrl.dtsi for 12x12 package

Clean up your configuration

Customize your "stm32mp157c.dtsi" file to remove all the configurations that are not relevant for your STM32MP15 part number

For example, remove cpu1 core if it is not relevant.

All the peripherals available on STM32MP15 MPU devices are configured but not activated, so no need to remove any of them in stm32mp157c.dtsi.

Activate only the peripherals available on your STM32MP15 part number on your board

For example:

  • Activate the peripherals linked to security and cryptography on secure microprocessors (STM32MP157D).
  • Activate FDCAN on STM32MP153x, and DSI and GPU on STM32MP157x.

STM32CubeMX generated device tree

Overview

STM32CubeMX can be used to generate the device tree files for a given project. The tool generates the files  highlighted in light blue  in the following diagrams, including the upstreamed files shown in the previous chapter.

<securetransclude src="ProtectedTemplate:ReviewsComments" params="CMO w845.1, during latest discussion/meeting with SVA/CubeMX team, we keep ProjectName in the name of dts file"></securetransclude>{{#set:Has reviews comments=true}}

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 introduction). 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 expalined in 如何将开发人员包交叉编译.
  • Use the Distribution Package to store the STM32CubeMX-generated files in meta-st/meta-st-stm32mp-addons/mx, as explained in the 如何创建自己的机器 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 如何将分发包交叉编译 article.

TF-A


<securetransclude src="ProtectedTemplate:PublicationRequestId" params="14960 | 2019-01-31 | Previous PR: 10415 (AnneJ)"></securetransclude>