What is the right way to change dtb file?

  • Afaik the dtb is created during kernel build - and I searched packages/linux for scripts that I could overload ...

    didn't find some.

    So I tried to create an overlay file, added it to extlinux.conf - but then, LE does not boot any more.

    What I wanted to change was enabling the pwm entries pwm@ff420000 and pwm@ff420010 - both are disabled by default.

    Having both enabled, the fan control is possible without any additional software on LE (I was able to buid a python script that works without installing any additional python packages. Shellscripts did not work on LE as busybox does not support arrays).

    So I'm at the end of porting fan control but again at the beginning of my problems.

    I tried new nightly image, but that does not boot at all - not from sd and neither from emmc.

    nightly build from 21/04/30 works fine from sd.

    • Official Post

    you didn't tell which board you're using.

    Afaik the dtb is created during kernel build - and I searched packages/linux for scripts that I could overload ...

    didn't find some.

    If you want to go this way, you have to make kernel patch and add it to "patches" folder.

    So I tried to create an overlay file, added it to extlinux.conf - but then, LE does not boot any more.

    This should work for Allwinner boards, if you use latest image. But I suspect you're using different platform.

  • you didn't tell which board you're using.

    Sorry, I'm working on a rockpi4 (rk3399 from radxa with penta-sata hat).

    This should work for Allwinner boards, if you use latest image.

    So overlay don't work for all boards?

    I thought it's a common practice.

    If you want to go this way, you have to make kernel patch and add it to "patches" folder.

    Hm, I didn't find another way to work.

    I first took the dtb file from running LE installation, decompiled it, changed the values and took the recompiled file back to flash image. That worked fine, but I thought, that's no way for image creation. So I searched for a way, that could work for all ...

    If you know another way, how I could reach same result with the tools, LE already provides, please let me know.

    • Official Post

    You can use overlays, but these are compiled files so you cannot add a text file and use it. You need to make a kernel patch to add the overlay to the kernel (and compile it) and then include the overlay in the list of overlay files that are copied to the image. Then you can add the overlay to extlinux.conf and use it. There is plenty of prior-art for that in the Allwinner build-project.

  • You can use overlays, but these are compiled files so you cannot add a text file and use it

    Oh man! I wrote about recompiling - so yes, I know!

    I read about changing extlinux.conf in other threads about overlays.

    I don't know much, but I read a lot and try to follow others.

    What I don't understand, is what breaks LE boot process?

    I'll dive into kernel stuff to see, whether I could do some patches.

  • Here is what I did to add my custom overlay in LE:

    1) created device tree fragment, in my case adding missing H3 CPU frequency

    2) compiled it to binary

    Code
    dtc -I dts -O dtb -o sun8i-h3-cpu-clock.dtbo sun8i-h3-cpu-clock.dts

    3) remounted /flash in read/write mode and copied sun8i-h3-cpu-clock.dtbo to /flash/overlays/

    4) added "FDTOVERLAYS /overlays/sun8i-h3-cpu-clock.dtbo" to extlinux.conf, just before APPEND line.

    It only has to be done once, your custom overlay will be kept even after LE upgrades.

  • offbeat I started following an armbian thread.

    That overlay worked with kernel4.4 and kernel5.10 - so I thought, it might be usable for LE.

    But bringing that overlay to LE, LE does not boot any more.

    ... and shellscript fails, as LE uses busybox as shell, whereas armbian has a real shell.

    So I had to test, what works with LE.

    My preferred way would have been to add a patch - but I don't know, how to do it.

  • My preferred way would have been to add a patch - but I don't know, how to do it.

    Clone linux kernel git, add your changes to arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi, then make a patch using "git format-patch" or "git diff".

    Drop your patch to LE directory in projects/Rockchip/patches/linux/ and rebuild LE.

  • offbeat I know this doing. But I don't know enuf from kernel stuff to do any changes there.

    I already scratched the sources, but I don't know, what and where to change.

    It would be easy, if I could do some scripting after dts has been generated ...