FAQ: STM32MPUs: How to create a device tree adapted to your design with STM32CubeMX
1. Purpose
Create device tree files for each component: TF-A, OP-TEE, U-Boot, and the Linux kernel, adapted to the design.
From an STM32CubeMX project that uses the microprocessor unit (MPU) part number of the design, it is possible to create minimal device tree files from scratch and enrich them with the STM32MPx peripherals required by the application.
This article applies to the STM32MP1 and STM32MP2 series.
2. Device tree file node
For the driver of each peripheral that the application uses, the device tree file contains a corresponding node that provides the driver configuration parameters. For each peripheral, see the wiki article about the device tree node parameters in the link below.
ST Wiki: Device tree configuration
These articles provide links to the driver binding files (st.txt files), which give the exact meaning of the node parameters.
To create the device tree file that is adapted to the design, ST recommends using STM32CubeMX and these wiki articles about the device tree.
The device tree files that STM32CubeMX generates are incomplete for booting the component. The files cannot be used as is for correct boot operation. STM32CubeMX generates the device tree for GPIO pin multiplexing, RCC clock settings, DRAM configuration, and the hardware execution context for peripheral isolation. The tool does not generate all driver node parameters. These parameters must be added manually (see the next section)
3. Node parameters
The nodes parameter must be added manually under the User sections in the STM32CubeMX-generated device tree file. To identify the parameters that match the design, refer to the wiki device tree article examples and the driver binding files (st.txt). Examples are available in the device tree files for ST reference boards in the OpenSTLinux source files. The node parameters presented on the wiki page might not match the design. Select the parameters that match the printed circuit board (PCB), such as GPIOs, flash, DRAM, power supply tree, and USB.
4. Build minimal device tree for bring-up
This hands-on session show how to configure the device tree of the boot chain (TF-A,POP-TEE,U-Boot) and the Linux kernel on ST Reference board. This hands-on is an illustration. The same method as can be followed for a customer design that uses an STM32 microprocessor unit (MPU) system-on-chip (SoC) part number that differs from the ST reference board and that connects to different devices. The device tree is built with STM32CubeMX and with device tree files from the OpenSTLinux source files.
This hands-on session covers the STM32MP157-DK board, the STM32MP135-DK board, and the STM32MP257-EV1 board, and their associated device tree files.
The device tree node parameters that are used on ST reference boards might not suit the design. Some nodes are generic and system oriented and can be reused but others nodes can depend on the design. For example, if the design includes a level shifter on an SD card, some device tree properties of the SDMMC node must be modified compared with the ST board. As stated previously, these device tree properties are described in the SDMMC driver binding file. Examples of node parameter are available in the wiki device tree articles and in the device tree files of different ST reference boards.
See the hands-on session STM32MPUs_BringUp_Minimal-DeviceTree
Note: Use the STM32CubeMX version that comes with the ecosystem and the corresponding OpenSTLinux source code. Across ST ecosystem releases, the OpenSTLinux driver source code and device tree evolves, and STM32CubeMX depends on it. Therefore, when OpenSTLinux is upgraded from ecosystem X.x to X+1.x, the Linux kernel device tree file from ecosystem X.x cannot be reused directly with a Linux kernel from ecosystem X+1.x. Check each node property again to confirm that it remains the same as in ecosystem X.x. see FAQ:Updating-OpenSTLinux
Additional resources
- Information about getting started with the STM32MPx
FAQ: STM32MPUs How to bring up STM32MPUs
- Find further information about device tree HSE pin configuration depending on the choice of Crystal/resonator or Oscillator clock source https://wiki.st.com/stm32mpu/wiki/Clock_device_tree_configuration_-_Bootloader_specific#DT_configuration_for_HSE
- Please find further information about I2Cx configuration for PMIC I2Cx when you design does not use the default I2C4 in https://wiki.st.com/stm32mpu/wiki/How_to_create_your_board_device_tree#PMIC_configuration_via_I2C
