dgibson / dtc

Device Tree Compiler
235 stars 134 forks source link

Apply multiple DTB overlays to create single DTB file? #99

Closed Harvie closed 1 year ago

Harvie commented 1 year ago

Hello, i have one base .dtb file and multiple .dtbo overlays. I know there are ways to apply these in runtime, eg. using u-boot. But in some cases i would like to prepare single .dtb file staticaly in build script. I tried to do the following:

#!/bin/bash
#call this script with list of .dtb files to get all overlays applied and combined to single .dtb

combine_to_dts() {
    main="$1"

    dtc -I dtb -O dts -@ "$main"

    shift
    for file in "$@"; do
        dtc -I dtb -O dts -@ "$file" | sed -e 's/\/dts-v.\/;//g'
    done
}

combine_to_dts $@ | dtc -I dts -O dtb -@

Basicaly it just decompiles all .dtb to .dts files, concatenates them, strips all headers except for the first one and tries to compile everything again. But it does not really work and reports duplicated phandles.

Can you please add some option that would do this correctly for me directly using dtc?

a3f commented 1 year ago

Do you know about the fdtoverlay utility?

Harvie commented 1 year ago

Do you know about the fdtoverlay utility?

Of course. Now that you've told me :-) For some reason they did not suggested it on stackoverflow thread i was looking into... Thanks.