kernel-uboot.bbclass: Use vmlinux.initramfs when INITRAMFS_IMAGE_BUNDLE set

Message ID 20220620134019.16951-1-raju.kumar-pothuraju@xilinx.com
State Accepted, archived
Commit e0a4e45e067d9fdb67a7d223aea463f259469035
Headers show
Series kernel-uboot.bbclass: Use vmlinux.initramfs when INITRAMFS_IMAGE_BUNDLE set | expand

Commit Message

Raju Kumar Pothuraju June 20, 2022, 1:40 p.m. UTC
vmlinux file doesnot have the initramfs image when INITRAMFS_IMAGE_BUNDLE was set.
Use vmlinux.initramfs in uboot_prep_kimage when INITRAMFS_IMAGE_BUNDLE set
based on the implementation in kernel.bbclass do_bundle_initramfs function,
https://github.com/openembedded/openembedded-core/blob/master/meta/classes/kernel.bbclass#L316-L317
to be able to use proper linux.bin file in creation of fitImage.

Signed-off-by: Raju Kumar Pothuraju <raju.kumar-pothuraju@xilinx.com>
---
 meta/classes/kernel-uboot.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jose Quaresma June 20, 2022, 2:07 p.m. UTC | #1
Hi Raju,

Raju Kumar Pothuraju <raju.kumar-pothuraju@xilinx.com> escreveu no dia
segunda, 20/06/2022 à(s) 14:40:

> vmlinux file doesnot have the initramfs image when INITRAMFS_IMAGE_BUNDLE
> was set.
> Use vmlinux.initramfs in uboot_prep_kimage when INITRAMFS_IMAGE_BUNDLE set
> based on the implementation in kernel.bbclass do_bundle_initramfs function,
>
> https://github.com/openembedded/openembedded-core/blob/master/meta/classes/kernel.bbclass#L316-L317
> to be able to use proper linux.bin file in creation of fitImage.
>
> Signed-off-by: Raju Kumar Pothuraju <raju.kumar-pothuraju@xilinx.com>
> ---
>  meta/classes/kernel-uboot.bbclass | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/meta/classes/kernel-uboot.bbclass
> b/meta/classes/kernel-uboot.bbclass
> index 2daa068298..180e7cf066 100644
> --- a/meta/classes/kernel-uboot.bbclass
> +++ b/meta/classes/kernel-uboot.bbclass
> @@ -15,6 +15,12 @@ uboot_prep_kimage() {
>                 linux_comp="none"
>         else
>                 vmlinux_path="vmlinux"
> +               # Use vmlinux.initramfs for linux.bin when
> INITRAMFS_IMAGE_BUNDLE set
> +               # As per the implementation in kernel.bbclass.
> +               # See do_bundle_initramfs function
> +               if [ x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
>

Maybe a check to see if the file exists is better aligned with the reminder
in the bbclass.
[ -e arch/${ARCH}/boot/vmlinux.initramfs ]

Jose


> +                       vmlinux_path="vmlinux.initramfs"
> +               fi
>                 linux_suffix="${FIT_KERNEL_COMP_ALG_EXTENSION}"
>                 linux_comp="${FIT_KERNEL_COMP_ALG}"
>         fi
> --
> 2.17.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#167108):
> https://lists.openembedded.org/g/openembedded-core/message/167108
> Mute This Topic: https://lists.openembedded.org/mt/91876695/5052612
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> quaresma.jose@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Michael Opdenacker June 20, 2022, 2:16 p.m. UTC | #2
Hi Raju,

On 6/20/22 15:40, Raju Kumar Pothuraju wrote:
> vmlinux file doesnot have the initramfs image when INITRAMFS_IMAGE_BUNDLE was set.
> Use vmlinux.initramfs in uboot_prep_kimage when INITRAMFS_IMAGE_BUNDLE set
> based on the implementation in kernel.bbclass do_bundle_initramfs function,
> https://github.com/openembedded/openembedded-core/blob/master/meta/classes/kernel.bbclass#L316-L317
> to be able to use proper linux.bin file in creation of fitImage.
>
> Signed-off-by: Raju Kumar Pothuraju <raju.kumar-pothuraju@xilinx.com>
> ---
>   meta/classes/kernel-uboot.bbclass | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/meta/classes/kernel-uboot.bbclass b/meta/classes/kernel-uboot.bbclass
> index 2daa068298..180e7cf066 100644
> --- a/meta/classes/kernel-uboot.bbclass
> +++ b/meta/classes/kernel-uboot.bbclass
> @@ -15,6 +15,12 @@ uboot_prep_kimage() {
>   		linux_comp="none"
>   	else
>   		vmlinux_path="vmlinux"
> +		# Use vmlinux.initramfs for linux.bin when INITRAMFS_IMAGE_BUNDLE set
> +		# As per the implementation in kernel.bbclass.
> +		# See do_bundle_initramfs function
> +		if [ x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then


Thanks for the patch!
By the way, why this weird x"${VAR}" = x1 trick?

I see it elsewhere in the class code, so I understand why you took it, 
but why not just the following?

if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then

Thanks again

Michael.
Michael Opdenacker June 20, 2022, 3:24 p.m. UTC | #3
Hi Raju,

On 6/20/22 16:45, Pothuraju, Rajukumar wrote:
>>
>> Thanks for the patch!
>> By the way, why this weird x"${VAR}" = x1 trick?
>>
>> I see it elsewhere in the class code, so I understand why you took it, but why
>> not just the following?
>>
>> if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
> Both formats will gives the same output when the variable set to "1".  This just skips passing empty string to if condition in comparison. And, I think the direct comparison may not work in old shells properly.
>
> Regards,
> Rajukumar P.


Thanks for your opinion. I'm copying Jason Wessel, who first wrote this 
kind of test in this file (in 2013!), hoping he can explain. I hope 
that's no longer necessary today, because I find this hack a bit ugly.

Cheers
Michael.

Patch

diff --git a/meta/classes/kernel-uboot.bbclass b/meta/classes/kernel-uboot.bbclass
index 2daa068298..180e7cf066 100644
--- a/meta/classes/kernel-uboot.bbclass
+++ b/meta/classes/kernel-uboot.bbclass
@@ -15,6 +15,12 @@  uboot_prep_kimage() {
 		linux_comp="none"
 	else
 		vmlinux_path="vmlinux"
+		# Use vmlinux.initramfs for linux.bin when INITRAMFS_IMAGE_BUNDLE set
+		# As per the implementation in kernel.bbclass.
+		# See do_bundle_initramfs function
+		if [ x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
+			vmlinux_path="vmlinux.initramfs"
+		fi
 		linux_suffix="${FIT_KERNEL_COMP_ALG_EXTENSION}"
 		linux_comp="${FIT_KERNEL_COMP_ALG}"
 	fi