9 Device tree generation (STM32MPUs only) ¶
Device tree generation (STM32MPUs only)
9 Device tree generation (STM32MPUs only) ¶
The Device tree in Linux is used to provide a way to describe non-discoverable hardware. STMicroelectronics is widely using the device tree for all the platform configuration data, including DDR configuration.
Linux developers can manually edit device tree source files (dts), but as an alternative STM32CubeMX offers a partial device-tree generation service to reduce effort and to ease new comers. STM32CubeMX intends to generate partially device trees corresponding to board level configuration. Partial means that the entire (board level) device-trees are not generated, but only main sections that usually imply huge efforts and can cause compilation errors and dysfunction:
folders structure and files to folders distribution
dtsi and headers inclusions
pinCtrl and clocks generation
System-On-Chip device nodes positioning
multi-core related configurations (Etzpc binding, resources manager binding, peripherals assignment)
9.1 Device tree overview ¶
To run properly, any piece of software needs to get the hardware description of the platform on which it is executed, including the kind of CPU, the memory size and the pin configuration. OpenSTLinux firmware has put such non-discoverable hardware description in a separate binary, the device tree blob (dtb). The device tree blob is compiled from the device tree source files (dts) using the dtc compiler provided with the OpenSTLinux distribution.
The device tree structure consist of a board level file (.dts) that includes two device tree source include files (.dtsi): a soc level file and a –pinctrl file, that lists the pin muxing configurations.
The device tree structure is very close to C language multiple level structures with the “root” (/) being the highest level then “peripherals” being sub-nodes described further in the hierarchy (see figures 584, 585 and 586).
STM32CubeMX generation uses widely overloading mechanisms to complete or change some SOC devices definitions when user configurations require it.
Device tree generation (STM32MPUs only) ¶
Figure 584. STM32CubeMX generated DTS – Extract 1
Figure 586. STM32CubeMX generated DTS – Extract 3 ¶
9.2 STM32CubeMX Device tree generation ¶
For STM32MPUs, STM32CubeMX code generation feature has been extended to generate Device trees (DT) configuring the firmware.
DTS generation is accessible through the same button.
Device tree generation (STM32MPUs only) ¶
The DT generation path can be configured from the Project Manager view, in the Advanced
Settings tab, under OpenSTLinux Settings (see Figure 587). For each Device tree STM32CubeMX generates Device tree source (DTS) files.
Figure 587. Project settings to configure Device tree path ¶
a complete clock-tree
a complete pin control
a complete multi-cores references definition
a set of device nodes and sub-nodes
user sections that can be filled to have complete and bootable Device trees (contents are not lost at next generation).
The generated DTS files reflect the user configuration, such as the assignment of peripherals to runtime contexts and boot loaders, or clock tree settings.
STM32CubeMX DT generation ensures the coherency between the different DTs.
Additionally, it generates the DDR configuration file as part of the boot loader Device trees.
These files, along with the files they include, are compiled to create the device tree blob for the targeted firmware.
The STM32CubeMX Device tree structure depends upon the targeted firmware and, in a few cases, upon the OpenSTLinux manifest version and/or the MPU family. The structures are detailed in https://wiki.st.com/stm32mpu/wiki/Category:Platform_configuration.