23

So, each time I modify the device tree I typically change the dts in a custom recipe and rebuild the image. The rebuild takes a long time since it rebuilds the entire kernel, and then the image needs to be built and finally deployed to the target device.

Is there any trick that I'm missing that rebuilds only the device tree?

UPDATE:

I've marked g0hl1n's answer as the correct one, since it is the answer to my question. However, I found it to be very cumbersome to work with the kernel in Yocto: strange, long paths and risk of files being overwritten on each rebuild, source of kernel in tmp/work-shared while the kernel is being built in tmp/work.

Instead I've moved the kernel development out of Yocto. Yocto has good tools for creating an SDK (see populate_sdk task) and with that it's easy to setup an environment for kernel development with quick rebuilds and manual (or scripted) deployments. Once the work is done the changes can be moved to a recipe using git diff.

The instructions on the following page was very helpful: http://jumpnowtek.com/beaglebone/Working-on-the-BeagleBone-kernel.html

Jonatan
  • 3,164
  • 2
  • 30
  • 47

2 Answers2

22

AFAIK there are two different ways of doing this.

  1. The kernel way: Using the scripts provided by the kernel
  • Change to your kernel source directory (<build dir>/tmp/work/<machine>/<kernel-name>/<kernel-version>/git/)
  • Execute the device-tree-compiler: ./scripts/dtc/dtc -I dts -O dtb -o ./devicetree.dtb path/to/devicetree.dts
  1. The bitbake way: Using the kernel's deploy job
  • Call $ bitbake <kernel-name> -f -c deploy
  • The generated device-tree-blob then can be found in <build dir>/tmp/work/<machine>/<kernel-name>/<kernel-version>/build/arch/arm/boot/dts/)

At least for me both versions worked in a quick test.

UPDATE: I just came over a third version of building the dtb with yocto on the net. That one uses yocto's devshell of the kernel build. For more information see the original authors page at https://splefty.blogspot.co.at/2015/09/compiling-device-tree-using-yocto.html.

HoldOffHunger
  • 10,963
  • 6
  • 53
  • 100
g0hl1n
  • 1,132
  • 12
  • 27
  • Thanks. Three good options. I prefer the second method since it is most guaranteed to do the same as a normal build. And I can't use devshell easily because Iwant to automate it. Now, to make it perfect I would like to run two tasks: "bitbake -f -c unpack" to copy all dts's and dtsi's from the recipe, followed by 'bitbake -f -c deploy' to build the dtb. But unfortunately the 'unpack' command makes the 'deploy' command rebuild the entire kernel. If it was possible to force a run of 'deploy' that does not rebuild the kernel it would be perfect! – Jonatan Aug 16 '16 at 11:26
  • Modifying files from `$TMPDIR` cannot be considered as an option. – Jérôme Pouiller Mar 26 '18 at 14:37
  • 1
    For me, `bitbake -f -c deploy` always causes it to rebuild the whole kernel, which has the same effect as just `bitbake `. I'm using the freescale kernel, linux-fslc. The meta-xilinx layer is really nice in that it provides a separate recipe for building just the device tree: https://github.com/Xilinx/meta-xilinx/tree/master/meta-xilinx-bsp/recipes-bsp/device-tree – Jetski S-type Jun 25 '18 at 00:28
  • Or run `bitbake virtual/kernel -f -c deploy` – User55412 Feb 11 '20 at 12:09
2

For me using bitbake to regenerate the device tree worked in the following way:

Command: $ bitbake <kernel-name> -f -c compile

Example: $ bitbake linux-fslc -f -c compile

Tested using yocto sumo.

Tobias Braune
  • 149
  • 1
  • 3
  • Correct me if I'm wrong, but this rebuilds the entire kernel. The question was how to do a quick compilation of just the device tree. – Jonatan Sep 07 '18 at 13:06
  • 1
    No, it triggers the kernel makefile, but if the source tree is unchanged (execept for the device tree) then the kernel binary is not regenerated. – Tobias Braune Sep 26 '18 at 11:36