How to patch Device Tree Blob in U-boot using Overlays

Last modified by Microchip on 2025/02/28 14:14

How it works

How to patch Device Tree Blob in U-boot using Overlays

Starting from U-boot 2018.07 released in Linux4SAM6.0, we can use the feature of patching the Device Tree Blob (DTB) with additional Device Tree Overlays (DTBO).

Traditional way of kernel booting

So far, to boot kernel with zImage and normal DTB, we would use a command like this:</br>

fatload mmc 0:1 0x24000000 zImage; fatload mmc 0:1 0x21000000 board.dtb; bootz 0x24000000 - 0x21000000;

We can see the DTB is passed as the third argument to the command.

Loading overlays and applying them on top of the DTB

To apply the DTBO on top of the DTB, we need following commands:</br> This will load the original DTB.</br>

setenv fdtaddr 0x21000000;
fatload mmc 0:1 ${fdtaddr} board.dtb

This will load the DTBO into memory</br>

setenv fdtovaddr 0x23000000;
fatload mmc 0:1 ${fdtovaddr} someoverlay.dtbo;

This will configure the address for fdt operations (we set it to the DRAM address where we loaded the base DTB)</br>

fdt addr ${fdtaddr}

This will resize the original DTB to accommodate more space for the overlay</br>

fdt resize 8192

This will apply the DTBO loaded at _fdtovaddr_ on top of the DTB at the address we configured with fdt addr </br>

fdt apply ${fdtovaddr}

This will boot the kernel with the DTB at _fdtaddr_ which now includes both the original DTB and the applied DTBO

bootz 0x24000000 - ${fdtaddr}

Related Topics

Boards

Sama5d29Curiosity
Sam9x75Curiosity
Sam9x60Curiosity
Sama7g5-ek
Sama5d2icp
Sam9x60EK
Sama5d27WLSom1EK
Sama5d27Som1EK
Sama5d2PtcEK
Sama5d2Xplained
Sama5d4Xplained

Components

U-Boot
Kernel

Summary

How to apply DTBOs in U-boot