Device Tree Implementation Guide for ARM Devices
1. Core Concepts
Device Tree Source (DTS)
Device Tree Blob (DTB)
2. File System Structure
arch/arm64/boot/dts/
├── broadcom/
│ ├── bcm2711-rpi-4-b.dts # Pi 4 Model B DTS
│ ├── bcm2711-rpi-4-b.dtb # Pi 4 Model B DTB
│ ├── bcm2712-rpi-5-b.dts # Pi 5 Model B DTS
│ ├── bcm2712-rpi-5-b.dtb # Pi 5 Model B DTB
│ ├── bcm2711-rpi.dtsi # Shared Pi 4 definitions
│ └── bcm2712.dtsi # Shared Pi 5 definitions
├── overlays/ # Device Tree Overlays
├── northstar2/ # BCM490x router configs
└── stingray/ # BCM95852x switch configs
3. Implementation Process
3.1 Deployment Steps
File Installation bash
# For Raspberry Pi 5:
sudo cp arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb /boot/firmware
sudo cp arch/arm64/boot/Image /boot/firmware/kernel8.img
Boot ConfigurationCopy
# In /boot/firmware/config.txt
kernel=kernel8.img
device_tree=bcm2712-rpi-5-b.dtb
3.2 Dynamic Memory Configuration
/* Will be filled by the bootloader */
memory@0 {
device_type = "memory";
reg = <0 0 0x28000000>;
};
This placeholder in the DTS allows the bootloader to dynamically configure system memory. The actual values are filled in during the boot process based on the hardware configuration.
3.3 Boot Process Integration
Bootloader Phase
4. U-Boot DTB Usage
领英推荐
4.1 Hardware Configuration
U-Boot uses DTB to:
4.2 DTB Modification Capabilities
5. Technical Implementation
5.1 Key Source Files in linux kernel
Entry Point (/arch/arm64/kernel/head.S)
assembly
preserve_boot_args:
mov x21, x0 // x21=FDT
adr_l x0, boot_args // record the contents of
stp x21, x1, [x0] // x0 .. x3 at kernel entry
...
str_l x21, __fdt_pointer, x5 // Save FDT pointer
Architecture Setup (/arch/arm64/kernel/setup.c)
c
void __init __no_sanitize_address setup_arch(char **cmdline_p)
{
setup_machine_fdt(__fdt_pointer);
if (acpi_disabled)
unflatten_device_tree();
}
6. Raspberry Pi 5 Specific Configuration
This DTS file is the device tree source for the Raspberry Pi 5 Model B, which describes the hardware configuration of the board. Let me explain the key components:
6.1 Hardware Components
6.2 Interfaces
7. Boot Chain DTB Handling