Skip to contentSkip to conversation

kernel-fitimage.bbclass: Introduce a way to provide external dtb

PATCH In review Manjukumar Matha 5 participants 11 messages Feb 15, 2019 – Apr 5, 2019 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1550192184-13460-1-git-send-email-manjukumar.harthikote-matha@xilinx.com

#1 lore raw

PATCH 2/2 kernel-fitimage.bbclass: Introduce a way to provide external dtb

Currently kernel-fitimage gets the dtb from KERNEL_DEVICETREE, however there are instances when the DTB file can be generated using other recipes, provide a way to include the DTB instead of inkernel device tree.

Add support for external device tree during the creation of fitimage. If virtual/dtb is set then use the path provided in EXTERNAL_KERNEL_DEVICETREE else use KERNEL_DEVICETREE during fitimage process

---
 meta/classes/kernel-fitimage.bbclass | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
meta/classes/kernel-fitimage.bbclass +19 -1
index 8ebd3dd..3adb1c9 100644
@@ -30,6 +30,13 @@ python __anonymous () {
         if image:
             d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
 
+	#check if there are any dtb providers
+        providerdtb = d.getVar("PREFERRED_PROVIDER_virtual/dtb")
+        if providerdtb:
+            d.appendVarFlag('do_assemble_fitimage', 'depends', ' virtual/dtb:do_populate_sysroot')
+            d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' virtual/dtb:do_populate_sysroot')
+            d.setVar('EXTERNAL_KERNEL_DEVICETREE', "${RECIPE_SYSROOT}/boot/devicetree")
+
         # Verified boot will sign the fitImage and append the public key to
         # U-Boot dtb. We ensure the U-Boot dtb is deployed before assembling
         # the fitImage:
@@ -373,7 +380,8 @@ fitimage_assemble() {
 	#
 	# Step 2: Prepare a DTB image section
 	#
-	if [ -n "${KERNEL_DEVICETREE}" ]; then
+
+	if [ -z "${EXTERNAL_KERNEL_DEVICETREE}" ] && [ -n "${KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in ${KERNEL_DEVICETREE}; do
 			if echo ${DTB} | grep -q '/dts/'; then
@@ -391,6 +399,16 @@ fitimage_assemble() {
 		done
 	fi
 
+	if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
+		dtbcount=1
+		for DTBFILE in ${EXTERNAL_KERNEL_DEVICETREE}/*.dtb; do
+			DTB=`basename ${DTBFILE}`
+			DTB=$(echo "${DTB}" | tr '/' '_')
+			DTBS="${DTBS} ${DTB}"
+			fitimage_emit_section_dtb ${1} ${DTB} ${DTBFILE}
+		done
+	fi
+
 	#
 	# Step 3: Prepare a setup section. (For x86)
 	#
Signature · 1 line
2.7.4
#2 lore raw

With these patches, I made a fitImage that booted on the mini-zed. It would be nice to include a note on how to enable this. I took at few stabs at it and ended up with

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

in he machine file to get the code to trigger.

Philip

Quoted 61 lines · Manjukumar Matha

Currently kernel-fitimage gets the dtb from KERNEL_DEVICETREE, however there are instances when the DTB file can be generated using other recipes, provide a way to include the DTB instead of inkernel device tree.

Add support for external device tree during the creation of fitimage. If virtual/dtb is set then use the path provided in EXTERNAL_KERNEL_DEVICETREE else use KERNEL_DEVICETREE during fitimage process

---
 meta/classes/kernel-fitimage.bbclass | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
meta/classes/kernel-fitimage.bbclass +19 -1
index 8ebd3dd..3adb1c9 100644
@@ -30,6 +30,13 @@ python __anonymous () {
         if image:
             d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
 
+	#check if there are any dtb providers
+        providerdtb = d.getVar("PREFERRED_PROVIDER_virtual/dtb")
+        if providerdtb:
+            d.appendVarFlag('do_assemble_fitimage', 'depends', ' virtual/dtb:do_populate_sysroot')
+            d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' virtual/dtb:do_populate_sysroot')
+            d.setVar('EXTERNAL_KERNEL_DEVICETREE', "${RECIPE_SYSROOT}/boot/devicetree")
+
         # Verified boot will sign the fitImage and append the public key to
         # U-Boot dtb. We ensure the U-Boot dtb is deployed before assembling
         # the fitImage:
@@ -373,7 +380,8 @@ fitimage_assemble() {
 	#
 	# Step 2: Prepare a DTB image section
 	#
-	if [ -n "${KERNEL_DEVICETREE}" ]; then
+
+	if [ -z "${EXTERNAL_KERNEL_DEVICETREE}" ] && [ -n "${KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in ${KERNEL_DEVICETREE}; do
 			if echo ${DTB} | grep -q '/dts/'; then
@@ -391,6 +399,16 @@ fitimage_assemble() {
 		done
 	fi
 
+	if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
+		dtbcount=1
+		for DTBFILE in ${EXTERNAL_KERNEL_DEVICETREE}/*.dtb; do
+			DTB=`basename ${DTBFILE}`
+			DTB=$(echo "${DTB}" | tr '/' '_')
+			DTBS="${DTBS} ${DTB}"
+			fitimage_emit_section_dtb ${1} ${DTB} ${DTBFILE}
+		done
+	fi
+
 	#
 	# Step 3: Prepare a setup section. (For x86)
 	#
#3 lore raw

Hi Philip,

Quoted 10 lines

-----Original Message-----
From: Philip Balister [mailto:[email protected]]
Sent: Sunday, February 17, 2019 3:47 PM
To: Manjukumar Harthikote Matha <[email protected]>
Cc: openembedded-core <[email protected]>
Subject: Re: [OE-core][PATCH 2/2] kernel-fitimage.bbclass: Introduce a way to provide external dtb

With these patches, I made a fitImage that booted on the mini-zed. It would be nice to include a note on how to enable this. I took at few stabs at it and ended up with

Thanks for testing it out on mini-zed

Quoted 3 lines

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Yes, I should have added this in the commit message. I will update it and re-send V2

Thanks,
Manju

Quoted 10 lines

in he machine file to get the code to trigger.

Philip

Quoted 5 lines · Manjukumar Matha

Currently kernel-fitimage gets the dtb from KERNEL_DEVICETREE, however there are instances when the DTB file can be generated using other recipes, provide a way to include the DTB instead of inkernel device tree.

<...>

#4 lore raw
Quoted 16 lines · Manjukumar Harthikote Matha

Hi Philip,

Quoted 9 lines

-----Original Message-----
From: Philip Balister [mailto:[email protected]]
Sent: Sunday, February 17, 2019 3:47 PM
To: Manjukumar Harthikote Matha <[email protected]>
Cc: openembedded-core <[email protected]>
Subject: Re: [OE-core][PATCH 2/2] kernel-fitimage.bbclass:
Introduce a way to
provide external dtb

Quoted 4 lines

With these patches, I made a fitImage that booted on the mini-zed. It would be nice
to include a note on how to enable this. I took at few stabs at it and ended up with

Quoted 7 lines

Thanks for testing it out on mini-zed

Quoted 2 lines

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Yes, I should have added this in the commit message. I will update it and re-send V2

What may also help a lot here would be some tests. This is currently a blackhole in the tests :(

Cheers,

Richard

#5 lore raw

Hi Richard,

Quoted 28 lines

-----Original Message-----
From: Richard Purdie [mailto:[email protected]]
Sent: Wednesday, February 20, 2019 3:16 PM
To: Manjukumar Harthikote Matha <[email protected]>; Philip Balister <[email protected]>
Cc: openembedded-core <[email protected]>
Subject: Re: [OE-core] [PATCH 2/2] kernel-fitimage.bbclass: Introduce a way to provide external dtb

Quoted 18 lines · Manjukumar Harthikote Matha

Hi Philip,

Quoted 9 lines

-----Original Message-----
From: Philip Balister [mailto:[email protected]]
Sent: Sunday, February 17, 2019 3:47 PM
To: Manjukumar Harthikote Matha <[email protected]>
Cc: openembedded-core <[email protected]>
Subject: Re: [OE-core][PATCH 2/2] kernel-fitimage.bbclass:
Introduce a way to
provide external dtb

Quoted 4 lines

With these patches, I made a fitImage that booted on the mini-zed. It would be nice
to include a note on how to enable this. I took at few stabs at it and ended up with

Thanks for testing it out on mini-zed

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Yes, I should have added this in the commit message. I will update it and re-send V2

What may also help a lot here would be some tests. This is currently a blackhole in the tests :(

Are there examples of having tests only for bbclass in OE-Core?

We need a recipe or create-one to inherit this class and probably add that as a testcase. I am not sure how to proceed, any example would help to implement the same

Thanks,
Manju

#6 lore raw
Quoted 10 lines · Manjukumar Harthikote Matha

From: Richard Purdie [mailto:[email protected]]

Quoted 9 lines

On Tue, 2019-02-19 at 19:34 +0000, Manjukumar Harthikote Matha

Quoted 6 lines
Quoted 2 lines

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Yes, I should have added this in the commit message. I will update it
and re-send V2

Quoted 5 lines
Quoted 4 lines

What may also help a lot here would be some tests. This is currently a blackhole in
the tests :(

Are there examples of having tests only for bbclass in OE-Core?

There are. See meta/lib/oeqa/selftest/cases/wic.py

I appreciate wic is a tool, not a class but the examples there should help. You can trigger them with oe-selftest -r wic.

Another example which is a bbclass is selftest/cases/archiver.py which does use a class inherit.

Quoted 4 lines

We need a recipe or create-one to inherit this class and probably add that as a testcase.
I am not sure how to proceed, any example would help to implement the same

See above, they show how to add small config fragments. If you do need a full recipe, then the meta-selftest layer of OE-Core should be able to help too.

If you have any other questions or run into issues please do ask!

Cheers,

Richard

#7 lore raw

I appreciate the nagging about testing, but I just did an update and realized these patches never made it into master so I could request they move into thud.

Philip

Quoted 43 lines · Richard Purdie
Quoted 10 lines · Manjukumar Harthikote Matha

From: Richard Purdie [mailto:[email protected]]

Quoted 9 lines

On Tue, 2019-02-19 at 19:34 +0000, Manjukumar Harthikote Matha

Quoted 6 lines
Quoted 2 lines

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Yes, I should have added this in the commit message. I will update it
and re-send V2

Quoted 5 lines
Quoted 4 lines

What may also help a lot here would be some tests. This is currently a blackhole in
the tests :(

Are there examples of having tests only for bbclass in OE-Core?

There are. See meta/lib/oeqa/selftest/cases/wic.py

I appreciate wic is a tool, not a class but the examples there should help. You can trigger them with oe-selftest -r wic.

Another example which is a bbclass is selftest/cases/archiver.py which does use a class inherit.

Quoted 4 lines

We need a recipe or create-one to inherit this class and probably add that as a testcase.
I am not sure how to proceed, any example would help to implement the same

See above, they show how to add small config fragments. If you do need a full recipe, then the meta-selftest layer of OE-Core should be able to help too.

If you have any other questions or run into issues please do ask!

Cheers,

Richard

#8 lore raw
Quoted 3 lines · Philip Balister

I appreciate the nagging about testing, but I just did an update and realized these patches never made it into master so I could request they move into thud.

Thud needs testing too, its not just a master thing.

It needs to be in warrior first ; )

Either send me the master/warrior commit ids or send a patch with the proper subject so its clear to me.
But this looks like a new feature or am I misunderstanding?

- armin

Quoted 43 lines

Philip

Quoted 39 lines · Richard Purdie
Quoted 5 lines · Manjukumar Harthikote Matha

From: Richard Purdie [mailto:[email protected]]

Quoted 4 lines

On Tue, 2019-02-19 at 19:34 +0000, Manjukumar Harthikote Matha

Quoted 2 lines
Quoted 2 lines

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Yes, I should have added this in the commit message. I will update it
and re-send V2

What may also help a lot here would be some tests. This is currently a blackhole in
the tests :(

Are there examples of having tests only for bbclass in OE-Core?

There are. See meta/lib/oeqa/selftest/cases/wic.py

I appreciate wic is a tool, not a class but the examples there should help. You can trigger them with oe-selftest -r wic.

Another example which is a bbclass is selftest/cases/archiver.py which does use a class inherit.

Quoted 4 lines

We need a recipe or create-one to inherit this class and probably add that as a testcase.
I am not sure how to proceed, any example would help to implement the same

See above, they show how to add small config fragments. If you do need a full recipe, then the meta-selftest layer of OE-Core should be able to help too.

If you have any other questions or run into issues please do ask!

Cheers,

Richard

#9 lore raw
Quoted 6 lines · On 04/03/2019 10:12 PM, akuster808 wrote:
Quoted 3 lines · Philip Balister

I appreciate the nagging about testing, but I just did an update and realized these patches never made it into master so I could request they move into thud.

Quoted 7 lines

Thud needs testing too, its not just a master thing.

It needs to be in warrior first ; )

Either send me the master/warrior commit ids or send a patch with the proper subject so its clear to me.
But this looks like a new feature or am I misunderstanding?

New feature maybe, or bugfix for meta-xilinx. Without these, people using meta-xilinx may need to use thud + these changes.

meta-xilinx/thud needs these to build properly:

commit 084f4de4dbaf9821516fc0254d35f4fb04311d27

Author: Manjukumar Matha <[email protected]>
Date:   Wed Feb 20 10:29:06 2019 -0800

kernel-fitimage.bbclass: Introduce a way to provide external dtb

Currently kernel-fitimage gets the dtb from KERNEL_DEVICETREE, however there are instances when the DTB file can be generated using other recipes, provide a way to include the DTB instead of inkernel device tree.

Add support for external device tree during the creation of
fitimage. If
virtual/dtb is set using PREFERRED_PROVIDER_virtual/dtb =
"devicetree", which
inherits the devicetree.bbclass then use the path provided in EXTERNAL_KERNEL_DEVICETREE else use KERNEL_DEVICETREE during
fitimage process

ommit a7d52dbffd0da95de82d910c595a6c27d9b2ad0d

Author: Manjukumar Matha <[email protected]>
Date:   Wed Feb 20 10:29:05 2019 -0800

devicetree.bbclass: Add virtual provider for dtb

Add virtual provider for dtb. This class can be used to generate dtb from static devicetree, for reference see meta-xilinx layer meta-xilinx/meta-xilinx-bsp/recipes-bsp/device-tree/device-tree.bb

By providing a virtual provider we can use it to differentiate between in-kernel dtb or an external one. This can be set in local.conf as PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Quoted 47 lines

- armin

Quoted 43 lines

Philip

Quoted 39 lines · Richard Purdie
Quoted 5 lines · Manjukumar Harthikote Matha

From: Richard Purdie [mailto:[email protected]]

Quoted 4 lines

On Tue, 2019-02-19 at 19:34 +0000, Manjukumar Harthikote Matha

Quoted 2 lines
Quoted 2 lines

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Yes, I should have added this in the commit message. I will update it
and re-send V2

What may also help a lot here would be some tests. This is currently a blackhole in
the tests :(

Are there examples of having tests only for bbclass in OE-Core?

There are. See meta/lib/oeqa/selftest/cases/wic.py

I appreciate wic is a tool, not a class but the examples there should help. You can trigger them with oe-selftest -r wic.

Another example which is a bbclass is selftest/cases/archiver.py which does use a class inherit.

Quoted 4 lines

We need a recipe or create-one to inherit this class and probably add that as a testcase.
I am not sure how to proceed, any example would help to implement the same

See above, they show how to add small config fragments. If you do need a full recipe, then the meta-selftest layer of OE-Core should be able to help too.

If you have any other questions or run into issues please do ask!

Cheers,

Richard

#10 lore raw
In reply to Philip Balister

Hi Philip,

It was been merged in master, need to backport to Thud
https://github.com/openembedded/openembedded-core/commit/084f4de4dbaf9821516fc0254d35f4fb04311d27#diff-088b9c270c04d657c74b182de1f8e9f6

Thanks,
Manju

-----Original Message-----
From: Philip Balister [mailto:[email protected]]
Sent: Wednesday, April 3, 2019 10:36 AM
To: Richard Purdie <[email protected]>; Manjukumar Harthikote Matha <[email protected]>
Cc: openembedded-core <[email protected]>
Subject: Re: [OE-core] [PATCH 2/2] kernel-fitimage.bbclass: Introduce a way to provide external dtb

I appreciate the nagging about testing, but I just did an update and realized these patches never made it into master so I could request they move into thud.

Philip

Quoted 41 lines · Richard Purdie
Quoted 6 lines · Manjukumar Harthikote Matha

From: Richard Purdie [mailto:[email protected]]

Quoted 5 lines

On Tue, 2019-02-19 at 19:34 +0000, Manjukumar Harthikote Matha

Quoted 3 lines
Quoted 2 lines

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

Yes, I should have added this in the commit message. I will update it and re-send V2

What may also help a lot here would be some tests. This is currently a blackhole in the tests :(

Are there examples of having tests only for bbclass in OE-Core?

There are. See meta/lib/oeqa/selftest/cases/wic.py

I appreciate wic is a tool, not a class but the examples there should help. You can trigger them with oe-selftest -r wic.

Another example which is a bbclass is selftest/cases/archiver.py which does use a class inherit.

Quoted 4 lines

We need a recipe or create-one to inherit this class and probably add that as a testcase.
I am not sure how to proceed, any example would help to implement the same

See above, they show how to add small config fragments. If you do need a full recipe, then the meta-selftest layer of OE-Core should be able to help too.

If you have any other questions or run into issues please do ask!

Cheers,

Richard

#11 lore raw
Quoted 4 lines · Manjukumar Harthikote Matha

Hi Philip,

It was been merged in master, need to backport to Thud
https://github.com/openembedded/openembedded-core/commit/084f4de4dbaf9821516fc0254d35f4fb04311d27#diff-088b9c270c04d657c74b182de1f8e9f6

Yes, I was having a senior moment.

Too many projects at once :(

Philip

Quoted 57 lines

Thanks,
Manju

-----Original Message-----
From: Philip Balister [mailto:[email protected]]
Sent: Wednesday, April 3, 2019 10:36 AM
To: Richard Purdie <[email protected]>; Manjukumar Harthikote Matha <[email protected]>
Cc: openembedded-core <[email protected]>
Subject: Re: [OE-core] [PATCH 2/2] kernel-fitimage.bbclass: Introduce a way to provide external dtb

I appreciate the nagging about testing, but I just did an update and realized these patches never made it into master so I could request they move into thud.

Philip

Quoted 41 lines · Richard Purdie
Quoted 6 lines · Manjukumar Harthikote Matha

From: Richard Purdie [mailto:[email protected]]

Quoted 5 lines

On Tue, 2019-02-19 at 19:34 +0000, Manjukumar Harthikote Matha

Quoted 3 lines
Quoted 2 lines

PREFERRED_PROVIDER_virtual/dtb = "devicetree"

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

Yes, I should have added this in the commit message. I will update it and re-send V2

What may also help a lot here would be some tests. This is currently a blackhole in the tests :(

Are there examples of having tests only for bbclass in OE-Core?

There are. See meta/lib/oeqa/selftest/cases/wic.py

I appreciate wic is a tool, not a class but the examples there should help. You can trigger them with oe-selftest -r wic.

Another example which is a bbclass is selftest/cases/archiver.py which does use a class inherit.

Quoted 4 lines

We need a recipe or create-one to inherit this class and probably add that as a testcase.
I am not sure how to proceed, any example would help to implement the same

See above, they show how to add small config fragments. If you do need a full recipe, then the meta-selftest layer of OE-Core should be able to help too.

If you have any other questions or run into issues please do ask!

Cheers,

Richard