Skip to contentSkip to conversation

featimage: refactor style

PATCH Superseded Andrej Valek 2 participants 10 messages Oct 5, 2021 – Oct 16, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 featimage: refactor style

- use bash variable notation without {} where possible
- just to make sure it looks like bash variable not bitbake variable one
- fix indent style in "cat" commands
- replace "! -z" -> "-n"

---
 meta/classes/kernel-fitimage.bbclass | 292 +++++++++++++--------------
 meta/classes/uboot-sign.bbclass      |  56 ++---
 2 files changed, 174 insertions(+), 174 deletions(-)
meta/classes/kernel-fitimage.bbclass +146 -146
index 38e05153e3..22b77f1858 100644
@@ -73,7 +73,7 @@ FIT_SIGN_INDIVIDUAL ?= "0"
 #
 # $1 ... .its filename
 fitimage_emit_fit_header() {
-	cat << EOF >> ${1}
+	cat << EOF >> $1
 /dts-v1/;
 
 / {
@@ -94,24 +94,24 @@ EOF
 fitimage_emit_section_maint() {
 	case $2 in
 	imagestart)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 
         images {
 EOF
 	;;
 	confstart)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 
         configurations {
 EOF
 	;;
 	sectend)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 	};
 EOF
 	;;
 	fitend)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 };
 EOF
 	;;
@@ -137,28 +137,28 @@ fitimage_emit_section_kernel() {
 			awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
 	fi
 
-	cat << EOF >> ${1}
-                kernel-${2} {
+	cat << EOF >> $1
+                kernel-$2 {
                         description = "Linux kernel";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "kernel";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
-                        compression = "${4}";
+                        compression = "$4";
                         load = <${UBOOT_LOADADDRESS}>;
-                        entry = <${ENTRYPOINT}>;
+                        entry = <$ENTRYPOINT>;
                         hash-1 {
-                                algo = "${kernel_csum}";
+                                algo = "$kernel_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${kernel_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$kernel_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${kernel_csum},${kernel_sign_algo}";
-                                key-name-hint = "${kernel_sign_keyname}";
+                                algo = "$kernel_csum,$kernel_sign_algo";
+                                key-name-hint = "$kernel_sign_keyname";
                         };
                 };
 EOF
@@ -186,26 +186,26 @@ fitimage_emit_section_dtb() {
 	elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then
 		dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;"
 	fi
-	cat << EOF >> ${1}
-                fdt-${2} {
+	cat << EOF >> $1
+                fdt-$2 {
                         description = "Flattened Device Tree blob";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "flat_dt";
                         arch = "${UBOOT_ARCH}";
                         compression = "none";
-                        ${dtb_loadline}
+                        $dtb_loadline
                         hash-1 {
-                                algo = "${dtb_csum}";
+                                algo = "$dtb_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${dtb_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$dtb_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${dtb_csum},${dtb_sign_algo}";
-                                key-name-hint = "${dtb_sign_keyname}";
+                                algo = "$dtb_csum,$dtb_sign_algo";
+                                key-name-hint = "$dtb_sign_keyname";
                         };
                 };
 EOF
@@ -220,29 +220,29 @@ EOF
 # $3 ... Path to boot script image
 fitimage_emit_section_boot_script() {
 
-        bootscr_csum="${FIT_HASH_ALG}"
+	bootscr_csum="${FIT_HASH_ALG}"
 	bootscr_sign_algo="${FIT_SIGN_ALG}"
 	bootscr_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}"
 
-        cat << EOF >> ${1}
-                bootscr-${2} {
+        cat << EOF >> $1
+                bootscr-$2 {
                         description = "U-boot script";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "script";
                         arch = "${UBOOT_ARCH}";
                         compression = "none";
                         hash-1 {
-                                algo = "${bootscr_csum}";
+                                algo = "$bootscr_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${bootscr_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$bootscr_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${bootscr_csum},${bootscr_sign_algo}";
-                                key-name-hint = "${bootscr_sign_keyname}";
+                                algo = "$bootscr_csum,$bootscr_sign_algo";
+                                key-name-hint = "$bootscr_sign_keyname";
                         };
                 };
 EOF
@@ -259,10 +259,10 @@ fitimage_emit_section_setup() {
 
 	setup_csum="${FIT_HASH_ALG}"
 
-	cat << EOF >> ${1}
-                setup-${2} {
+	cat << EOF >> $1
+                setup-$2 {
                         description = "Linux setup.bin";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "x86_setup";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
@@ -270,7 +270,7 @@ fitimage_emit_section_setup() {
                         load = <0x00090000>;
                         entry = <0x00090000>;
                         hash-1 {
-                                algo = "${setup_csum}";
+                                algo = "$setup_csum";
                         };
                 };
 EOF
@@ -297,28 +297,28 @@ fitimage_emit_section_ramdisk() {
 		ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
 	fi
 
-	cat << EOF >> ${1}
-                ramdisk-${2} {
+	cat << EOF >> $1
+                ramdisk-$2 {
                         description = "${INITRAMFS_IMAGE}";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "ramdisk";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
                         compression = "none";
-                        ${ramdisk_loadline}
-                        ${ramdisk_entryline}
+                        $ramdisk_loadline
+                        $ramdisk_entryline
                         hash-1 {
-                                algo = "${ramdisk_csum}";
+                                algo = "$ramdisk_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${ramdisk_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$ramdisk_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${ramdisk_csum},${ramdisk_sign_algo}";
-                                key-name-hint = "${ramdisk_sign_keyname}";
+                                algo = "$ramdisk_csum,$ramdisk_sign_algo";
+                                key-name-hint = "$ramdisk_sign_keyname";
                         };
                 };
 EOF
@@ -343,13 +343,13 @@ fitimage_emit_section_config() {
 		conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
 	fi
 
-	its_file="${1}"
-	kernel_id="${2}"
-	dtb_image="${3}"
-	ramdisk_id="${4}"
-	bootscr_id="${5}"
-	config_id="${6}"
-	default_flag="${7}"
+	its_file="$1"
+	kernel_id="$2"
+	dtb_image="$3"
+	ramdisk_id="$4"
+	bootscr_id="$5"
+	config_id="$6"
+	default_flag="$7"
 
 	# Test if we have any DTBs at all
 	sep=""
@@ -364,106 +364,106 @@ fitimage_emit_section_config() {
 
 	# conf node name is selected based on dtb ID if it is present,
 	# otherwise its selected based on kernel ID
-	if [ -n "${dtb_image}" ]; then
-		conf_node=$conf_node${dtb_image}
+	if [ -n "$dtb_image" ]; then
+		conf_node=$conf_node$dtb_image
 	else
-		conf_node=$conf_node${kernel_id}
+		conf_node=$conf_node$kernel_id
 	fi
 
-	if [ -n "${kernel_id}" ]; then
+	if [ -n "$kernel_id" ]; then
 		conf_desc="Linux kernel"
 		sep=", "
-		kernel_line="kernel = \"kernel-${kernel_id}\";"
+		kernel_line="kernel = \"kernel-$kernel_id\";"
 	fi
 
-	if [ -n "${dtb_image}" ]; then
-		conf_desc="${conf_desc}${sep}FDT blob"
+	if [ -n "$dtb_image" ]; then
+		conf_desc="$conf_desc${sep}FDT blob"
 		sep=", "
-		fdt_line="fdt = \"fdt-${dtb_image}\";"
+		fdt_line="fdt = \"fdt-$dtb_image\";"
 	fi
 
-	if [ -n "${ramdisk_id}" ]; then
-		conf_desc="${conf_desc}${sep}ramdisk"
+	if [ -n "$ramdisk_id" ]; then
+		conf_desc="$conf_desc${sep}ramdisk"
 		sep=", "
-		ramdisk_line="ramdisk = \"ramdisk-${ramdisk_id}\";"
+		ramdisk_line="ramdisk = \"ramdisk-$ramdisk_id\";"
 	fi
 
-	if [ -n "${bootscr_id}" ]; then
-		conf_desc="${conf_desc}${sep}u-boot script"
+	if [ -n "$bootscr_id" ]; then
+		conf_desc="$conf_desc${sep}u-boot script"
 		sep=", "
-		bootscr_line="bootscr = \"bootscr-${bootscr_id}\";"
+		bootscr_line="bootscr = \"bootscr-$bootscr_id\";"
 	fi
 
-	if [ -n "${config_id}" ]; then
-		conf_desc="${conf_desc}${sep}setup"
-		setup_line="setup = \"setup-${config_id}\";"
+	if [ -n "$config_id" ]; then
+		conf_desc="$conf_desc${sep}setup"
+		setup_line="setup = \"setup-$config_id\";"
 	fi
 
-	if [ "${default_flag}" = "1" ]; then
+	if [ "$default_flag" = "1" ]; then
 		# default node is selected based on dtb ID if it is present,
 		# otherwise its selected based on kernel ID
-		if [ -n "${dtb_image}" ]; then
-			default_line="default = \"conf-${dtb_image}\";"
+		if [ -n "$dtb_image" ]; then
+			default_line="default = \"conf-$dtb_image\";"
 		else
-			default_line="default = \"conf-${kernel_id}\";"
+			default_line="default = \"conf-$kernel_id\";"
 		fi
 	fi
 
-	cat << EOF >> ${its_file}
-                ${default_line}
+	cat << EOF >> $its_file
+                $default_line
                 $conf_node {
-			description = "${default_flag} ${conf_desc}";
-			${kernel_line}
-			${fdt_line}
-			${ramdisk_line}
-			${bootscr_line}
-			${setup_line}
+                        description = "$default_flag $conf_desc";
+                        $kernel_line
+                        $fdt_line
+                        $ramdisk_line
+                        $bootscr_line
+                        $setup_line
                         hash-1 {
-                                algo = "${conf_csum}";
+                                algo = "$conf_csum";
                         };
 EOF
 
-	if [ ! -z "${conf_sign_keyname}" ] ; then
+	if [ -n "$conf_sign_keyname" ] ; then
 
 		sign_line="sign-images = "
 		sep=""
 
-		if [ -n "${kernel_id}" ]; then
-			sign_line="${sign_line}${sep}\"kernel\""
+		if [ -n "$kernel_id" ]; then
+			sign_line="$sign_line${sep}\"kernel\""
 			sep=", "
 		fi
 
-		if [ -n "${dtb_image}" ]; then
-			sign_line="${sign_line}${sep}\"fdt\""
+		if [ -n "$dtb_image" ]; then
+			sign_line="$sign_line${sep}\"fdt\""
 			sep=", "
 		fi
 
-		if [ -n "${ramdisk_id}" ]; then
-			sign_line="${sign_line}${sep}\"ramdisk\""
+		if [ -n "$ramdisk_id" ]; then
+			sign_line="$sign_line${sep}\"ramdisk\""
 			sep=", "
 		fi
 
-		if [ -n "${bootscr_id}" ]; then
-			sign_line="${sign_line}${sep}\"bootscr\""
+		if [ -n "$bootscr_id" ]; then
+			sign_line="$sign_line${sep}\"bootscr\""
 			sep=", "
 		fi
 
-		if [ -n "${config_id}" ]; then
-			sign_line="${sign_line}${sep}\"setup\""
+		if [ -n "$config_id" ]; then
+			sign_line="$sign_line${sep}\"setup\""
 		fi
 
-		sign_line="${sign_line};"
+		sign_line="$sign_line;"
 
-		cat << EOF >> ${its_file}
+		cat << EOF >> $its_file
                         signature-1 {
-                                algo = "${conf_csum},${conf_sign_algo}";
-                                key-name-hint = "${conf_sign_keyname}";
-				${sign_line}
+                                algo = "$conf_csum,$conf_sign_algo";
+                                key-name-hint = "$conf_sign_keyname";
+                        $sign_line
                         };
 EOF
 	fi
 
-	cat << EOF >> ${its_file}
+	cat << EOF >> $its_file
                 };
 EOF
 }
@@ -478,38 +478,38 @@ fitimage_assemble() {
 	kernelcount=1
 	dtbcount=""
 	DTBS=""
-	ramdiskcount=${3}
+	ramdiskcount=$3
 	setupcount=""
 	bootscr_id=""
-	rm -f ${1} arch/${ARCH}/boot/${2}
+	rm -f $1 arch/${ARCH}/boot/$2
 
-	if [ ! -z "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
+	if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
 		bbfatal "Keys used to sign images and configuration nodes must be different."
 	fi
 
-	fitimage_emit_fit_header ${1}
+	fitimage_emit_fit_header $1
 
 	#
 	# Step 1: Prepare a kernel image section.
 	#
-	fitimage_emit_section_maint ${1} imagestart
+	fitimage_emit_section_maint $1 imagestart
 
 	uboot_prep_kimage
 
 	if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
 		initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
-		if [ -e "${initramfs_bundle_path}" ]; then
+		if [ -e "$initramfs_bundle_path" ]; then
 
 			#
 			# Include the kernel/rootfs bundle.
 			#
 
-			fitimage_emit_section_kernel ${1} "${kernelcount}" "${initramfs_bundle_path}" "${linux_comp}"
+			fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
 		else
-			bbwarn "${initramfs_bundle_path} not found."
+			bbwarn "$initramfs_bundle_pat not found."
 		fi
 	else
-		fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}"
+		fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
 	fi
 
 	#
@@ -519,9 +519,9 @@ fitimage_assemble() {
 	if [ -n "${KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in ${KERNEL_DEVICETREE}; do
-			if echo ${DTB} | grep -q '/dts/'; then
-				bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
-				DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
+			if echo $DTB | grep -q '/dts/'; then
+				bbwarn "$DTB contains the full path to the the dts file, but only the dtb name should be used."
+				DTB=`basename $DTB | sed 's,\.dts$,.dtb,g'`
 			fi
 
 			# Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE}
@@ -529,23 +529,23 @@ fitimage_assemble() {
 				continue
 			fi
 
-			DTB_PATH="arch/${ARCH}/boot/dts/${DTB}"
-			if [ ! -e "${DTB_PATH}" ]; then
-				DTB_PATH="arch/${ARCH}/boot/${DTB}"
+			DTB_PATH="arch/${ARCH}/boot/dts/$DTB"
+			if [ ! -e "$DTB_PATH" ]; then
+				DTB_PATH="arch/${ARCH}/boot/$DTB"
 			fi
 
-			DTB=$(echo "${DTB}" | tr '/' '_')
-			DTBS="${DTBS} ${DTB}"
-			fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH}
+			DTB=$(echo "$DTB" | tr '/' '_')
+			DTBS="$DTBS $DTB"
+			fitimage_emit_section_dtb $1 $DTB $DTB_PATH
 		done
 	fi
 
 	if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do
-			DTB=$(echo "${DTB}" | tr '/' '_')
-			DTBS="${DTBS} ${DTB}"
-			fitimage_emit_section_dtb ${1} ${DTB} "${EXTERNAL_KERNEL_DEVICETREE}/${DTB}"
+			DTB=$(echo "$DTB" | tr '/' '_')
+			DTBS="$DTBS $DTB"
+			fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB"
 		done
 	fi
 
@@ -557,7 +557,7 @@ fitimage_assemble() {
 		if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then
 			cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B}
 			bootscr_id="${UBOOT_ENV_BINARY}"
-			fitimage_emit_section_boot_script ${1} "${bootscr_id}" ${UBOOT_ENV_BINARY}
+			fitimage_emit_section_boot_script ${1} "$bootscr_id" ${UBOOT_ENV_BINARY}
 		else
 			bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found."
 		fi
@@ -568,7 +568,7 @@ fitimage_assemble() {
 	#
 	if [ -e arch/${ARCH}/boot/setup.bin ]; then
 		setupcount=1
-		fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin
+		fitimage_emit_section_setup $1 $setupcount arch/${ARCH}/boot/setup.bin
 	fi
 
 	#
@@ -577,27 +577,27 @@ fitimage_assemble() {
 	if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
 		# Find and use the first initramfs image archive type we find
 		for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio; do
-			initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}"
+			initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img"
 			echo "Using $initramfs_path"
-			if [ -e "${initramfs_path}" ]; then
-				fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}"
+			if [ -e "$initramfs_path" ]; then
+				fitimage_emit_section_ramdisk $1 "$ramdiskcount" "$initramfs_path"
 				break
 			fi
 		done
 	fi
 
-	fitimage_emit_section_maint ${1} sectend
+	fitimage_emit_section_maint $1 sectend
 
 	# Force the first Kernel and DTB in the default config
 	kernelcount=1
-	if [ -n "${dtbcount}" ]; then
+	if [ -n "$dtbcount" ]; then
 		dtbcount=1
 	fi
 
 	#
 	# Step 6: Prepare a configurations section
 	#
-	fitimage_emit_section_maint ${1} confstart
+	fitimage_emit_section_maint $1 confstart
 
 	# kernel-fitimage.bbclass currently only supports a single kernel (no less or
 	# more) to be added to the FIT image along with 0 or more device trees and
@@ -608,33 +608,33 @@ fitimage_assemble() {
 	# the default configuration to be used is based on the dtbcount. If there is
 	# no dtb present than select the default configuation to be based on
 	# the kernelcount.
-	if [ -n "${DTBS}" ]; then
+	if [ -n "$DTBS" ]; then
 		i=1
 		for DTB in ${DTBS}; do
 			dtb_ext=${DTB##*.}
-			if [ "${dtb_ext}" = "dtbo" ]; then
-				fitimage_emit_section_config ${1} "" "${DTB}" "" "${bootscr_id}" "" "`expr ${i} = ${dtbcount}`"
+			if [ "$dtb_ext" = "dtbo" ]; then
+				fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`"
 			else
-				fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "`expr ${i} = ${dtbcount}`"
+				fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`"
 			fi
-			i=`expr ${i} + 1`
+			i=`expr $i + 1`
 		done
 	else
 		defaultconfigcount=1
-		fitimage_emit_section_config ${1} "${kernelcount}" "" "${ramdiskcount}" "${bootscr_id}"  "${setupcount}" "${defaultconfigcount}"
+		fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id"  "$setupcount" $defaultconfigcount
 	fi
 
-	fitimage_emit_section_maint ${1} sectend
+	fitimage_emit_section_maint $1 sectend
 
-	fitimage_emit_section_maint ${1} fitend
+	fitimage_emit_section_maint $1 fitend
 
 	#
 	# Step 7: Assemble the image
 	#
 	${UBOOT_MKIMAGE} \
 		${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
-		-f ${1} \
-		arch/${ARCH}/boot/${2}
+		-f $1 \
+		arch/${ARCH}/boot/$2
 
 	#
 	# Step 8: Sign the image and add public key to U-Boot dtb
@@ -651,7 +651,7 @@ fitimage_assemble() {
 			${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
 			-F -k "${UBOOT_SIGN_KEYDIR}" \
 			$add_key_to_u_boot \
-			-r arch/${ARCH}/boot/${2} \
+			-r arch/${ARCH}/boot/$2 \
 			${UBOOT_MKIMAGE_SIGN_ARGS}
 	fi
 }
@@ -659,7 +659,7 @@ fitimage_assemble() {
 do_assemble_fitimage() {
 	if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
 		cd ${B}
-		fitimage_assemble fit-image.its fitImage
+		fitimage_assemble fit-image.its fitImage ""
 	fi
 }
 
meta/classes/uboot-sign.bbclass +28 -28

135 lines not on this page · raw message

Signature · 1 line
2.31.1
#1 lore raw

PATCH 2/2 kernel-fitimage: use correct kernel image

Even if initramfs_bundle_path was used, kernel compression was not reflected in output its image. Use linux.bin as kernel compressed output image. File is correctly created from vmlinux which includes a right initramfs image.

---
 meta/classes/kernel-fitimage.bbclass | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
meta/classes/kernel-fitimage.bbclass +1 -16
index 22b77f1858..7969c89f1a 100644
@@ -495,22 +495,7 @@ fitimage_assemble() {
 	fitimage_emit_section_maint $1 imagestart
 
 	uboot_prep_kimage
-
-	if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
-		initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
-		if [ -e "$initramfs_bundle_path" ]; then
-
-			#
-			# Include the kernel/rootfs bundle.
-			#
-
-			fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
-		else
-			bbwarn "$initramfs_bundle_pat not found."
-		fi
-	else
-		fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
-	fi
+	fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
 
 	#
 	# Step 2: Prepare a DTB image section
Signature · 1 line
2.31.1
#2 lore raw

PATCH v2 1/2 featimage: refactor style

In reply to Andrej Valek

- use bash variable notation without {} where possible
- just to make sure it looks like bash variable not bitbake variable one
- fix indent style in "cat" commands
- replace "! -z" -> "-n"
- make debug info in ramdisk section creation more verbose

---
 meta/classes/kernel-fitimage.bbclass | 297 ++++++++++++++-------------
 meta/classes/uboot-sign.bbclass      |  56 ++---
 2 files changed, 178 insertions(+), 175 deletions(-)
meta/classes/kernel-fitimage.bbclass +150 -147
index 38e05153e3..886ed13029 100644
@@ -73,7 +73,7 @@ FIT_SIGN_INDIVIDUAL ?= "0"
 #
 # $1 ... .its filename
 fitimage_emit_fit_header() {
-	cat << EOF >> ${1}
+	cat << EOF >> $1
 /dts-v1/;
 
 / {
@@ -94,24 +94,24 @@ EOF
 fitimage_emit_section_maint() {
 	case $2 in
 	imagestart)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 
         images {
 EOF
 	;;
 	confstart)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 
         configurations {
 EOF
 	;;
 	sectend)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 	};
 EOF
 	;;
 	fitend)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 };
 EOF
 	;;
@@ -137,28 +137,28 @@ fitimage_emit_section_kernel() {
 			awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
 	fi
 
-	cat << EOF >> ${1}
-                kernel-${2} {
+	cat << EOF >> $1
+                kernel-$2 {
                         description = "Linux kernel";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "kernel";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
-                        compression = "${4}";
+                        compression = "$4";
                         load = <${UBOOT_LOADADDRESS}>;
-                        entry = <${ENTRYPOINT}>;
+                        entry = <$ENTRYPOINT>;
                         hash-1 {
-                                algo = "${kernel_csum}";
+                                algo = "$kernel_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${kernel_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$kernel_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${kernel_csum},${kernel_sign_algo}";
-                                key-name-hint = "${kernel_sign_keyname}";
+                                algo = "$kernel_csum,$kernel_sign_algo";
+                                key-name-hint = "$kernel_sign_keyname";
                         };
                 };
 EOF
@@ -186,26 +186,26 @@ fitimage_emit_section_dtb() {
 	elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then
 		dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;"
 	fi
-	cat << EOF >> ${1}
-                fdt-${2} {
+	cat << EOF >> $1
+                fdt-$2 {
                         description = "Flattened Device Tree blob";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "flat_dt";
                         arch = "${UBOOT_ARCH}";
                         compression = "none";
-                        ${dtb_loadline}
+                        $dtb_loadline
                         hash-1 {
-                                algo = "${dtb_csum}";
+                                algo = "$dtb_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${dtb_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$dtb_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${dtb_csum},${dtb_sign_algo}";
-                                key-name-hint = "${dtb_sign_keyname}";
+                                algo = "$dtb_csum,$dtb_sign_algo";
+                                key-name-hint = "$dtb_sign_keyname";
                         };
                 };
 EOF
@@ -220,29 +220,29 @@ EOF
 # $3 ... Path to boot script image
 fitimage_emit_section_boot_script() {
 
-        bootscr_csum="${FIT_HASH_ALG}"
+	bootscr_csum="${FIT_HASH_ALG}"
 	bootscr_sign_algo="${FIT_SIGN_ALG}"
 	bootscr_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}"
 
-        cat << EOF >> ${1}
-                bootscr-${2} {
+        cat << EOF >> $1
+                bootscr-$2 {
                         description = "U-boot script";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "script";
                         arch = "${UBOOT_ARCH}";
                         compression = "none";
                         hash-1 {
-                                algo = "${bootscr_csum}";
+                                algo = "$bootscr_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${bootscr_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$bootscr_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${bootscr_csum},${bootscr_sign_algo}";
-                                key-name-hint = "${bootscr_sign_keyname}";
+                                algo = "$bootscr_csum,$bootscr_sign_algo";
+                                key-name-hint = "$bootscr_sign_keyname";
                         };
                 };
 EOF
@@ -259,10 +259,10 @@ fitimage_emit_section_setup() {
 
 	setup_csum="${FIT_HASH_ALG}"
 
-	cat << EOF >> ${1}
-                setup-${2} {
+	cat << EOF >> $1
+                setup-$2 {
                         description = "Linux setup.bin";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "x86_setup";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
@@ -270,7 +270,7 @@ fitimage_emit_section_setup() {
                         load = <0x00090000>;
                         entry = <0x00090000>;
                         hash-1 {
-                                algo = "${setup_csum}";
+                                algo = "$setup_csum";
                         };
                 };
 EOF
@@ -297,28 +297,28 @@ fitimage_emit_section_ramdisk() {
 		ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
 	fi
 
-	cat << EOF >> ${1}
-                ramdisk-${2} {
+	cat << EOF >> $1
+                ramdisk-$2 {
                         description = "${INITRAMFS_IMAGE}";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "ramdisk";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
                         compression = "none";
-                        ${ramdisk_loadline}
-                        ${ramdisk_entryline}
+                        $ramdisk_loadline
+                        $ramdisk_entryline
                         hash-1 {
-                                algo = "${ramdisk_csum}";
+                                algo = "$ramdisk_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${ramdisk_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$ramdisk_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${ramdisk_csum},${ramdisk_sign_algo}";
-                                key-name-hint = "${ramdisk_sign_keyname}";
+                                algo = "$ramdisk_csum,$ramdisk_sign_algo";
+                                key-name-hint = "$ramdisk_sign_keyname";
                         };
                 };
 EOF
@@ -343,13 +343,13 @@ fitimage_emit_section_config() {
 		conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
 	fi
 
-	its_file="${1}"
-	kernel_id="${2}"
-	dtb_image="${3}"
-	ramdisk_id="${4}"
-	bootscr_id="${5}"
-	config_id="${6}"
-	default_flag="${7}"
+	its_file="$1"
+	kernel_id="$2"
+	dtb_image="$3"
+	ramdisk_id="$4"
+	bootscr_id="$5"
+	config_id="$6"
+	default_flag="$7"
 
 	# Test if we have any DTBs at all
 	sep=""
@@ -364,106 +364,106 @@ fitimage_emit_section_config() {
 
 	# conf node name is selected based on dtb ID if it is present,
 	# otherwise its selected based on kernel ID
-	if [ -n "${dtb_image}" ]; then
-		conf_node=$conf_node${dtb_image}
+	if [ -n "$dtb_image" ]; then
+		conf_node=$conf_node$dtb_image
 	else
-		conf_node=$conf_node${kernel_id}
+		conf_node=$conf_node$kernel_id
 	fi
 
-	if [ -n "${kernel_id}" ]; then
+	if [ -n "$kernel_id" ]; then
 		conf_desc="Linux kernel"
 		sep=", "
-		kernel_line="kernel = \"kernel-${kernel_id}\";"
+		kernel_line="kernel = \"kernel-$kernel_id\";"
 	fi
 
-	if [ -n "${dtb_image}" ]; then
-		conf_desc="${conf_desc}${sep}FDT blob"
+	if [ -n "$dtb_image" ]; then
+		conf_desc="$conf_desc${sep}FDT blob"
 		sep=", "
-		fdt_line="fdt = \"fdt-${dtb_image}\";"
+		fdt_line="fdt = \"fdt-$dtb_image\";"
 	fi
 
-	if [ -n "${ramdisk_id}" ]; then
-		conf_desc="${conf_desc}${sep}ramdisk"
+	if [ -n "$ramdisk_id" ]; then
+		conf_desc="$conf_desc${sep}ramdisk"
 		sep=", "
-		ramdisk_line="ramdisk = \"ramdisk-${ramdisk_id}\";"
+		ramdisk_line="ramdisk = \"ramdisk-$ramdisk_id\";"
 	fi
 
-	if [ -n "${bootscr_id}" ]; then
-		conf_desc="${conf_desc}${sep}u-boot script"
+	if [ -n "$bootscr_id" ]; then
+		conf_desc="$conf_desc${sep}u-boot script"
 		sep=", "
-		bootscr_line="bootscr = \"bootscr-${bootscr_id}\";"
+		bootscr_line="bootscr = \"bootscr-$bootscr_id\";"
 	fi
 
-	if [ -n "${config_id}" ]; then
-		conf_desc="${conf_desc}${sep}setup"
-		setup_line="setup = \"setup-${config_id}\";"
+	if [ -n "$config_id" ]; then
+		conf_desc="$conf_desc${sep}setup"
+		setup_line="setup = \"setup-$config_id\";"
 	fi
 
-	if [ "${default_flag}" = "1" ]; then
+	if [ "$default_flag" = "1" ]; then
 		# default node is selected based on dtb ID if it is present,
 		# otherwise its selected based on kernel ID
-		if [ -n "${dtb_image}" ]; then
-			default_line="default = \"conf-${dtb_image}\";"
+		if [ -n "$dtb_image" ]; then
+			default_line="default = \"conf-$dtb_image\";"
 		else
-			default_line="default = \"conf-${kernel_id}\";"
+			default_line="default = \"conf-$kernel_id\";"
 		fi
 	fi
 
-	cat << EOF >> ${its_file}
-                ${default_line}
+	cat << EOF >> $its_file
+                $default_line
                 $conf_node {
-			description = "${default_flag} ${conf_desc}";
-			${kernel_line}
-			${fdt_line}
-			${ramdisk_line}
-			${bootscr_line}
-			${setup_line}
+                        description = "$default_flag $conf_desc";
+                        $kernel_line
+                        $fdt_line
+                        $ramdisk_line
+                        $bootscr_line
+                        $setup_line
                         hash-1 {
-                                algo = "${conf_csum}";
+                                algo = "$conf_csum";
                         };
 EOF
 
-	if [ ! -z "${conf_sign_keyname}" ] ; then
+	if [ -n "$conf_sign_keyname" ] ; then
 
 		sign_line="sign-images = "
 		sep=""
 
-		if [ -n "${kernel_id}" ]; then
-			sign_line="${sign_line}${sep}\"kernel\""
+		if [ -n "$kernel_id" ]; then
+			sign_line="$sign_line${sep}\"kernel\""
 			sep=", "
 		fi
 
-		if [ -n "${dtb_image}" ]; then
-			sign_line="${sign_line}${sep}\"fdt\""
+		if [ -n "$dtb_image" ]; then
+			sign_line="$sign_line${sep}\"fdt\""
 			sep=", "
 		fi
 
-		if [ -n "${ramdisk_id}" ]; then
-			sign_line="${sign_line}${sep}\"ramdisk\""
+		if [ -n "$ramdisk_id" ]; then
+			sign_line="$sign_line${sep}\"ramdisk\""
 			sep=", "
 		fi
 
-		if [ -n "${bootscr_id}" ]; then
-			sign_line="${sign_line}${sep}\"bootscr\""
+		if [ -n "$bootscr_id" ]; then
+			sign_line="$sign_line${sep}\"bootscr\""
 			sep=", "
 		fi
 
-		if [ -n "${config_id}" ]; then
-			sign_line="${sign_line}${sep}\"setup\""
+		if [ -n "$config_id" ]; then
+			sign_line="$sign_line${sep}\"setup\""
 		fi
 
-		sign_line="${sign_line};"
+		sign_line="$sign_line;"
 
-		cat << EOF >> ${its_file}
+		cat << EOF >> $its_file
                         signature-1 {
-                                algo = "${conf_csum},${conf_sign_algo}";
-                                key-name-hint = "${conf_sign_keyname}";
-				${sign_line}
+                                algo = "$conf_csum,$conf_sign_algo";
+                                key-name-hint = "$conf_sign_keyname";
+                                $sign_line
                         };
 EOF
 	fi
 
-	cat << EOF >> ${its_file}
+	cat << EOF >> $its_file
                 };
 EOF
 }
@@ -478,38 +478,38 @@ fitimage_assemble() {
 	kernelcount=1
 	dtbcount=""
 	DTBS=""
-	ramdiskcount=${3}
+	ramdiskcount=$3
 	setupcount=""
 	bootscr_id=""
-	rm -f ${1} arch/${ARCH}/boot/${2}
+	rm -f $1 arch/${ARCH}/boot/$2
 
-	if [ ! -z "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
+	if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
 		bbfatal "Keys used to sign images and configuration nodes must be different."
 	fi
 
-	fitimage_emit_fit_header ${1}
+	fitimage_emit_fit_header $1
 
 	#
 	# Step 1: Prepare a kernel image section.
 	#
-	fitimage_emit_section_maint ${1} imagestart
+	fitimage_emit_section_maint $1 imagestart
 
 	uboot_prep_kimage
 
 	if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
 		initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
-		if [ -e "${initramfs_bundle_path}" ]; then
+		if [ -e "$initramfs_bundle_path" ]; then
 
 			#
 			# Include the kernel/rootfs bundle.
 			#
 
-			fitimage_emit_section_kernel ${1} "${kernelcount}" "${initramfs_bundle_path}" "${linux_comp}"
+			fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
 		else
-			bbwarn "${initramfs_bundle_path} not found."
+			bbwarn "$initramfs_bundle_pat not found."
 		fi
 	else
-		fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}"
+		fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
 	fi
 
 	#
@@ -519,9 +519,9 @@ fitimage_assemble() {
 	if [ -n "${KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in ${KERNEL_DEVICETREE}; do
-			if echo ${DTB} | grep -q '/dts/'; then
-				bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
-				DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
+			if echo $DTB | grep -q '/dts/'; then
+				bbwarn "$DTB contains the full path to the the dts file, but only the dtb name should be used."
+				DTB=`basename $DTB | sed 's,\.dts$,.dtb,g'`
 			fi
 
 			# Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE}
@@ -529,23 +529,23 @@ fitimage_assemble() {
 				continue
 			fi
 
-			DTB_PATH="arch/${ARCH}/boot/dts/${DTB}"
-			if [ ! -e "${DTB_PATH}" ]; then
-				DTB_PATH="arch/${ARCH}/boot/${DTB}"
+			DTB_PATH="arch/${ARCH}/boot/dts/$DTB"
+			if [ ! -e "$DTB_PATH" ]; then
+				DTB_PATH="arch/${ARCH}/boot/$DTB"
 			fi
 
-			DTB=$(echo "${DTB}" | tr '/' '_')
-			DTBS="${DTBS} ${DTB}"
-			fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH}
+			DTB=$(echo "$DTB" | tr '/' '_')
+			DTBS="$DTBS $DTB"
+			fitimage_emit_section_dtb $1 $DTB $DTB_PATH
 		done
 	fi
 
 	if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do
-			DTB=$(echo "${DTB}" | tr '/' '_')
-			DTBS="${DTBS} ${DTB}"
-			fitimage_emit_section_dtb ${1} ${DTB} "${EXTERNAL_KERNEL_DEVICETREE}/${DTB}"
+			DTB=$(echo "$DTB" | tr '/' '_')
+			DTBS="$DTBS $DTB"
+			fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB"
 		done
 	fi
 
@@ -557,7 +557,7 @@ fitimage_assemble() {
 		if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then
 			cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B}
 			bootscr_id="${UBOOT_ENV_BINARY}"
-			fitimage_emit_section_boot_script ${1} "${bootscr_id}" ${UBOOT_ENV_BINARY}
+			fitimage_emit_section_boot_script $1 "$bootscr_id" ${UBOOT_ENV_BINARY}
 		else
 			bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found."
 		fi
@@ -568,7 +568,7 @@ fitimage_assemble() {
 	#
 	if [ -e arch/${ARCH}/boot/setup.bin ]; then
 		setupcount=1
-		fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin
+		fitimage_emit_section_setup $1 $setupcount arch/${ARCH}/boot/setup.bin
 	fi
 
 	#
@@ -577,27 +577,30 @@ fitimage_assemble() {
 	if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
 		# Find and use the first initramfs image archive type we find
 		for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio; do
-			initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}"
-			echo "Using $initramfs_path"
-			if [ -e "${initramfs_path}" ]; then
-				fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}"
+			initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img"
+			echo -n "Searching for $initramfs_path..."
+			if [ -e "$initramfs_path" ]; then
+				echo "found"
+				fitimage_emit_section_ramdisk $1 "$ramdiskcount" "$initramfs_path"
 				break
+			else
+				echo "not found"
 			fi
 		done
 	fi
 
-	fitimage_emit_section_maint ${1} sectend
+	fitimage_emit_section_maint $1 sectend
 
 	# Force the first Kernel and DTB in the default config
 	kernelcount=1
-	if [ -n "${dtbcount}" ]; then
+	if [ -n "$dtbcount" ]; then
 		dtbcount=1
 	fi
 
 	#
 	# Step 6: Prepare a configurations section
 	#
-	fitimage_emit_section_maint ${1} confstart
+	fitimage_emit_section_maint $1 confstart
 
 	# kernel-fitimage.bbclass currently only supports a single kernel (no less or
 	# more) to be added to the FIT image along with 0 or more device trees and
@@ -608,33 +611,33 @@ fitimage_assemble() {
 	# the default configuration to be used is based on the dtbcount. If there is
 	# no dtb present than select the default configuation to be based on
 	# the kernelcount.
-	if [ -n "${DTBS}" ]; then
+	if [ -n "$DTBS" ]; then
 		i=1
 		for DTB in ${DTBS}; do
 			dtb_ext=${DTB##*.}
-			if [ "${dtb_ext}" = "dtbo" ]; then
-				fitimage_emit_section_config ${1} "" "${DTB}" "" "${bootscr_id}" "" "`expr ${i} = ${dtbcount}`"
+			if [ "$dtb_ext" = "dtbo" ]; then
+				fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`"
 			else
-				fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "`expr ${i} = ${dtbcount}`"
+				fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`"
 			fi
-			i=`expr ${i} + 1`
+			i=`expr $i + 1`
 		done
 	else
 		defaultconfigcount=1
-		fitimage_emit_section_config ${1} "${kernelcount}" "" "${ramdiskcount}" "${bootscr_id}"  "${setupcount}" "${defaultconfigcount}"
+		fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id"  "$setupcount" $defaultconfigcount
 	fi
 
-	fitimage_emit_section_maint ${1} sectend
+	fitimage_emit_section_maint $1 sectend
 
-	fitimage_emit_section_maint ${1} fitend
+	fitimage_emit_section_maint $1 fitend
 
 	#
 	# Step 7: Assemble the image
 	#
 	${UBOOT_MKIMAGE} \
 		${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
-		-f ${1} \
-		arch/${ARCH}/boot/${2}
+		-f $1 \
+		arch/${ARCH}/boot/$2
 
 	#
 	# Step 8: Sign the image and add public key to U-Boot dtb
@@ -651,7 +654,7 @@ fitimage_assemble() {
 			${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
 			-F -k "${UBOOT_SIGN_KEYDIR}" \
 			$add_key_to_u_boot \
-			-r arch/${ARCH}/boot/${2} \
+			-r arch/${ARCH}/boot/$2 \
 			${UBOOT_MKIMAGE_SIGN_ARGS}
 	fi
 }
@@ -659,7 +662,7 @@ fitimage_assemble() {
 do_assemble_fitimage() {
 	if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
 		cd ${B}
-		fitimage_assemble fit-image.its fitImage
+		fitimage_assemble fit-image.its fitImage ""
 	fi
 }
 
meta/classes/uboot-sign.bbclass +28 -28

135 lines not on this page · raw message

Signature · 1 line
2.31.1
#3 lore raw

PATCH v2 2/2 kernel-fitimage: use correct kernel image

In reply to Andrej Valek

Even if initramfs_bundle_path was used, a wrong compression was reflected in output its template file. Use linux.bin as universal kernel image. The linux.bin file covers both cases.

---
 meta/classes/kernel-fitimage.bbclass | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
meta/classes/kernel-fitimage.bbclass +1 -16
index 886ed13029..8718ce7e16 100644
@@ -495,22 +495,7 @@ fitimage_assemble() {
 	fitimage_emit_section_maint $1 imagestart
 
 	uboot_prep_kimage
-
-	if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
-		initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
-		if [ -e "$initramfs_bundle_path" ]; then
-
-			#
-			# Include the kernel/rootfs bundle.
-			#
-
-			fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
-		else
-			bbwarn "$initramfs_bundle_pat not found."
-		fi
-	else
-		fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
-	fi
+	fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
 
 	#
 	# Step 2: Prepare a DTB image section
Signature · 1 line
2.31.1
#4 lore raw

Re: [OE-core][PATCH v2 2/2] kernel-fitimage: use correct kernel image

Hello,

This series causes the following failure:

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/2699/steps/15/logs/stdio

2021-10-12 00:31:47,557 - oe-selftest - INFO - fitimage.FitImageTests.test_initramfs_bundle (subunit.RemotedTestCase)
2021-10-12 00:31:47,665 - oe-selftest - INFO -  ... FAIL
Stderr:
2021-10-11 21:55:16,664 - oe-selftest - INFO - Adding: "include selftest.inc" in /home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/build-st-16604/conf/local.conf
2021-10-11 21:55:16,665 - oe-selftest - INFO - Adding: "include bblayers.inc" in bblayers.conf
2021-10-12 00:31:47,666 - oe-selftest - INFO - 10: 3/13 335/444 (2817.06s) (fitimage.FitImageTests.test_initramfs_bundle)
2021-10-12 00:31:47,666 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/meta/lib/oeqa/selftest/cases/fitimage.py", line 803, in test_initramfs_bundle
    self.assertTrue(test_passed == True,"kernel node does not match expectation")
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/python3.9/unittest/case.py", line 682, in assertTrue
    raise self.failureException(msg)

AssertionError: False is not true : kernel node does not match expectation

It failed on all 4 oe-selftest builds

Quoted 51 lines · Andrej Valek

Even if initramfs_bundle_path was used, a wrong compression was reflected in output its template file. Use linux.bin as universal kernel image. The linux.bin file covers both cases.

---
 meta/classes/kernel-fitimage.bbclass | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
meta/classes/kernel-fitimage.bbclass +1 -16
index 886ed13029..8718ce7e16 100644
@@ -495,22 +495,7 @@ fitimage_assemble() {
 	fitimage_emit_section_maint $1 imagestart
 
 	uboot_prep_kimage
-
-	if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
-		initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
-		if [ -e "$initramfs_bundle_path" ]; then
-
-			#
-			# Include the kernel/rootfs bundle.
-			#
-
-			fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
-		else
-			bbwarn "$initramfs_bundle_pat not found."
-		fi
-	else
-		fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
-	fi
+	fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
 
 	#
 	# Step 2: Prepare a DTB image section
Signature · 11 lines
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#156674): https://lists.openembedded.org/g/openembedded-core/message/156674
Mute This Topic: https://lists.openembedded.org/mt/86113979/3617179
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH v3 1/2 featimage: refactor style

In reply to Andrej Valek

- use bash variable notation without {} where possible
- just to make sure it looks like bash variable not bitbake variable one
- fix indent style in "cat" commands
- replace "! -z" -> "-n"
- make debug info in ramdisk section creation more verbose

---
 meta/classes/kernel-fitimage.bbclass | 297 ++++++++++++++-------------
 meta/classes/uboot-sign.bbclass      |  56 ++---
 2 files changed, 178 insertions(+), 175 deletions(-)
meta/classes/kernel-fitimage.bbclass +150 -147
index 38e05153e3..886ed13029 100644
@@ -73,7 +73,7 @@ FIT_SIGN_INDIVIDUAL ?= "0"
 #
 # $1 ... .its filename
 fitimage_emit_fit_header() {
-	cat << EOF >> ${1}
+	cat << EOF >> $1
 /dts-v1/;
 
 / {
@@ -94,24 +94,24 @@ EOF
 fitimage_emit_section_maint() {
 	case $2 in
 	imagestart)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 
         images {
 EOF
 	;;
 	confstart)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 
         configurations {
 EOF
 	;;
 	sectend)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 	};
 EOF
 	;;
 	fitend)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 };
 EOF
 	;;
@@ -137,28 +137,28 @@ fitimage_emit_section_kernel() {
 			awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
 	fi
 
-	cat << EOF >> ${1}
-                kernel-${2} {
+	cat << EOF >> $1
+                kernel-$2 {
                         description = "Linux kernel";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "kernel";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
-                        compression = "${4}";
+                        compression = "$4";
                         load = <${UBOOT_LOADADDRESS}>;
-                        entry = <${ENTRYPOINT}>;
+                        entry = <$ENTRYPOINT>;
                         hash-1 {
-                                algo = "${kernel_csum}";
+                                algo = "$kernel_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${kernel_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$kernel_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${kernel_csum},${kernel_sign_algo}";
-                                key-name-hint = "${kernel_sign_keyname}";
+                                algo = "$kernel_csum,$kernel_sign_algo";
+                                key-name-hint = "$kernel_sign_keyname";
                         };
                 };
 EOF
@@ -186,26 +186,26 @@ fitimage_emit_section_dtb() {
 	elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then
 		dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;"
 	fi
-	cat << EOF >> ${1}
-                fdt-${2} {
+	cat << EOF >> $1
+                fdt-$2 {
                         description = "Flattened Device Tree blob";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "flat_dt";
                         arch = "${UBOOT_ARCH}";
                         compression = "none";
-                        ${dtb_loadline}
+                        $dtb_loadline
                         hash-1 {
-                                algo = "${dtb_csum}";
+                                algo = "$dtb_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${dtb_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$dtb_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${dtb_csum},${dtb_sign_algo}";
-                                key-name-hint = "${dtb_sign_keyname}";
+                                algo = "$dtb_csum,$dtb_sign_algo";
+                                key-name-hint = "$dtb_sign_keyname";
                         };
                 };
 EOF
@@ -220,29 +220,29 @@ EOF
 # $3 ... Path to boot script image
 fitimage_emit_section_boot_script() {
 
-        bootscr_csum="${FIT_HASH_ALG}"
+	bootscr_csum="${FIT_HASH_ALG}"
 	bootscr_sign_algo="${FIT_SIGN_ALG}"
 	bootscr_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}"
 
-        cat << EOF >> ${1}
-                bootscr-${2} {
+        cat << EOF >> $1
+                bootscr-$2 {
                         description = "U-boot script";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "script";
                         arch = "${UBOOT_ARCH}";
                         compression = "none";
                         hash-1 {
-                                algo = "${bootscr_csum}";
+                                algo = "$bootscr_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${bootscr_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$bootscr_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${bootscr_csum},${bootscr_sign_algo}";
-                                key-name-hint = "${bootscr_sign_keyname}";
+                                algo = "$bootscr_csum,$bootscr_sign_algo";
+                                key-name-hint = "$bootscr_sign_keyname";
                         };
                 };
 EOF
@@ -259,10 +259,10 @@ fitimage_emit_section_setup() {
 
 	setup_csum="${FIT_HASH_ALG}"
 
-	cat << EOF >> ${1}
-                setup-${2} {
+	cat << EOF >> $1
+                setup-$2 {
                         description = "Linux setup.bin";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "x86_setup";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
@@ -270,7 +270,7 @@ fitimage_emit_section_setup() {
                         load = <0x00090000>;
                         entry = <0x00090000>;
                         hash-1 {
-                                algo = "${setup_csum}";
+                                algo = "$setup_csum";
                         };
                 };
 EOF
@@ -297,28 +297,28 @@ fitimage_emit_section_ramdisk() {
 		ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
 	fi
 
-	cat << EOF >> ${1}
-                ramdisk-${2} {
+	cat << EOF >> $1
+                ramdisk-$2 {
                         description = "${INITRAMFS_IMAGE}";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "ramdisk";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
                         compression = "none";
-                        ${ramdisk_loadline}
-                        ${ramdisk_entryline}
+                        $ramdisk_loadline
+                        $ramdisk_entryline
                         hash-1 {
-                                algo = "${ramdisk_csum}";
+                                algo = "$ramdisk_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${ramdisk_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$ramdisk_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${ramdisk_csum},${ramdisk_sign_algo}";
-                                key-name-hint = "${ramdisk_sign_keyname}";
+                                algo = "$ramdisk_csum,$ramdisk_sign_algo";
+                                key-name-hint = "$ramdisk_sign_keyname";
                         };
                 };
 EOF
@@ -343,13 +343,13 @@ fitimage_emit_section_config() {
 		conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
 	fi
 
-	its_file="${1}"
-	kernel_id="${2}"
-	dtb_image="${3}"
-	ramdisk_id="${4}"
-	bootscr_id="${5}"
-	config_id="${6}"
-	default_flag="${7}"
+	its_file="$1"
+	kernel_id="$2"
+	dtb_image="$3"
+	ramdisk_id="$4"
+	bootscr_id="$5"
+	config_id="$6"
+	default_flag="$7"
 
 	# Test if we have any DTBs at all
 	sep=""
@@ -364,106 +364,106 @@ fitimage_emit_section_config() {
 
 	# conf node name is selected based on dtb ID if it is present,
 	# otherwise its selected based on kernel ID
-	if [ -n "${dtb_image}" ]; then
-		conf_node=$conf_node${dtb_image}
+	if [ -n "$dtb_image" ]; then
+		conf_node=$conf_node$dtb_image
 	else
-		conf_node=$conf_node${kernel_id}
+		conf_node=$conf_node$kernel_id
 	fi
 
-	if [ -n "${kernel_id}" ]; then
+	if [ -n "$kernel_id" ]; then
 		conf_desc="Linux kernel"
 		sep=", "
-		kernel_line="kernel = \"kernel-${kernel_id}\";"
+		kernel_line="kernel = \"kernel-$kernel_id\";"
 	fi
 
-	if [ -n "${dtb_image}" ]; then
-		conf_desc="${conf_desc}${sep}FDT blob"
+	if [ -n "$dtb_image" ]; then
+		conf_desc="$conf_desc${sep}FDT blob"
 		sep=", "
-		fdt_line="fdt = \"fdt-${dtb_image}\";"
+		fdt_line="fdt = \"fdt-$dtb_image\";"
 	fi
 
-	if [ -n "${ramdisk_id}" ]; then
-		conf_desc="${conf_desc}${sep}ramdisk"
+	if [ -n "$ramdisk_id" ]; then
+		conf_desc="$conf_desc${sep}ramdisk"
 		sep=", "
-		ramdisk_line="ramdisk = \"ramdisk-${ramdisk_id}\";"
+		ramdisk_line="ramdisk = \"ramdisk-$ramdisk_id\";"
 	fi
 
-	if [ -n "${bootscr_id}" ]; then
-		conf_desc="${conf_desc}${sep}u-boot script"
+	if [ -n "$bootscr_id" ]; then
+		conf_desc="$conf_desc${sep}u-boot script"
 		sep=", "
-		bootscr_line="bootscr = \"bootscr-${bootscr_id}\";"
+		bootscr_line="bootscr = \"bootscr-$bootscr_id\";"
 	fi
 
-	if [ -n "${config_id}" ]; then
-		conf_desc="${conf_desc}${sep}setup"
-		setup_line="setup = \"setup-${config_id}\";"
+	if [ -n "$config_id" ]; then
+		conf_desc="$conf_desc${sep}setup"
+		setup_line="setup = \"setup-$config_id\";"
 	fi
 
-	if [ "${default_flag}" = "1" ]; then
+	if [ "$default_flag" = "1" ]; then
 		# default node is selected based on dtb ID if it is present,
 		# otherwise its selected based on kernel ID
-		if [ -n "${dtb_image}" ]; then
-			default_line="default = \"conf-${dtb_image}\";"
+		if [ -n "$dtb_image" ]; then
+			default_line="default = \"conf-$dtb_image\";"
 		else
-			default_line="default = \"conf-${kernel_id}\";"
+			default_line="default = \"conf-$kernel_id\";"
 		fi
 	fi
 
-	cat << EOF >> ${its_file}
-                ${default_line}
+	cat << EOF >> $its_file
+                $default_line
                 $conf_node {
-			description = "${default_flag} ${conf_desc}";
-			${kernel_line}
-			${fdt_line}
-			${ramdisk_line}
-			${bootscr_line}
-			${setup_line}
+                        description = "$default_flag $conf_desc";
+                        $kernel_line
+                        $fdt_line
+                        $ramdisk_line
+                        $bootscr_line
+                        $setup_line
                         hash-1 {
-                                algo = "${conf_csum}";
+                                algo = "$conf_csum";
                         };
 EOF
 
-	if [ ! -z "${conf_sign_keyname}" ] ; then
+	if [ -n "$conf_sign_keyname" ] ; then
 
 		sign_line="sign-images = "
 		sep=""
 
-		if [ -n "${kernel_id}" ]; then
-			sign_line="${sign_line}${sep}\"kernel\""
+		if [ -n "$kernel_id" ]; then
+			sign_line="$sign_line${sep}\"kernel\""
 			sep=", "
 		fi
 
-		if [ -n "${dtb_image}" ]; then
-			sign_line="${sign_line}${sep}\"fdt\""
+		if [ -n "$dtb_image" ]; then
+			sign_line="$sign_line${sep}\"fdt\""
 			sep=", "
 		fi
 
-		if [ -n "${ramdisk_id}" ]; then
-			sign_line="${sign_line}${sep}\"ramdisk\""
+		if [ -n "$ramdisk_id" ]; then
+			sign_line="$sign_line${sep}\"ramdisk\""
 			sep=", "
 		fi
 
-		if [ -n "${bootscr_id}" ]; then
-			sign_line="${sign_line}${sep}\"bootscr\""
+		if [ -n "$bootscr_id" ]; then
+			sign_line="$sign_line${sep}\"bootscr\""
 			sep=", "
 		fi
 
-		if [ -n "${config_id}" ]; then
-			sign_line="${sign_line}${sep}\"setup\""
+		if [ -n "$config_id" ]; then
+			sign_line="$sign_line${sep}\"setup\""
 		fi
 
-		sign_line="${sign_line};"
+		sign_line="$sign_line;"
 
-		cat << EOF >> ${its_file}
+		cat << EOF >> $its_file
                         signature-1 {
-                                algo = "${conf_csum},${conf_sign_algo}";
-                                key-name-hint = "${conf_sign_keyname}";
-				${sign_line}
+                                algo = "$conf_csum,$conf_sign_algo";
+                                key-name-hint = "$conf_sign_keyname";
+                                $sign_line
                         };
 EOF
 	fi
 
-	cat << EOF >> ${its_file}
+	cat << EOF >> $its_file
                 };
 EOF
 }
@@ -478,38 +478,38 @@ fitimage_assemble() {
 	kernelcount=1
 	dtbcount=""
 	DTBS=""
-	ramdiskcount=${3}
+	ramdiskcount=$3
 	setupcount=""
 	bootscr_id=""
-	rm -f ${1} arch/${ARCH}/boot/${2}
+	rm -f $1 arch/${ARCH}/boot/$2
 
-	if [ ! -z "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
+	if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
 		bbfatal "Keys used to sign images and configuration nodes must be different."
 	fi
 
-	fitimage_emit_fit_header ${1}
+	fitimage_emit_fit_header $1
 
 	#
 	# Step 1: Prepare a kernel image section.
 	#
-	fitimage_emit_section_maint ${1} imagestart
+	fitimage_emit_section_maint $1 imagestart
 
 	uboot_prep_kimage
 
 	if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
 		initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
-		if [ -e "${initramfs_bundle_path}" ]; then
+		if [ -e "$initramfs_bundle_path" ]; then
 
 			#
 			# Include the kernel/rootfs bundle.
 			#
 
-			fitimage_emit_section_kernel ${1} "${kernelcount}" "${initramfs_bundle_path}" "${linux_comp}"
+			fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
 		else
-			bbwarn "${initramfs_bundle_path} not found."
+			bbwarn "$initramfs_bundle_pat not found."
 		fi
 	else
-		fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}"
+		fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
 	fi
 
 	#
@@ -519,9 +519,9 @@ fitimage_assemble() {
 	if [ -n "${KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in ${KERNEL_DEVICETREE}; do
-			if echo ${DTB} | grep -q '/dts/'; then
-				bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
-				DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
+			if echo $DTB | grep -q '/dts/'; then
+				bbwarn "$DTB contains the full path to the the dts file, but only the dtb name should be used."
+				DTB=`basename $DTB | sed 's,\.dts$,.dtb,g'`
 			fi
 
 			# Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE}
@@ -529,23 +529,23 @@ fitimage_assemble() {
 				continue
 			fi
 
-			DTB_PATH="arch/${ARCH}/boot/dts/${DTB}"
-			if [ ! -e "${DTB_PATH}" ]; then
-				DTB_PATH="arch/${ARCH}/boot/${DTB}"
+			DTB_PATH="arch/${ARCH}/boot/dts/$DTB"
+			if [ ! -e "$DTB_PATH" ]; then
+				DTB_PATH="arch/${ARCH}/boot/$DTB"
 			fi
 
-			DTB=$(echo "${DTB}" | tr '/' '_')
-			DTBS="${DTBS} ${DTB}"
-			fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH}
+			DTB=$(echo "$DTB" | tr '/' '_')
+			DTBS="$DTBS $DTB"
+			fitimage_emit_section_dtb $1 $DTB $DTB_PATH
 		done
 	fi
 
 	if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do
-			DTB=$(echo "${DTB}" | tr '/' '_')
-			DTBS="${DTBS} ${DTB}"
-			fitimage_emit_section_dtb ${1} ${DTB} "${EXTERNAL_KERNEL_DEVICETREE}/${DTB}"
+			DTB=$(echo "$DTB" | tr '/' '_')
+			DTBS="$DTBS $DTB"
+			fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB"
 		done
 	fi
 
@@ -557,7 +557,7 @@ fitimage_assemble() {
 		if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then
 			cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B}
 			bootscr_id="${UBOOT_ENV_BINARY}"
-			fitimage_emit_section_boot_script ${1} "${bootscr_id}" ${UBOOT_ENV_BINARY}
+			fitimage_emit_section_boot_script $1 "$bootscr_id" ${UBOOT_ENV_BINARY}
 		else
 			bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found."
 		fi
@@ -568,7 +568,7 @@ fitimage_assemble() {
 	#
 	if [ -e arch/${ARCH}/boot/setup.bin ]; then
 		setupcount=1
-		fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin
+		fitimage_emit_section_setup $1 $setupcount arch/${ARCH}/boot/setup.bin
 	fi
 
 	#
@@ -577,27 +577,30 @@ fitimage_assemble() {
 	if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
 		# Find and use the first initramfs image archive type we find
 		for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio; do
-			initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}"
-			echo "Using $initramfs_path"
-			if [ -e "${initramfs_path}" ]; then
-				fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}"
+			initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img"
+			echo -n "Searching for $initramfs_path..."
+			if [ -e "$initramfs_path" ]; then
+				echo "found"
+				fitimage_emit_section_ramdisk $1 "$ramdiskcount" "$initramfs_path"
 				break
+			else
+				echo "not found"
 			fi
 		done
 	fi
 
-	fitimage_emit_section_maint ${1} sectend
+	fitimage_emit_section_maint $1 sectend
 
 	# Force the first Kernel and DTB in the default config
 	kernelcount=1
-	if [ -n "${dtbcount}" ]; then
+	if [ -n "$dtbcount" ]; then
 		dtbcount=1
 	fi
 
 	#
 	# Step 6: Prepare a configurations section
 	#
-	fitimage_emit_section_maint ${1} confstart
+	fitimage_emit_section_maint $1 confstart
 
 	# kernel-fitimage.bbclass currently only supports a single kernel (no less or
 	# more) to be added to the FIT image along with 0 or more device trees and
@@ -608,33 +611,33 @@ fitimage_assemble() {
 	# the default configuration to be used is based on the dtbcount. If there is
 	# no dtb present than select the default configuation to be based on
 	# the kernelcount.
-	if [ -n "${DTBS}" ]; then
+	if [ -n "$DTBS" ]; then
 		i=1
 		for DTB in ${DTBS}; do
 			dtb_ext=${DTB##*.}
-			if [ "${dtb_ext}" = "dtbo" ]; then
-				fitimage_emit_section_config ${1} "" "${DTB}" "" "${bootscr_id}" "" "`expr ${i} = ${dtbcount}`"
+			if [ "$dtb_ext" = "dtbo" ]; then
+				fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`"
 			else
-				fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "`expr ${i} = ${dtbcount}`"
+				fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`"
 			fi
-			i=`expr ${i} + 1`
+			i=`expr $i + 1`
 		done
 	else
 		defaultconfigcount=1
-		fitimage_emit_section_config ${1} "${kernelcount}" "" "${ramdiskcount}" "${bootscr_id}"  "${setupcount}" "${defaultconfigcount}"
+		fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id"  "$setupcount" $defaultconfigcount
 	fi
 
-	fitimage_emit_section_maint ${1} sectend
+	fitimage_emit_section_maint $1 sectend
 
-	fitimage_emit_section_maint ${1} fitend
+	fitimage_emit_section_maint $1 fitend
 
 	#
 	# Step 7: Assemble the image
 	#
 	${UBOOT_MKIMAGE} \
 		${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
-		-f ${1} \
-		arch/${ARCH}/boot/${2}
+		-f $1 \
+		arch/${ARCH}/boot/$2
 
 	#
 	# Step 8: Sign the image and add public key to U-Boot dtb
@@ -651,7 +654,7 @@ fitimage_assemble() {
 			${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
 			-F -k "${UBOOT_SIGN_KEYDIR}" \
 			$add_key_to_u_boot \
-			-r arch/${ARCH}/boot/${2} \
+			-r arch/${ARCH}/boot/$2 \
 			${UBOOT_MKIMAGE_SIGN_ARGS}
 	fi
 }
@@ -659,7 +662,7 @@ fitimage_assemble() {
 do_assemble_fitimage() {
 	if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
 		cd ${B}
-		fitimage_assemble fit-image.its fitImage
+		fitimage_assemble fit-image.its fitImage ""
 	fi
 }
 
meta/classes/uboot-sign.bbclass +28 -28

135 lines not on this page · raw message

Signature · 1 line
2.31.1
#6 lore raw

PATCH v3 2/2 kernel-fitimage: use correct kernel image

In reply to Andrej Valek

Even if initramfs_bundle_path was used, a wrong compression was reflected in output its template file. Use linux.bin as universal kernel image. The linux.bin file covers both cases.

Use linux.bin as a replacement for zImage in selftest. We know, that zImage is a compressed one, so get the compression type.

---
 meta/classes/kernel-fitimage.bbclass     | 17 +----------------
 meta/lib/oeqa/selftest/cases/fitimage.py |  8 +++-----
 2 files changed, 4 insertions(+), 21 deletions(-)
meta/classes/kernel-fitimage.bbclass +1 -16
index 886ed13029..8718ce7e16 100644
@@ -495,22 +495,7 @@ fitimage_assemble() {
 	fitimage_emit_section_maint $1 imagestart
 
 	uboot_prep_kimage
-
-	if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
-		initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
-		if [ -e "$initramfs_bundle_path" ]; then
-
-			#
-			# Include the kernel/rootfs bundle.
-			#
-
-			fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
-		else
-			bbwarn "$initramfs_bundle_pat not found."
-		fi
-	else
-		fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
-	fi
+	fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
 
 	#
 	# Step 2: Prepare a DTB image section
meta/lib/oeqa/selftest/cases/fitimage.py +3 -5
index 184c8778d2..39c1cf9dd1 100644
@@ -741,7 +741,6 @@ UBOOT_ARCH = "arm"
 UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000"
 UBOOT_EXTLINUX = "0"
 FIT_GENERATE_KEYS = "1"
-KERNEL_IMAGETYPE_REPLACEMENT = "zImage"
 FIT_HASH_ALG = "sha256"
 """
         self.write_config(config)
@@ -763,9 +762,8 @@ FIT_HASH_ALG = "sha256"
 
         kernel_load = str(get_bb_var('UBOOT_LOADADDRESS'))
         kernel_entry = str(get_bb_var('UBOOT_ENTRYPOINT'))
-        initramfs_bundle_format = str(get_bb_var('KERNEL_IMAGETYPE_REPLACEMENT'))
+        kernel_compression = str(get_bb_var('FIT_KERNEL_COMP_ALG'))
         uboot_arch = str(get_bb_var('UBOOT_ARCH'))
-        initramfs_bundle = "arch/" + uboot_arch + "/boot/" + initramfs_bundle_format + ".initramfs"
         fit_hash_alg = str(get_bb_var('FIT_HASH_ALG'))
 
         its_file = open(fitimage_its_path)
@@ -775,11 +773,11 @@ FIT_HASH_ALG = "sha256"
         exp_node_lines = [
             'kernel-1 {',
             'description = "Linux kernel";',
-            'data = /incbin/("' + initramfs_bundle + '");',
+            'data = /incbin/("linux.bin");',
             'type = "kernel";',
             'arch = "' + uboot_arch + '";',
             'os = "linux";',
-            'compression = "none";',
+            'compression = "' + kernel_compression + '";',
             'load = <' + kernel_load + '>;',
             'entry = <' + kernel_entry + '>;',
             'hash-1 {',
Signature · 1 line
2.31.1
#7 lore raw

Re: [OE-core][PATCH v3 2/2] kernel-fitimage: use correct kernel image

Hello Andrej,

Quoted 4 lines · Andrej Valek

Even if initramfs_bundle_path was used, a wrong compression was reflected in output its template file. Use linux.bin as universal kernel image. The linux.bin file covers both cases.

Quoted 8 lines

Use linux.bin as a replacement for zImage in selftest. We know, that zImage is a compressed one, so get the compression type.

---
 meta/classes/kernel-fitimage.bbclass     | 17 +----------------
 meta/lib/oeqa/selftest/cases/fitimage.py |  8 +++-----

This still caused issues on the autobuilders:

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/2710/steps/15/logs/stdio

2021-10-15 17:23:26,867 - oe-selftest - INFO - fitimage.FitImageTests.test_initramfs_bundle (subunit.RemotedTestCase)
2021-10-15 17:23:26,868 - oe-selftest - INFO -  ... FAIL
Stderr:
2021-10-15 14:30:44,854 - oe-selftest - INFO - Adding: "include selftest.inc" in /home/pokybuild/yocto-worker/oe-selftest-centos/build/build-st-7047/conf/local.conf
2021-10-15 14:30:44,854 - oe-selftest - INFO - Adding: "include bblayers.inc" in bblayers.conf
2021-10-15 17:23:26,868 - oe-selftest - INFO - 10: 3/13 391/444 (6177.79s) (fitimage.FitImageTests.test_initramfs_bundle)
2021-10-15 17:23:26,868 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oeqa/selftest/cases/fitimage.py", line 801, in test_initramfs_bundle
    self.assertTrue(test_passed == True,"kernel node does not match expectation")
  File "/home/pokybuild/yocto-worker/oe-selftest-centos/build/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/python3.9/unittest/case.py", line 682, in assertTrue
    raise self.failureException(msg)

AssertionError: False is not true : kernel node does not match expectation

https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/2686/steps/14/logs/stdio

2021-10-15 15:51:53,829 - oe-selftest - INFO - fitimage.FitImageTests.test_initramfs_bundle (subunit.RemotedTestCase)
2021-10-15 15:51:53,830 - oe-selftest - INFO -  ... FAIL
2021-10-15 15:51:53,830 - oe-selftest - INFO - 10: 3/13 339/444 (525.77s) (fitimage.FitImageTests.test_initramfs_bundle)
2021-10-15 15:51:53,830 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/lib/oeqa/selftest/cases/fitimage.py", line 801, in test_initramfs_bundle
    self.assertTrue(test_passed == True,"kernel node does not match expectation")
  File "/usr/lib/python3.7/unittest/case.py", line 692, in assertTrue
    raise self.failureException(msg)

AssertionError: False is not true : kernel node does not match expectation

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#8 lore raw

PATCH v4 1/2 featimage: refactor style

In reply to Andrej Valek

- use bash variable notation without {} where possible
- just to make sure it looks like bash variable not bitbake variable one
- fix indent style in "cat" commands
- replace "! -z" -> "-n"
- make debug info in ramdisk section creation more verbose

---
 meta/classes/kernel-fitimage.bbclass | 297 ++++++++++++++-------------
 meta/classes/uboot-sign.bbclass      |  56 ++---
 2 files changed, 178 insertions(+), 175 deletions(-)
meta/classes/kernel-fitimage.bbclass +150 -147
index 38e05153e3..886ed13029 100644
@@ -73,7 +73,7 @@ FIT_SIGN_INDIVIDUAL ?= "0"
 #
 # $1 ... .its filename
 fitimage_emit_fit_header() {
-	cat << EOF >> ${1}
+	cat << EOF >> $1
 /dts-v1/;
 
 / {
@@ -94,24 +94,24 @@ EOF
 fitimage_emit_section_maint() {
 	case $2 in
 	imagestart)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 
         images {
 EOF
 	;;
 	confstart)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 
         configurations {
 EOF
 	;;
 	sectend)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 	};
 EOF
 	;;
 	fitend)
-		cat << EOF >> ${1}
+		cat << EOF >> $1
 };
 EOF
 	;;
@@ -137,28 +137,28 @@ fitimage_emit_section_kernel() {
 			awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
 	fi
 
-	cat << EOF >> ${1}
-                kernel-${2} {
+	cat << EOF >> $1
+                kernel-$2 {
                         description = "Linux kernel";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "kernel";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
-                        compression = "${4}";
+                        compression = "$4";
                         load = <${UBOOT_LOADADDRESS}>;
-                        entry = <${ENTRYPOINT}>;
+                        entry = <$ENTRYPOINT>;
                         hash-1 {
-                                algo = "${kernel_csum}";
+                                algo = "$kernel_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${kernel_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$kernel_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${kernel_csum},${kernel_sign_algo}";
-                                key-name-hint = "${kernel_sign_keyname}";
+                                algo = "$kernel_csum,$kernel_sign_algo";
+                                key-name-hint = "$kernel_sign_keyname";
                         };
                 };
 EOF
@@ -186,26 +186,26 @@ fitimage_emit_section_dtb() {
 	elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then
 		dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;"
 	fi
-	cat << EOF >> ${1}
-                fdt-${2} {
+	cat << EOF >> $1
+                fdt-$2 {
                         description = "Flattened Device Tree blob";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "flat_dt";
                         arch = "${UBOOT_ARCH}";
                         compression = "none";
-                        ${dtb_loadline}
+                        $dtb_loadline
                         hash-1 {
-                                algo = "${dtb_csum}";
+                                algo = "$dtb_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${dtb_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$dtb_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${dtb_csum},${dtb_sign_algo}";
-                                key-name-hint = "${dtb_sign_keyname}";
+                                algo = "$dtb_csum,$dtb_sign_algo";
+                                key-name-hint = "$dtb_sign_keyname";
                         };
                 };
 EOF
@@ -220,29 +220,29 @@ EOF
 # $3 ... Path to boot script image
 fitimage_emit_section_boot_script() {
 
-        bootscr_csum="${FIT_HASH_ALG}"
+	bootscr_csum="${FIT_HASH_ALG}"
 	bootscr_sign_algo="${FIT_SIGN_ALG}"
 	bootscr_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}"
 
-        cat << EOF >> ${1}
-                bootscr-${2} {
+        cat << EOF >> $1
+                bootscr-$2 {
                         description = "U-boot script";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "script";
                         arch = "${UBOOT_ARCH}";
                         compression = "none";
                         hash-1 {
-                                algo = "${bootscr_csum}";
+                                algo = "$bootscr_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${bootscr_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$bootscr_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${bootscr_csum},${bootscr_sign_algo}";
-                                key-name-hint = "${bootscr_sign_keyname}";
+                                algo = "$bootscr_csum,$bootscr_sign_algo";
+                                key-name-hint = "$bootscr_sign_keyname";
                         };
                 };
 EOF
@@ -259,10 +259,10 @@ fitimage_emit_section_setup() {
 
 	setup_csum="${FIT_HASH_ALG}"
 
-	cat << EOF >> ${1}
-                setup-${2} {
+	cat << EOF >> $1
+                setup-$2 {
                         description = "Linux setup.bin";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "x86_setup";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
@@ -270,7 +270,7 @@ fitimage_emit_section_setup() {
                         load = <0x00090000>;
                         entry = <0x00090000>;
                         hash-1 {
-                                algo = "${setup_csum}";
+                                algo = "$setup_csum";
                         };
                 };
 EOF
@@ -297,28 +297,28 @@ fitimage_emit_section_ramdisk() {
 		ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
 	fi
 
-	cat << EOF >> ${1}
-                ramdisk-${2} {
+	cat << EOF >> $1
+                ramdisk-$2 {
                         description = "${INITRAMFS_IMAGE}";
-                        data = /incbin/("${3}");
+                        data = /incbin/("$3");
                         type = "ramdisk";
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
                         compression = "none";
-                        ${ramdisk_loadline}
-                        ${ramdisk_entryline}
+                        $ramdisk_loadline
+                        $ramdisk_entryline
                         hash-1 {
-                                algo = "${ramdisk_csum}";
+                                algo = "$ramdisk_csum";
                         };
                 };
 EOF
 
-	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${ramdisk_sign_keyname}" ] ; then
-		sed -i '$ d' ${1}
-		cat << EOF >> ${1}
+	if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$ramdisk_sign_keyname" ] ; then
+		sed -i '$ d' $1
+		cat << EOF >> $1
                         signature-1 {
-                                algo = "${ramdisk_csum},${ramdisk_sign_algo}";
-                                key-name-hint = "${ramdisk_sign_keyname}";
+                                algo = "$ramdisk_csum,$ramdisk_sign_algo";
+                                key-name-hint = "$ramdisk_sign_keyname";
                         };
                 };
 EOF
@@ -343,13 +343,13 @@ fitimage_emit_section_config() {
 		conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
 	fi
 
-	its_file="${1}"
-	kernel_id="${2}"
-	dtb_image="${3}"
-	ramdisk_id="${4}"
-	bootscr_id="${5}"
-	config_id="${6}"
-	default_flag="${7}"
+	its_file="$1"
+	kernel_id="$2"
+	dtb_image="$3"
+	ramdisk_id="$4"
+	bootscr_id="$5"
+	config_id="$6"
+	default_flag="$7"
 
 	# Test if we have any DTBs at all
 	sep=""
@@ -364,106 +364,106 @@ fitimage_emit_section_config() {
 
 	# conf node name is selected based on dtb ID if it is present,
 	# otherwise its selected based on kernel ID
-	if [ -n "${dtb_image}" ]; then
-		conf_node=$conf_node${dtb_image}
+	if [ -n "$dtb_image" ]; then
+		conf_node=$conf_node$dtb_image
 	else
-		conf_node=$conf_node${kernel_id}
+		conf_node=$conf_node$kernel_id
 	fi
 
-	if [ -n "${kernel_id}" ]; then
+	if [ -n "$kernel_id" ]; then
 		conf_desc="Linux kernel"
 		sep=", "
-		kernel_line="kernel = \"kernel-${kernel_id}\";"
+		kernel_line="kernel = \"kernel-$kernel_id\";"
 	fi
 
-	if [ -n "${dtb_image}" ]; then
-		conf_desc="${conf_desc}${sep}FDT blob"
+	if [ -n "$dtb_image" ]; then
+		conf_desc="$conf_desc${sep}FDT blob"
 		sep=", "
-		fdt_line="fdt = \"fdt-${dtb_image}\";"
+		fdt_line="fdt = \"fdt-$dtb_image\";"
 	fi
 
-	if [ -n "${ramdisk_id}" ]; then
-		conf_desc="${conf_desc}${sep}ramdisk"
+	if [ -n "$ramdisk_id" ]; then
+		conf_desc="$conf_desc${sep}ramdisk"
 		sep=", "
-		ramdisk_line="ramdisk = \"ramdisk-${ramdisk_id}\";"
+		ramdisk_line="ramdisk = \"ramdisk-$ramdisk_id\";"
 	fi
 
-	if [ -n "${bootscr_id}" ]; then
-		conf_desc="${conf_desc}${sep}u-boot script"
+	if [ -n "$bootscr_id" ]; then
+		conf_desc="$conf_desc${sep}u-boot script"
 		sep=", "
-		bootscr_line="bootscr = \"bootscr-${bootscr_id}\";"
+		bootscr_line="bootscr = \"bootscr-$bootscr_id\";"
 	fi
 
-	if [ -n "${config_id}" ]; then
-		conf_desc="${conf_desc}${sep}setup"
-		setup_line="setup = \"setup-${config_id}\";"
+	if [ -n "$config_id" ]; then
+		conf_desc="$conf_desc${sep}setup"
+		setup_line="setup = \"setup-$config_id\";"
 	fi
 
-	if [ "${default_flag}" = "1" ]; then
+	if [ "$default_flag" = "1" ]; then
 		# default node is selected based on dtb ID if it is present,
 		# otherwise its selected based on kernel ID
-		if [ -n "${dtb_image}" ]; then
-			default_line="default = \"conf-${dtb_image}\";"
+		if [ -n "$dtb_image" ]; then
+			default_line="default = \"conf-$dtb_image\";"
 		else
-			default_line="default = \"conf-${kernel_id}\";"
+			default_line="default = \"conf-$kernel_id\";"
 		fi
 	fi
 
-	cat << EOF >> ${its_file}
-                ${default_line}
+	cat << EOF >> $its_file
+                $default_line
                 $conf_node {
-			description = "${default_flag} ${conf_desc}";
-			${kernel_line}
-			${fdt_line}
-			${ramdisk_line}
-			${bootscr_line}
-			${setup_line}
+                        description = "$default_flag $conf_desc";
+                        $kernel_line
+                        $fdt_line
+                        $ramdisk_line
+                        $bootscr_line
+                        $setup_line
                         hash-1 {
-                                algo = "${conf_csum}";
+                                algo = "$conf_csum";
                         };
 EOF
 
-	if [ ! -z "${conf_sign_keyname}" ] ; then
+	if [ -n "$conf_sign_keyname" ] ; then
 
 		sign_line="sign-images = "
 		sep=""
 
-		if [ -n "${kernel_id}" ]; then
-			sign_line="${sign_line}${sep}\"kernel\""
+		if [ -n "$kernel_id" ]; then
+			sign_line="$sign_line${sep}\"kernel\""
 			sep=", "
 		fi
 
-		if [ -n "${dtb_image}" ]; then
-			sign_line="${sign_line}${sep}\"fdt\""
+		if [ -n "$dtb_image" ]; then
+			sign_line="$sign_line${sep}\"fdt\""
 			sep=", "
 		fi
 
-		if [ -n "${ramdisk_id}" ]; then
-			sign_line="${sign_line}${sep}\"ramdisk\""
+		if [ -n "$ramdisk_id" ]; then
+			sign_line="$sign_line${sep}\"ramdisk\""
 			sep=", "
 		fi
 
-		if [ -n "${bootscr_id}" ]; then
-			sign_line="${sign_line}${sep}\"bootscr\""
+		if [ -n "$bootscr_id" ]; then
+			sign_line="$sign_line${sep}\"bootscr\""
 			sep=", "
 		fi
 
-		if [ -n "${config_id}" ]; then
-			sign_line="${sign_line}${sep}\"setup\""
+		if [ -n "$config_id" ]; then
+			sign_line="$sign_line${sep}\"setup\""
 		fi
 
-		sign_line="${sign_line};"
+		sign_line="$sign_line;"
 
-		cat << EOF >> ${its_file}
+		cat << EOF >> $its_file
                         signature-1 {
-                                algo = "${conf_csum},${conf_sign_algo}";
-                                key-name-hint = "${conf_sign_keyname}";
-				${sign_line}
+                                algo = "$conf_csum,$conf_sign_algo";
+                                key-name-hint = "$conf_sign_keyname";
+                                $sign_line
                         };
 EOF
 	fi
 
-	cat << EOF >> ${its_file}
+	cat << EOF >> $its_file
                 };
 EOF
 }
@@ -478,38 +478,38 @@ fitimage_assemble() {
 	kernelcount=1
 	dtbcount=""
 	DTBS=""
-	ramdiskcount=${3}
+	ramdiskcount=$3
 	setupcount=""
 	bootscr_id=""
-	rm -f ${1} arch/${ARCH}/boot/${2}
+	rm -f $1 arch/${ARCH}/boot/$2
 
-	if [ ! -z "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
+	if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
 		bbfatal "Keys used to sign images and configuration nodes must be different."
 	fi
 
-	fitimage_emit_fit_header ${1}
+	fitimage_emit_fit_header $1
 
 	#
 	# Step 1: Prepare a kernel image section.
 	#
-	fitimage_emit_section_maint ${1} imagestart
+	fitimage_emit_section_maint $1 imagestart
 
 	uboot_prep_kimage
 
 	if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
 		initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
-		if [ -e "${initramfs_bundle_path}" ]; then
+		if [ -e "$initramfs_bundle_path" ]; then
 
 			#
 			# Include the kernel/rootfs bundle.
 			#
 
-			fitimage_emit_section_kernel ${1} "${kernelcount}" "${initramfs_bundle_path}" "${linux_comp}"
+			fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
 		else
-			bbwarn "${initramfs_bundle_path} not found."
+			bbwarn "$initramfs_bundle_pat not found."
 		fi
 	else
-		fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}"
+		fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
 	fi
 
 	#
@@ -519,9 +519,9 @@ fitimage_assemble() {
 	if [ -n "${KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in ${KERNEL_DEVICETREE}; do
-			if echo ${DTB} | grep -q '/dts/'; then
-				bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
-				DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
+			if echo $DTB | grep -q '/dts/'; then
+				bbwarn "$DTB contains the full path to the the dts file, but only the dtb name should be used."
+				DTB=`basename $DTB | sed 's,\.dts$,.dtb,g'`
 			fi
 
 			# Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE}
@@ -529,23 +529,23 @@ fitimage_assemble() {
 				continue
 			fi
 
-			DTB_PATH="arch/${ARCH}/boot/dts/${DTB}"
-			if [ ! -e "${DTB_PATH}" ]; then
-				DTB_PATH="arch/${ARCH}/boot/${DTB}"
+			DTB_PATH="arch/${ARCH}/boot/dts/$DTB"
+			if [ ! -e "$DTB_PATH" ]; then
+				DTB_PATH="arch/${ARCH}/boot/$DTB"
 			fi
 
-			DTB=$(echo "${DTB}" | tr '/' '_')
-			DTBS="${DTBS} ${DTB}"
-			fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH}
+			DTB=$(echo "$DTB" | tr '/' '_')
+			DTBS="$DTBS $DTB"
+			fitimage_emit_section_dtb $1 $DTB $DTB_PATH
 		done
 	fi
 
 	if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
 		dtbcount=1
 		for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do
-			DTB=$(echo "${DTB}" | tr '/' '_')
-			DTBS="${DTBS} ${DTB}"
-			fitimage_emit_section_dtb ${1} ${DTB} "${EXTERNAL_KERNEL_DEVICETREE}/${DTB}"
+			DTB=$(echo "$DTB" | tr '/' '_')
+			DTBS="$DTBS $DTB"
+			fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB"
 		done
 	fi
 
@@ -557,7 +557,7 @@ fitimage_assemble() {
 		if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then
 			cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B}
 			bootscr_id="${UBOOT_ENV_BINARY}"
-			fitimage_emit_section_boot_script ${1} "${bootscr_id}" ${UBOOT_ENV_BINARY}
+			fitimage_emit_section_boot_script $1 "$bootscr_id" ${UBOOT_ENV_BINARY}
 		else
 			bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found."
 		fi
@@ -568,7 +568,7 @@ fitimage_assemble() {
 	#
 	if [ -e arch/${ARCH}/boot/setup.bin ]; then
 		setupcount=1
-		fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin
+		fitimage_emit_section_setup $1 $setupcount arch/${ARCH}/boot/setup.bin
 	fi
 
 	#
@@ -577,27 +577,30 @@ fitimage_assemble() {
 	if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
 		# Find and use the first initramfs image archive type we find
 		for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio; do
-			initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}"
-			echo "Using $initramfs_path"
-			if [ -e "${initramfs_path}" ]; then
-				fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}"
+			initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img"
+			echo -n "Searching for $initramfs_path..."
+			if [ -e "$initramfs_path" ]; then
+				echo "found"
+				fitimage_emit_section_ramdisk $1 "$ramdiskcount" "$initramfs_path"
 				break
+			else
+				echo "not found"
 			fi
 		done
 	fi
 
-	fitimage_emit_section_maint ${1} sectend
+	fitimage_emit_section_maint $1 sectend
 
 	# Force the first Kernel and DTB in the default config
 	kernelcount=1
-	if [ -n "${dtbcount}" ]; then
+	if [ -n "$dtbcount" ]; then
 		dtbcount=1
 	fi
 
 	#
 	# Step 6: Prepare a configurations section
 	#
-	fitimage_emit_section_maint ${1} confstart
+	fitimage_emit_section_maint $1 confstart
 
 	# kernel-fitimage.bbclass currently only supports a single kernel (no less or
 	# more) to be added to the FIT image along with 0 or more device trees and
@@ -608,33 +611,33 @@ fitimage_assemble() {
 	# the default configuration to be used is based on the dtbcount. If there is
 	# no dtb present than select the default configuation to be based on
 	# the kernelcount.
-	if [ -n "${DTBS}" ]; then
+	if [ -n "$DTBS" ]; then
 		i=1
 		for DTB in ${DTBS}; do
 			dtb_ext=${DTB##*.}
-			if [ "${dtb_ext}" = "dtbo" ]; then
-				fitimage_emit_section_config ${1} "" "${DTB}" "" "${bootscr_id}" "" "`expr ${i} = ${dtbcount}`"
+			if [ "$dtb_ext" = "dtbo" ]; then
+				fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`"
 			else
-				fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "`expr ${i} = ${dtbcount}`"
+				fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`"
 			fi
-			i=`expr ${i} + 1`
+			i=`expr $i + 1`
 		done
 	else
 		defaultconfigcount=1
-		fitimage_emit_section_config ${1} "${kernelcount}" "" "${ramdiskcount}" "${bootscr_id}"  "${setupcount}" "${defaultconfigcount}"
+		fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id"  "$setupcount" $defaultconfigcount
 	fi
 
-	fitimage_emit_section_maint ${1} sectend
+	fitimage_emit_section_maint $1 sectend
 
-	fitimage_emit_section_maint ${1} fitend
+	fitimage_emit_section_maint $1 fitend
 
 	#
 	# Step 7: Assemble the image
 	#
 	${UBOOT_MKIMAGE} \
 		${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
-		-f ${1} \
-		arch/${ARCH}/boot/${2}
+		-f $1 \
+		arch/${ARCH}/boot/$2
 
 	#
 	# Step 8: Sign the image and add public key to U-Boot dtb
@@ -651,7 +654,7 @@ fitimage_assemble() {
 			${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
 			-F -k "${UBOOT_SIGN_KEYDIR}" \
 			$add_key_to_u_boot \
-			-r arch/${ARCH}/boot/${2} \
+			-r arch/${ARCH}/boot/$2 \
 			${UBOOT_MKIMAGE_SIGN_ARGS}
 	fi
 }
@@ -659,7 +662,7 @@ fitimage_assemble() {
 do_assemble_fitimage() {
 	if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
 		cd ${B}
-		fitimage_assemble fit-image.its fitImage
+		fitimage_assemble fit-image.its fitImage ""
 	fi
 }
 
meta/classes/uboot-sign.bbclass +28 -28

135 lines not on this page · raw message

Signature · 1 line
2.31.1
#9 lore raw

PATCH v4 2/2 kernel-fitimage: use correct kernel image

In reply to Andrej Valek

Even if initramfs_bundle_path was used, a wrong compression was reflected in output its template file. Use linux.bin as universal kernel image. The linux.bin file covers both cases because it's beying created from vmlinux.

We know, that vmlinux is created inside compressed directory already, so no external compression will be used.

---
 meta/classes/kernel-fitimage.bbclass     | 17 +----------------
 meta/lib/oeqa/selftest/cases/fitimage.py |  8 ++++----
 2 files changed, 5 insertions(+), 20 deletions(-)
meta/classes/kernel-fitimage.bbclass +1 -16
index 886ed13029..8718ce7e16 100644
@@ -495,22 +495,7 @@ fitimage_assemble() {
 	fitimage_emit_section_maint $1 imagestart
 
 	uboot_prep_kimage
-
-	if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
-		initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
-		if [ -e "$initramfs_bundle_path" ]; then
-
-			#
-			# Include the kernel/rootfs bundle.
-			#
-
-			fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
-		else
-			bbwarn "$initramfs_bundle_pat not found."
-		fi
-	else
-		fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
-	fi
+	fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
 
 	#
 	# Step 2: Prepare a DTB image section
meta/lib/oeqa/selftest/cases/fitimage.py +4 -4
index 184c8778d2..f6f6a8e795 100644
@@ -742,6 +742,7 @@ UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000"
 UBOOT_EXTLINUX = "0"
 FIT_GENERATE_KEYS = "1"
 KERNEL_IMAGETYPE_REPLACEMENT = "zImage"
+FIT_KERNEL_COMP_ALG = "none"
 FIT_HASH_ALG = "sha256"
 """
         self.write_config(config)
@@ -763,9 +764,8 @@ FIT_HASH_ALG = "sha256"
 
         kernel_load = str(get_bb_var('UBOOT_LOADADDRESS'))
         kernel_entry = str(get_bb_var('UBOOT_ENTRYPOINT'))
-        initramfs_bundle_format = str(get_bb_var('KERNEL_IMAGETYPE_REPLACEMENT'))
+        kernel_compression = str(get_bb_var('FIT_KERNEL_COMP_ALG'))
         uboot_arch = str(get_bb_var('UBOOT_ARCH'))
-        initramfs_bundle = "arch/" + uboot_arch + "/boot/" + initramfs_bundle_format + ".initramfs"
         fit_hash_alg = str(get_bb_var('FIT_HASH_ALG'))
 
         its_file = open(fitimage_its_path)
@@ -775,11 +775,11 @@ FIT_HASH_ALG = "sha256"
         exp_node_lines = [
             'kernel-1 {',
             'description = "Linux kernel";',
-            'data = /incbin/("' + initramfs_bundle + '");',
+            'data = /incbin/("linux.bin");',
             'type = "kernel";',
             'arch = "' + uboot_arch + '";',
             'os = "linux";',
-            'compression = "none";',
+            'compression = "' + kernel_compression + '";',
             'load = <' + kernel_load + '>;',
             'entry = <' + kernel_entry + '>;',
             'hash-1 {',
Signature · 1 line
2.31.1