Skip to contentSkip to conversation

kernel-fitimage: sanitize dtb section name (unbreak MIPS)

PATCH New André Draszik 1 participant 5 messages Sep 20, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 kernel-fitimage: sanitize dtb section name (unbreak MIPS)

From: André Draszik <[email protected]>

We can't build fitImages for MIPS any more:

| Error: fit-image.its:21.27-28 syntax error
| FATAL ERROR: Unable to parse input tree
| uboot-mkimage: Can't read arch/mips/boot/fitImage.tmp: Invalid argument

Since commit cd2ed7f80b555add07795cc0cbaee866e6c193a3 ("kernel-fitimage: dtb sections named by their filenames and one config section for each dtb"), commit 1ec405ef5df82884c8997878bbe6c66d924b5127 in yocto, dtb sections are named by the DTB filename, but the filename can legally be in a subdirectory below arch/$arch/boot/dts/, and on MIPS all DTBs are actually in a subdirectory.

If so, mkimage fails with the above error message.

Unbreak this by replacing the offending character (directory separator /)

---
 meta/classes/kernel-fitimage.bbclass | 1 +
 1 file changed, 1 insertion(+)
meta/classes/kernel-fitimage.bbclass +1 -0
index 2630b47316..6f1b7667bc 100644
@@ -351,6 +351,7 @@ fitimage_assemble() {
 				DTB_PATH="arch/${ARCH}/boot/${DTB}"
 			fi
 
+			DTB=$(echo "${DTB}" | tr '/' '_')
 			DTBS="${DTBS} ${DTB}"
 			fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH}
 		done
Signature · 1 line
2.14.1
#1 lore raw

PATCH 2/5 kernel-fitimage: unbreak UBOOT_ENTRYSYMBOL support

From: André Draszik <[email protected]>

- vmlinux is located in ${B}, not ${S}.
- parsing of nm output got broken completely in commit b406a89935f148779569fa3770776e009dd51f13 ("kernel-fitimage: add initramfs support"), commit ec755d2524fcbd9dfded23a576f25c990d405a6c in yocto

While at it, make awk exit on match to save a few CPU cycles.

---
 meta/classes/kernel-fitimage.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/kernel-fitimage.bbclass +2 -2
index 6f1b7667bc..5583b4472e 100644
@@ -97,8 +97,8 @@ fitimage_emit_section_kernel() {
 
 	ENTRYPOINT=${UBOOT_ENTRYPOINT}
 	if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then
-		ENTRYPOINT=`${HOST_PREFIX}nm ${S}/vmlinux | \
-			awk '$4=="${UBOOT_ENTRYSYMBOL}" {print $2}'`
+		ENTRYPOINT=`${HOST_PREFIX}nm vmlinux | \
+			awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
 	fi
 
 	cat << EOF >> ${1}
Signature · 1 line
2.14.1
#2 lore raw

PATCH 3/5 kernel-uimage: optimise UBOOT_ENTRYSYMBOL support

In reply to André Draszik

From: André Draszik <[email protected]>

This is the remaining local change to a fix similar to commit e0b4f018d1c2 ("kernel-uimage.bbclass: Fix up generation of uImage from vmlinux"):

Make awk exit on match to save a few CPU cycles so as to make this similar to kernel-fitimage.bbclass

---
 meta/classes/kernel-uimage.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel-uimage.bbclass +1 -1
index 7c026abf0b..1d8656e76e 100644
@@ -27,7 +27,7 @@ do_uboot_mkimage() {
 	ENTRYPOINT=${UBOOT_ENTRYPOINT}
 	if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then
 		ENTRYPOINT=`${HOST_PREFIX}nm ${B}/vmlinux | \
-			awk '$3=="${UBOOT_ENTRYSYMBOL}" {print $1}'`
+			awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
 	fi
 
 	uboot-mkimage -A ${UBOOT_ARCH} -O linux -T kernel -C "${linux_comp}" -a ${UBOOT_LOADADDRESS} -e $ENTRYPOINT -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin ${B}/arch/${ARCH}/boot/uImage
Signature · 1 line
2.14.1
#3 lore raw

PATCH 4/5 kernel-uboot: support compressed kernel on MIPS

In reply to André Draszik

From: André Draszik <[email protected]>

MIPS generates vmlinuz.bin when compression in the kernel build is enabled, including any necessary objcopy so we can leverage that and skip our manual invocation of objcopy here. We just have to put the file into the right place for the rest of the build to find it.

---
 meta/classes/kernel-uboot.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta/classes/kernel-uboot.bbclass +7 -1
index 868e97d7a7..87f02654fa 100644
@@ -3,13 +3,19 @@ uboot_prep_kimage() {
 		vmlinux_path="arch/${ARCH}/boot/compressed/vmlinux"
 		linux_suffix=""
 		linux_comp="none"
+	elif [ -e arch/${ARCH}/boot/vmlinuz.bin ]; then
+		rm -f linux.bin
+		cp -l arch/${ARCH}/boot/vmlinuz.bin linux.bin
+		vmlinux_path=""
+		linux_suffix=""
+		linux_comp="none"
 	else
 		vmlinux_path="vmlinux"
 		linux_suffix=".gz"
 		linux_comp="gzip"
 	fi
 
-	${OBJCOPY} -O binary -R .note -R .comment -S "${vmlinux_path}" linux.bin
+	[ -n "${vmlinux_path}" ] && ${OBJCOPY} -O binary -R .note -R .comment -S "${vmlinux_path}" linux.bin
 
 	if [ "${linux_comp}" != "none" ] ; then
 		gzip -9 linux.bin
Signature · 1 line
2.14.1
#4 lore raw

PATCH 5/5 kernel-fitimage: support MIPS (compressed)

In reply to André Draszik

From: André Draszik <[email protected]>

On MIPS, the compressed kernel image target is vmlinuz.bin

---
 meta/classes/kernel-fitimage.bbclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/classes/kernel-fitimage.bbclass +3 -1
index 5583b4472e..179185b6b2 100644
@@ -7,7 +7,9 @@ python __anonymous () {
         depends = "%s u-boot-mkimage-native dtc-native" % depends
         d.setVar("DEPENDS", depends)
 
-        if d.getVar("UBOOT_ARCH") == "x86":
+        if d.getVar("UBOOT_ARCH") == "mips":
+            replacementtype = "vmlinuz.bin"
+        elif d.getVar("UBOOT_ARCH") == "x86":
             replacementtype = "bzImage"
         else:
             replacementtype = "zImage"
Signature · 1 line
2.14.1