Skip to contentSkip to conversation

Revert "kernel-fitimage: move ramdisk section right after kernel to fix u-boot loading"

PATCH New Denys Dmytriyenko 1 participant 2 messages Oct 3, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Revert "kernel-fitimage: move ramdisk section right after kernel to fix u-boot loading"

From: Denys Dmytriyenko <[email protected]>

This reverts commit 030b6607ee4ef781f1150908e6d1f05fea29dc91.

---
 meta-arago-distro/classes/kernel-fitimage.bbclass | 32 +++++++++++------------
 1 file changed, 16 insertions(+), 16 deletions(-)
meta-arago-distro/classes/kernel-fitimage.bbclass +16 -16
index d9b9ff8..23b162b 100644
@@ -473,18 +473,7 @@ fitimage_assemble() {
 	fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin.sec "${linux_comp}"
 
 	#
-	# Step 2: Prepare a ramdisk section.
-	#
-	if [ "x${ramdiskcount}" = "x1" ] ; then
-		copy_initramfs
-		RAMDISK_FILE="usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio"
-		xz -f -k -c ${XZ_COMPRESSION_LEVEL} ${XZ_THREADS} --check=${XZ_INTEGRITY_CHECK} ${RAMDISK_FILE} > ${RAMDISK_FILE}.xz
-		fitimage_ti_secure ${RAMDISK_FILE}.xz ${RAMDISK_FILE}.xz.sec
-		fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" ${RAMDISK_FILE}.xz.sec
-	fi
-
-	#
-	# Step 3: Prepare a DTB image section
+	# Step 2: Prepare a DTB image section
 	#
 	if test -n "${KERNEL_DEVICETREE}"; then
 		dtbcount=1
@@ -511,7 +500,7 @@ fitimage_assemble() {
 	fi
 
 	#
-	# Step 4: Prepare OP/TEE image section
+	# Step 2a: Prepare OP/TEE image section
 	#
 	if test -n "${FITIMAGE_TEE}"; then
 		mkdir -p ${B}/usr
@@ -536,13 +525,24 @@ fitimage_assemble() {
 	fi
 
 	#
-	# Step 5: Prepare a setup section. (For x86)
+	# Step 3: Prepare a setup section. (For x86)
 	#
 	if test -e arch/${ARCH}/boot/setup.bin ; then
 		setupcount=1
 		fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin
 	fi
 
+	#
+	# Step 4: Prepare a ramdisk section.
+	#
+	if [ "x${ramdiskcount}" = "x1" ] ; then
+		copy_initramfs
+		RAMDISK_FILE="usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio"
+		xz -f -k -c ${XZ_COMPRESSION_LEVEL} ${XZ_THREADS} --check=${XZ_INTEGRITY_CHECK} ${RAMDISK_FILE} > ${RAMDISK_FILE}.xz
+		fitimage_ti_secure ${RAMDISK_FILE}.xz ${RAMDISK_FILE}.xz.sec
+		fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" ${RAMDISK_FILE}.xz.sec
+	fi
+
 	fitimage_emit_section_maint ${1} sectend
 
 	# Force the first Kernel and DTB in the default config
@@ -552,7 +552,7 @@ fitimage_assemble() {
 	fi
 
 	#
-	# Step 6: Prepare a configurations section
+	# Step 5: Prepare a configurations section
 	#
 	fitimage_emit_section_maint ${1} confstart
 
@@ -567,7 +567,7 @@ fitimage_assemble() {
 	fitimage_emit_section_maint ${1} fitend
 
 	#
-	# Step 7: Assemble the image
+	# Step 6: Assemble the image
 	#
 	uboot-mkimage \
 		${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 kernel-fitimage: expand FDT-to-TEE mapping, simplify code

From: Denys Dmytriyenko <[email protected]>

---
 meta-arago-distro/classes/kernel-fitimage.bbclass | 111 +++++++---------------
 1 file changed, 33 insertions(+), 78 deletions(-)
meta-arago-distro/classes/kernel-fitimage.bbclass +33 -78
index 23b162b..773c254 100644
@@ -296,16 +296,12 @@ fitimage_emit_section_config() {
 		conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
 	fi
 
-	# Test if we have any DTBs at all
-	if test -n "${FITIMAGE_TEE}"; then
-		conf_desc="Linux kernel, OPTEE OS Image"
-	else
-		conf_desc="Linux kernel"
-	fi
+	conf_desc="Linux kernel"
 	kernel_line="kernel = \"kernel@${2}\";"
 	fdt_line=""
 	ramdisk_line=""
 
+	# Test if we have any DTBs at all
 	if [ -n "${3}" ]; then
 		conf_desc="${conf_desc}, FDT blob"
 		fdt_line="fdt = \"${3}\";"
@@ -321,31 +317,47 @@ fitimage_emit_section_config() {
 		setup_line="setup = \"setup@${5}\";"
 	fi
 
-	if test -n "${FITIMAGE_TEE}"; then
-		teecount=1
-		for TEE in ${FITIMAGE_TEE}; do
-			DTB=`basename ${TEE} | sed 's,\.optee$,.dtb,g'`
+	dtbcount=1
+	for DTB in ${KERNEL_DEVICETREE}; do
 
-			if [ "x${FITIMAGE_CONF_BY_NAME}" = "x1" ] ; then
-				conf_name="${DTB}"
-			else
-				conf_name="conf@${teecount}"
-			fi
+		if [ "x${FITIMAGE_CONF_BY_NAME}" = "x1" ] ; then
+			conf_name="${DTB}"
+		else
+			conf_name="conf@${dtbcount}"
+		fi
 
-			if [ "x${teecount}" = "x1" ]; then
-				cat << EOF >> ${1}
+		if [ "x${dtbcount}" = "x1" ]; then
+			cat << EOF >> ${1}
                 default = "${conf_name}";
 EOF
-			fi
+		fi
+
+		if test -n "${FITIMAGE_TEE}"; then
+			teecount=1
+			for TEE in ${FITIMAGE_TEE}; do
+				teename=`basename ${TEE} ".optee"`
+				loadables_line=""
+				final_conf_desc="${conf_desc}"
+				if [ "${DTB#$teename}" != "${DTB}" ]; then
+					loadables_line="loadables = \"${TEE}\";"
+					final_conf_desc="${conf_desc}, OPTEE OS Image"
+					break
+				fi
+				teecount=`expr ${teecount} + 1`
+			done
+		else
+			loadables_line=""
+			final_conf_desc="${conf_desc}"
+		fi
 
 			cat << EOF >> ${1}
                 ${conf_name} {
-                        description = "${conf_desc}";
+                        description = "${final_conf_desc}";
                         ${kernel_line}
                         fdt = "${DTB}";
                         ${ramdisk_line}
                         ${setup_line}
-                        loadables = "${TEE}";
+                        ${loadables_line}
 EOF
 
 			if test -n "${FITIMAGE_HASH_ALGO}"; then
@@ -387,65 +399,8 @@ EOF
                 };
 EOF
 
-			teecount=`expr ${teecount} + 1`
+		dtbcount=`expr ${dtbcount} + 1`
 		done
-	else
-
-		if [ "x${FITIMAGE_CONF_BY_NAME}" = "x1" ] ; then
-			conf_name="${3}"
-		else
-			conf_name="conf@$1"
-		fi
-
-		cat << EOF >> ${1}
-                default = "${conf_name}";
-                ${conf_name} {
-                        description = "${conf_desc}";
-                        ${kernel_line}
-                        ${fdt_line}
-                        ${ramdisk_line}
-                        ${setup_line}
-EOF
-
-		if test -n "${FITIMAGE_HASH_ALGO}"; then
-			cat << EOF >> ${1}
-                        hash@1 {
-                                algo = "${conf_csum}";
-                        };
-EOF
-		fi
-
-		if [ ! -z "${conf_sign_keyname}" ] ; then
-
-			sign_line="sign-images = \"kernel\""
-
-			if [ -n "${3}" ]; then
-				sign_line="${sign_line}, \"fdt\""
-			fi
-
-			if [ -n "${4}" ]; then
-				sign_line="${sign_line}, \"ramdisk\""
-			fi
-
-			if [ -n "${5}" ]; then
-				sign_line="${sign_line}, \"setup\""
-			fi
-
-			sign_line="${sign_line};"
-
-			cat << EOF >> ${1}
-                        signature@1 {
-                                algo = "${conf_csum},rsa2048";
-                                key-name-hint = "${conf_sign_keyname}";
-                                ${sign_line}
-                        };
-EOF
-		fi
-
-		cat << EOF >> ${1}
-                };
-EOF
-	fi
 }
 
 #
Signature · 1 line
2.7.4