u-boot runtime modify Linux device tree(dtb)

Showing results for 
Search instead for 
Did you mean: 

u-boot runtime modify Linux device tree(dtb)

100% helpful (1/1)

u-boot runtime modify Linux device tree(dtb)

In some cases, i.MX board connect to different module. It has very tiny changes, such as just one gpio different driver strength.

We can build an entire new software to handle this requirement.

Here we introduce another way, using u-boot to modify the device tree(dtb) at runtime.


Here is u-boot fdt command for 

How to use gpio-hog demo


run loadfdt

fdt addr ${fdt_addr_r}

fdt print /soc/bus/pinctrl/uart3grp
fdt rm /soc/bus/pinctrl/uart3grp

fdt print serial2

fdt set serial2 status disabled

fdt print serial2

fdt print gpio4

fdt resize

fdt mknode gpio4 gpio_hog_demo

fdt set gpio4/gpio_hog_demo gpio-hog
fdt set gpio4/gpio_hog_demo gpios <7 0>
fdt set gpio4/gpio_hog_demo output-high
fdt print gpio4

run mmcargs
run loadimage

booti ${loadaddr} - ${fdt_addr_r}

root@imx8mmevk:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/30200000.gpio, 30200000.gpio:
gpio-5 ( |PCIe DIS ) out hi
gpio-13 ( |ir-receiver ) in hi IRQ ACTIVE LOW
gpio-15 ( |cd ) in hi IRQ ACTIVE LOW

gpiochip1: GPIOs 32-63, parent: platform/30210000.gpio, 30210000.gpio:
gpio-38 ( |? ) out hi
gpio-42 ( |reset ) out lo ACTIVE LOW
gpio-51 ( |regulator-usdhc2 ) out lo

gpiochip2: GPIOs 64-95, parent: platform/30220000.gpio, 30220000.gpio:
gpio-80 ( |status ) out hi

gpiochip3: GPIOs 96-127, parent: platform/30230000.gpio, 30230000.gpio:
gpio-117 ( |PCIe reset ) out hi

gpiochip4: GPIOs 128-159, parent: platform/30240000.gpio, 30240000.gpio:
gpio-135 ( |gpio_hog_demo ) out hi
gpio-141 ( |spi1 CS0 ) out hi ACTIVE LOW
gpio-149 ( |wlf,mute ) out hi ACTIVE LOW
root@imx8mmevk:~# [ 33.758914] VSD_3V3: disabling

dtc_utils-v1.6.1-win-x86_64.zip by msys2 


Version history
Revision #:
6 of 6
Last update:
‎03-29-2022 11:06 PM
Updated by: