Bug 15092 - Document devicetree.bbclass
Summary: Document devicetree.bbclass
Status: RESOLVED FIXED
Alias: None
Product: Reference
Classification: Documentation
Component: handbook (show other bugs)
Version: unspecified
Hardware: All Multiple
: Medium+ enhancement
Target Milestone: 4.3 M1
Assignee: Michael Opdenacker
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2023-04-04 09:21 UTC by Luca Ceresoli
Modified: 2023-04-28 16:23 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Yes (doc changes required)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luca Ceresoli 2023-04-04 09:21:05 UTC
devicetree.bbclass is in oe-core since several years, and according to my experience it works well and it is very useful for real products, where the hardware is custom and the device tree is out of the kernel tree.

Thus it should be mentioned in the "Classes" chapter of the reference manual.
Comment 1 Michael Opdenacker 2023-04-04 17:32:03 UTC
Hi Luca
Thanks for the suggestion!
Would you have an example recipe using this class?
That would help to explain how to use it.
Any further details (like a quick draft) will help too.
Cheers
Michael.
Comment 2 Luca Ceresoli 2023-04-05 14:32:29 UTC
I have this one, which definitely arguments how easy it is to use the class (just renamed the machine to hide customer details):

------- recipes-kernel/linux/devicetree-acme.bb: --------
inherit devicetree

COMPATIBLE_MACHINE = "^mymachine$"

SRC_URI:mymachine = "file://mymachine.dts"
---------------------------------------------------------

Looking at the source code, I'd say the initial comment is already a pretty good documentation. Starting from that and adding a few details, I came up with this draft:

The devicetree class allows building a recipe that compiles device tree
source files that are not in the kernel tree.
The compilation of the device tree sources is the same as the kernel
device tree compilation process, this includes being able to include sources
from the kernel such as SoC dtsi files or header files such as gpio.h.

The do_compile() task will compile two kinds of files:
 * Regular device tree sources with a .dts extension
 * Device tree overlays, detected from the presence of the "/plugin/;"
   string in the file content

The output of this class behaves similar to how kernel-devicetree.bbclass
operates in that the output files are installed into /boot/devicetree.
However this class on purpose separates the deployed device trees into the
'devicetree' subdirectory. This prevents clashes with the kernel-devicetree
output. Additionally the device trees are populated into the sysroot for
access via the sysroot from within other recipes.

An extra padding is appended to non-overlay device trees blobs, used as extra space typically for additional properties during boot. The padding size can be modified by setting DT_PADDING_SIZE to the desired padding size, in bytes.
Comment 3 Michael Opdenacker 2023-04-12 19:12:27 UTC
Many thanks Luca! This helped a lot.
A patch has been sent:
https://lists.yoctoproject.org/g/docs/message/3836
Comment 4 Michael Opdenacker 2023-04-28 16:23:19 UTC
Now fixed thanks to this commit:
https://git.yoctoproject.org/yocto-docs/commit/?id=f65816f5ea62e6c4301c0bd0c6aad91110963f9e

Thanks Luca for the proposed text!