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

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:

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:
This will load the original DTB.

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

This will load the DTBO into memory
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)
fdt addr ${fdtaddr}

This will resize the original DTB to accommodate more space for the overlay
fdt resize 8192

This will apply the DTBO loaded at fdtovaddr on top of the DTB at the address we configured with fdt addr
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}

r10 - 09 Nov 2023 - 12:57:13 - AndreiSimion
 
Linux & Open Source for AT91 Microchip Microprocessors

Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.

Microchip® and others, are registered trademarks or trademarks of Microchip Technology Inc. and its subsidiaries. This site is powered by the TWiki collaboration platform

Arm® and others are registered trademarks or trademarks of Arm Limited (or its affiliates). Other terms and product names may be trademarks of others.

Ideas, requests, contributions ? Connect to LinksToCommunities page.

Syndicate this siteRSS ATOM