All of lore.kernel.org
 help / color / mirror / Atom feed
* no dt overlay example in meta-skeleton
@ 2021-05-06  9:27 dan
  2021-05-06  9:35 ` [poky] " Richard Purdie
  0 siblings, 1 reply; 4+ messages in thread
From: dan @ 2021-05-06  9:27 UTC (permalink / raw)
  To: poky

[-- Attachment #1: Type: text/plain, Size: 323 bytes --]

Hi,

In the  the meta-skeleton repo there is an example that shows how to build a standalone kernel module but no example of how to include or build an accompanying device tree overlay. Is there an existing "standard" way to achieve this? I am aware it can be done via the a .append on the linux kernel.

Many Thanks

[-- Attachment #2: Type: text/html, Size: 351 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [poky] no dt overlay example in meta-skeleton
  2021-05-06  9:27 no dt overlay example in meta-skeleton dan
@ 2021-05-06  9:35 ` Richard Purdie
  2021-05-06 11:35   ` Quentin Schulz
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Purdie @ 2021-05-06  9:35 UTC (permalink / raw)
  To: dan, poky

On Thu, 2021-05-06 at 02:27 -0700, dan@engineeredarts.co.uk wrote:
> Hi, 
> 
> In the  the meta-skeleton repo there is an example that shows how to 
> build a standalone kernel module but no example of how to include or
> build an accompanying device tree overlay. Is there an existing "standard" way
> to achieve this? I am aware it can be done via the a .append on the linux kernel. 

I'm not aware of one but it would be something that could be nice to
add if you do work it out and were willing!

Cheers,

Richard


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [poky] no dt overlay example in meta-skeleton
  2021-05-06  9:35 ` [poky] " Richard Purdie
@ 2021-05-06 11:35   ` Quentin Schulz
  2021-05-07 16:02     ` dan
  0 siblings, 1 reply; 4+ messages in thread
From: Quentin Schulz @ 2021-05-06 11:35 UTC (permalink / raw)
  To: Richard Purdie; +Cc: dan, poky

On Thu, May 06, 2021 at 10:35:55AM +0100, Richard Purdie wrote:
> On Thu, 2021-05-06 at 02:27 -0700, dan@engineeredarts.co.uk wrote:
> > Hi, 
> > 
> > In the  the meta-skeleton repo there is an example that shows how to 
> > build a standalone kernel module but no example of how to include or
> > build an accompanying device tree overlay. Is there an existing "standard" way
> > to achieve this? I am aware it can be done via the a .append on the linux kernel. 
> 
> I'm not aware of one but it would be something that could be nice to
> add if you do work it out and were willing!
> 

I agree on this.

Probably just need DEPENDS = "dtc-native" and do proper dtc calls in
do_compile.

I would expect this to be allarch too.

The tricky thing is that in order for dtbo to be usable, the original
dtb should keep the references of Device Tree nodes (which it does not
by default, or at least didn't, don't know for the more recent kernels).

See what I had to do for a project a while ago:
https://github.com/QSchulz/linux-at91/commit/c1ddbd31090bc8d82d5df38af2a12e8c053bb01f

I think we have support for DTC_FLAGS in Yocto now:
https://docs.yoctoproject.org/ref-manual/variables.html#term-KERNEL_DTC_FLAGS
so that could be a way to pass this flag without requiring users to patch the
sources of their Linux kernel.

Thinking about it, maybe that is something that could be added to
KERNEL_DTC_FLAGS if some other variable in set in, e.g. a machine
configuration file. Let's say KERNEL_DTBO_SUPPORT = "1" would add "-@"
to KERNEL_DTC_FLAGS.

Anyway, that's outside of the scope of the patch you could to send.

Just pointers :)

Looking forward to your patch,
Cheers,
Quentin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: no dt overlay example in meta-skeleton
  2021-05-06 11:35   ` Quentin Schulz
@ 2021-05-07 16:02     ` dan
  0 siblings, 0 replies; 4+ messages in thread
From: dan @ 2021-05-07 16:02 UTC (permalink / raw)
  To: poky

[-- Attachment #1: Type: text/plain, Size: 2095 bytes --]

RFC - this seems to work for me.

File : dtbo-standalone.bbclass
> 
> 
>> # Inherit this class in a recipe to build an out of kernel tree Device
>> tree overlay (.dtbo) file
> 
> 
>> DEPENDS = "dtc-native"
> 
> 
>> inherit deploy
> 
> 
>> do_compile() {
> 
> 
>> cd ${S}
> 
> 
>> pwd
> 
> 
>> for dtbo in ${DT_OVERLAYS}; do
> 
> 
>> dtc -@ -Hepapr -I dts -o $dtbo.dtbo $dtbo.dts
> 
> 
>> done
> 
> 
>> }
> 
> 
>> do_deploy() {
> 
> 
>> install -d ${DEPLOYDIR}
> 
> 
>> for i in ${S}/*.dtbo ; do
> 
> 
>> cp $i ${DEPLOYDIR}
> 
> 
>> done
> 
> 
>> }
> 
> 
>> addtask deploy before do_build after do_install
> 
> 
>> do_deploy[dirs] += "${DEPLOYDIR}"
> 
> 
>> PACKAGE_ARCH = "${MACHINE_ARCH}"
> 
> 

File : dtbo-standalone-image.bbclass

> 
> # Inherit this class in your image recipe to include Device tree overlay
> (.dtbo) files built outside of the kernel tree, e.g. by a my-dtbo.bb
> recipe
> 
> DTBO_STANDLONE ?= ""
> 
> def make_standalone_dtbo_files_list(d):
> # Generate IMAGE_BOOT_FILES entries for device tree files listed in
> # DTBO_STANDLONE.
> dtbs = d.getVar('DTBO_STANDLONE')
> 
> def transform(dtb):
> base = os.path.basename(dtb)
> if dtb.endswith('dtbo'):
> # overlay dtb:
> # eg: overlays/hifiberry-amp.dtbo has:
> #     DEPLOYDIR file: hifiberry-amp.dtbo
> #     destination: overlays/hifiberry-amp.dtbo
> return '{};{}'.format(base, dtb)
> elif dtb.endswith('dtb'):
> # eg: whatever/bcm2708-rpi-b.dtb has:
> #     DEPLOYDIR file: bcm2708-rpi-b.dtb
> #     destination: bcm2708-rpi-b.dtb
> return base
> 
> return ' '.join([transform(dtb) for dtb in dtbs.split(' ') if dtb])
> 
> IMAGE_BOOT_FILES += "${@make_standalone_dtbo_files_list(d)}"
> 

File : my-dtbo.bb

> 
> inherit dtbo-standalone
> 
> LICENSE = "CLOSED" # For brevity only
> SRC_URI += "file://my-dt.dts;subdir=${PN}-${PV}"
> DT_OVERLAYS = "my-dt"
> 

And then in the image where you want to install the DT file

> 
> DTBO_STANDLONE += "my-dt.dtbo"

> 
> inherit dtbo-standalone-image

[-- Attachment #2: Type: text/html, Size: 3533 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-07 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  9:27 no dt overlay example in meta-skeleton dan
2021-05-06  9:35 ` [poky] " Richard Purdie
2021-05-06 11:35   ` Quentin Schulz
2021-05-07 16:02     ` dan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.