Change the device tree source directly on target board

This article illustrates how to extract the device tree source from a the device tree blob, make some changes and generate the new device tree blob using the Device Tree Compiler

Install the Device Tree Compiler on your board

sudo apt update
sudo apt install device-tree-compiler

In this example we will change the cmdline text passed to the Linux Kernel at startup. The example is on an Acqua board but it will works on any other Linux board.

Find the device tree blob file on the first microSD partition by typing:

ls -al /boot
-rwxr-xr-x  1 root root   36133 Oct  7 19:37 acme-acqua.dtb
-rwxr-xr-x  1 root root   17221 Oct  7 19:37 boot.bin
-rwxr-xr-x  1 root root 5441352 Oct  7 19:37 zImage

Make a copy of yout original acme-acqua.dtb file:

sudo cp /boot/acme-acqua.dtb /boot/acme-acqua.dtb.copy

Extract the device tree source by typing:

dtc -I dtb -O dts -o acme-acqua.dts /boot/acme-acqua.dtb

Find in the acme-acqua.dts file this line:

bootargs = "mem=256M console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait consoleblank=0";

Change for example the amount of RAM memory in this way:

bootargs = "mem=512 console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait consoleblank=0";

Compile the new source so generate the new device tree blob file:

dtc -I dts -O dtb -o acme-acqua.dtb acme-acqua.dts

and copy the new acme-acqua.dtb in in the first partition of microSD

sudo cp acme-acqua.dtb /boot

Reboot

sudo reboot

At prompt check the content of Kernel command line:

cat /proc/cmdline
mem=512M console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait consoleblank=0

Sergio Tanzilli
Systems designer, webmaster of www.acmesystems.it and founder of Acme Systems srl

Personal email: tanzilli@acmesystems.it
Web pages: https://www.acmesystems.it --- https://www.acmestudio.it
Github repositories: https://github.com/tanzilli --- https://github.com/acmesystems
Telegram group dedicated to the Acme Systems boards: https://t.me/acmesystemssrl