11. Configuration files, device tree
11.1 Configuration files
The armsom board uses armbian to manage source code images. There is an armbianEnv.txt file in the boot directory of the file system. This file is mainly used to configure uboot and describe some key information during the startup process.
armbianEnv.txt
file provides a flexible way to adjust startup parameters without recompiling or modifying U-Boot.
## 11.1.1 The role of the armbianEnv.txt
file
- U-Boot environment variable configuration:
-
armbianEnv.txt
file allows users to define and modify U-Boot environment variables in a simple text format. These variables can control how to load the kernel, initialize the RAM disk, pass command line parameters, etc.
- Custom startup behavior:
- Users can customize the startup process by editing the
armbianEnv.txt
file. For example, specify different kernel images, device tree files, mount points for the root file system, etc.
- Easy debugging and development:
- For developers,
armbianEnv.txt
provides a convenient way to test different boot configurations without having to recompile U-Boot every time or enter a long list of boot commands directly in the U-Boot command line.
- Support multiple boot options:
- This file can also be used to configure multiple boot options, such as booting from an SD card, eMMC, or the network, allowing users to easily switch boot sources in different environments.
- Passing additional parameters to the kernel:
- In addition to the standard boot parameters,
armbianEnv.txt
also allows users to pass additional command line parameters to the kernel, which is very useful for specific hardware configurations or debugging purposes
We take the armbianEnv.txt of sige5 as an example to explain in detail the role of the parameters in this file:
armsom@armsom-sige5:/boot$ cat armbianEnv.txt
verbosity=1 // Set the output verbosity during the boot process. Setting this to 1 will print as much information as possible for easier debugging
bootlogo=true // Controls whether to display the boot logo at boot time. Here it is set to turn on the display logo
console=both // both means that the output will be sent to both the serial console (such as a terminal connected via the UART interface) and the HDMI or other video output device.
overlay_prefix=rk35xx // Used to specify the device tree file path associated with a specific SoC
fdtfile=rockchip/rk3576-armsom-sige5.dtb // Specify the device tree used by the current device as /boot/dtb/rockchip/rk3576-armsom-sige5.dtb
rootdev=UUID=24e6d1ad-085e-4c9b-9784-f33d6ca6d189 // Use UUID to uniquely identify the partition where the root file system is located, the most reliable way, UUID will not change with the order of the device
rootfstype=ext4 // Specify the file system type as ext4
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u // List the Vendor ID and Product ID (PID) of the USB storage device, u means enabling UAS (USB Attached SCSI Protocol)
11.2 Device Tree
11.2.1 What is Device Tree
The Linux kernel introduced the concept of device tree from 3.x. Its main function is to separate the modification of board peripherals from the kernel source code, improve the versatility of the kernel, and reduce the workload of kernel developers.
After using the device tree, a kernel image can adapt to many boards. Different boards only need to replace the device tree.
The device tree is used to describe the hardware resources of a hardware platform. This "device tree" can be passed to the kernel by the bootloader (uboot), and the kernel can obtain hardware information from the device tree. It is equivalent to using a customized device tree to operate different hardware resources, such as i2c, spi, mipi, mini-pcie, i2s and other interfaces, which can be configured and enabled through the device tree to operate them normally.
The device tree describes hardware resources in a "tree-like" structure. For example, the local bus is the "trunk" of the tree and is called the "root node" in the device tree. The spi bus mounted to the local bus is the "branch" of the tree and is called the "child node of the root node" in the device tree. There is more than one spi device under the spi bus, and these "branches" can be further divided.
11.2 Device tree used by armsom
11.2.1 Main device tree:
In the armsom board, each board has its own main device tree, located in /boot/dtb/rockchip, as shown below:
In the uboot stage, the sige5 board will parse the rk3576-armsom-sige5.dtb in the eMMC and load it into the ddr, and then jump to the kernel and use the device tree image content.
11.2.2 Device tree plug-in
11.2.2.1 What is a device tree plug-in
Linux4.4 introduced the dynamic device tree (Dynamic DeviceTree). Device Tree Overlay is an extension mechanism for the Device Tree. Device Tree is a data structure used to describe hardware devices. It is widely used in embedded systems, especially those based on the Linux kernel.
Device Tree Overlay allows the content of the device tree to be modified dynamically at runtime to add, modify, or delete device nodes and properties. It provides a flexible way to configure and manage hardware devices without recompiling the entire device tree. By using the device tree plugin, developers can make configuration changes to the hardware without restarting the system.
Device Tree Plugins are usually defined in a text format called Device Tree Source (DTS). The DTS file describes the structure and properties of the device tree, including device nodes, register addresses, interrupt information, etc. The device tree plugin can dynamically modify the device tree by loading and parsing the device tree file and merging it into the existing device tree.
11.2.2.2 How to use the device tree plugin
The device tree plugin is located in the file system under the path /boot/dtb/rockchip/overlay
To use the device tree plug-in, you need to modify the configuration file armbianEnv.txt
In 2.1, we can see that there are currently three device tree plug-ins related to sige5. If all of them are used, you need to write the following in the configuration file:
verbosity=1
bootlogo=true
console=both
overlay_prefix=rk35xx
fdtfile=rockchip/rk3576-armsom-sige5.dtb
rootdev=UUID=24e6d1ad-085e-4c9b-9784-f33d6ca6d189
rootfstype=ext4
usbstoragequirk s=0x2537:0x1066:u,0x2537:0x1068:u #overlay_start dtoverlay=/dtb/rockchip/overlay/armsom-sige5-display-10hd.dtbo dtoverlay=/dtb/rockchip/overlay/armsom-sige5-camera-ov13850-cs0.dtbo #dtoverlay=/dtb/rockchip/overlay/armsom-sige5-camera-ov13850-cs1.dtbo #overlay_end ``` * The way to open the device tree plug-in is to delete the comments of the corresponding device tree plug-in, that is, delete **‘#’**
* The way to close the device tree plug-in is to comment out the corresponding device tree plug-in, that is, add **‘#’** at the beginning of the line
* From the above configuration file, it can be seen that `display-10hd` `camera-ov13850-cs0` are not commented, so they are currently in the open state.
* `camera-ov13850-cs1` is commented out, so it is currently in the closed state.