bootlin / simplest-yocto-setup

Working example of a yocto setup without unnecessary complications
66 stars 13 forks source link

How to create board definition using meta-kiss #5

Closed radoslavp closed 4 months ago

radoslavp commented 5 months ago

Thanks for creating this! Seems to be really promising for our purposes. But still, i'm bit unsure how to use it properly, or rather how to create new board definition using meta-kiss as a reference.

This is what i did:

Is this correct way to do it? Thank you.

radoslavp commented 5 months ago

Ok, figured the binman issue out (had to also create a patch to add stm32mp157a-board-u-boot.dtsi which defines binman node).

But still would appreciate some comments on whether the way i went is a good one. Thank you.

lucaceresoli commented 4 months ago

Hi @radoslavp, thanks for your appreciation!

Using your own device tree for U-Boot should be easier than how you are doing it now. First you can write a very simple recipe that builds your device tree, which is very easy using the devicetree bbclass. The class also ensures your recipe provides the virtual/dtb virtual package.

Then you can have your U-Boot recipe depend on virtual/dtb and ask the U-Boot Makefile to use your own DTB file using the EXT_DTB environment variable. See the U-Boot documentation for more details.

Actually we have a plan to add all of this to meta-kiss. Stay tuned on #3 to see when it will be done.

radoslavp commented 3 months ago

Thanks. Sorry for late reply - got sidetracked. Tried this out and it was pretty easy. For anybody interested, short howto (writing it from top of my head, so hope it's complete - anybody feel free to correct me):

LICENSE = ""

inherit devicetree

PROVIDES = "virtual/dtb"

COMPATIBLE_MACHINE: = ".*" SRC_URI:append: = " \ file://.dts \ "


* create subdirectory recipes-bsp/device-tree/files
* put your dts/dtsi files to recipes-bsp/device-tree/files
* in conf/machine/<machine-name>.conf change line `UBOOT_MAKE_TARGET:append = " DEVICE_TREE=<device tree name>"` to `UBOOT_MAKE_TARGET:append = " EXT_DTB=boot/devicetree/<device tree name>.dtb"`
*  build

I used this recipe file as a template: https://github.com/nathanrossi/meta-xilinx/blob/nrossi/devicetree-classify/meta-xilinx-bsp/recipes-bsp/device-tree/device-tree.bb
radoslavp commented 3 months ago

Well, the previous post seems to be premature. The device-tree recipe seems to build correctly, but after clean u-boot rebuild it fails on:

Device Tree Source (boot/device_tree_name.dtb) is not correctly specified.
| Please define 'CONFIG_DEFAULT_DEVICE_TREE'
| or build with 'DEVICE_TREE=<device_tree>' argument

Originally, i had something like this in my machine conf: UBOOT_MAKE_TARGET:append = " EXT_DTB=boot/devicetree/device_tree_name.dtb" - i don't know where i got the 'boot/devicetree' path :), but even when changing it to just boot/device_tree_name.dtb (as it is in the link to u-boot documentation, you provided), it still fails. I'm not sure what path should i use.

The other thing i'm not sure about is what having 'U-Boot recipe depend on virtual/dtb' actually means - is it adding DEPENDS:append:stm32mp1 = "virtual/dtb" to u-boot recipe? Cause that didn't help.

In case, you're working on this and there is gonna be a commit adding this in the near future, i'll wait. If not, i'll be grateful for any help regarding this. Thank you.

radoslavp commented 3 months ago

Just na update in case, somebody needs it. The correct path in EXT_DTB seems to be ../recipe-sysroot/boot/devicetree/device-tree-name.dtb" - at least that's what worked for me.

But then, there popped up another problem - u-boot Makefile somehow automatically includes -u-boot.dtsi which adds changes on top of original dts file used to build dtb for linux (as discussed here: https://wiki.st.com/stm32mpu/index.php?title=U-Boot_overview&oldid=79536#Device_tree). It doesn't seem devicetree.bbclass does this, so i just tried to include it in the dts, but this dtsi includes some header files present in u-boot sources, but not present in kernel sources (which devicetree.bbclass sources when building the device tree) - namely dt-bindings/clock/stm32mp1-clksrc.h. Looked at devicetree.bbclass, but wasn't sure how to tell it to use u-boot sources instead of kernel ones. So that's where i stopped for now.