Skip to contentSkip to conversation

Routerstationpro: The size of the kernel image is too big

PATCH In review [email protected] 3 participants 5 messages Mar 28, 2013 – Apr 1, 2013

lore
Share & tools
lore
#0 lore raw

cover Routerstationpro: The size of the kernel image is too big

Hi Bruce, et al,

I'd previously sent a patch to the poky list which Richard Purdie has merged, commit 83716e40edacfd20dec8ef41f415ad5828d4643b:
"routerstationpro: use KERNEL_IMAGE_MAXSIZE to test the image"

The two patches here are for yocto #3515 and #3514.

I am sending a fourth patch (second?) to the poky list:
"routerstationpro: swap KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE"

I recommend that these three patches be applied in this order:
#3515
1. [OE-core] [PATCH 1/2] kernel.bbclass: omit vmlinux from rpm file when it is the alternative image
2. [poky] [PATCH 1/1] routerstationpro: swap KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE

#3514
3. [OE-core] [PATCH 2/2] kernel.bbclass: do_sizecheck: update path to build image and do not delete

When these three are merged then I would consider #3514 and #3515 closed.

Michel

#1 lore raw

PATCH 1/2 kernel.bbclass: omit vmlinux from rpm file when it is the alternative image

From: Michel Thebeau <[email protected]>

For routerstationpro, setting vmlinux as KERNEL_ALT_IMAGETYPE would cause both the default KERNEL_IMAGETYPE and the alternate to be inserted into the kernel rpm file. This is because copying "vmlinux" is hardcoded.

RSP is presently the only board that specifies vmlinux as the alternate image.

Testing KERNEL_ALT_IMAGETYPE to disable this install of vmlinux will cause the vmlinux output to not appear in the kernel rpm file.

[YOCTO #3515]

---
 meta/classes/kernel.bbclass |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
meta/classes/kernel.bbclass +8 -1
index d57d1f5..6f988e7 100644
@@ -111,7 +111,14 @@ kernel_do_install() {
 	install -m 0644 ${KERNEL_OUTPUT} ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}
 	install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
 	install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
-	install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION}
+
+	# if vmlinux is the alternate image type, then do not install it
+	# in the deployed rpm.  The default will install instead, above
+	# via the variable KERNEL_OUTPUT (KERNEL_IMAGETYPE)
+	if [ ! ${KERNEL_ALT_IMAGETYPE} == "vmlinux" ]; then
+		install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION}
+	fi
+
 	[ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION}
 	install -d ${D}${sysconfdir}/modules-load.d
 	install -d ${D}${sysconfdir}/modprobe.d
Signature · 1 line
1.7.9.7
#2 lore raw

PATCH 2/2 kernel.bbclass: do_sizecheck: update path to build image and do not delete

In reply to [email protected]

From: Michel Thebeau <[email protected]>

do_sizecheck has been around for a while but looks to have been unused. There are a few issues.

It breaks because KERNEL_OUTPUT is a path relative to ${B}, and resolves to a soft link to ${B}/${KERNEL_IMAGETYPE}. When do_sizecheck runs it does not find the file (because the working directory is elsewhere) and does not fail.

Also, when do_sizecheck deletes the oversized kernel image it leaves the previously run do_compile task with inaccurate status.

So, do the following:
- keep the oversized image file so the status of do_compile is valid
- specify the full path with ${B} to break the dependency on working directory
- test for the image file in two typical locations and print a "not supported" warning when it is not found
- finally, print a note that the size check was run successfully

[YOCTO #3514]

---
 meta/classes/kernel.bbclass |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
meta/classes/kernel.bbclass +21 -4
index 6f988e7..d25d98a 100644
@@ -300,10 +300,27 @@ python split_kernel_packages () {
 # with a fixed length or there is a limit in transferring the kernel to memory
 do_sizecheck() {
 	if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
-		size=`ls -l ${KERNEL_OUTPUT} | awk '{ print $5}'`
-		if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
-			rm ${KERNEL_OUTPUT}
-			die "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular."
+		if [ -f ${B}/${KERNEL_OUTPUT} ]; then
+			# vmlinux.bin is usually found here
+			koutf="${B}/${KERNEL_OUTPUT}"
+		elif [ -f ${B}/${KERNEL_IMAGETYPE} ]; then
+			# vmlinux is usually found here
+			koutf="${B}/${KERNEL_IMAGETYPE}"
+		else
+			# if we're lucky we'll catch some other image
+			# types in the previous conditions; otherwise:
+			koutf=""
+		fi
+
+		if [ -z "$koutf" ]; then
+			bbwarn "KERNEL_IMAGE_MAXSIZE enabled but" \
+			       "${KERNEL_IMAGETYPE} not supported (or not found)"
+		else
+			size=`ls -l $koutf | awk '{ print $5}'`
+			if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
+				die "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular."
+			fi
+			bbnote "kernel image size check... done"
 		fi
 	fi
 }
Signature · 1 line
1.7.9.7
#3 lore raw

Re: [OE-core] [PATCH 2/2] kernel.bbclass: do_sizecheck: update path to build image and do not delete

Quoted 55 lines · On Thu, 2013-03-28 at 15:32 -0400, [email protected] wrote:

From: Michel Thebeau <[email protected]>

do_sizecheck has been around for a while but looks to have been unused. There are a few issues.

It breaks because KERNEL_OUTPUT is a path relative to ${B}, and resolves to a soft link to ${B}/${KERNEL_IMAGETYPE}. When do_sizecheck runs it does not find the file (because the working directory is elsewhere) and does not fail.

Also, when do_sizecheck deletes the oversized kernel image it leaves the previously run do_compile task with inaccurate status.

So, do the following:
- keep the oversized image file so the status of do_compile is valid
- specify the full path with ${B} to break the dependency on working directory
- test for the image file in two typical locations and print a "not supported" warning when it is not found
- finally, print a note that the size check was run successfully

[YOCTO #3514]

---
 meta/classes/kernel.bbclass |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
meta/classes/kernel.bbclass +14 -4
index 6f988e7..d25d98a 100644
@@ -300,10 +300,27 @@ python split_kernel_packages () {
 # with a fixed length or there is a limit in transferring the kernel to memory
 do_sizecheck() {
 	if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
-		size=`ls -l ${KERNEL_OUTPUT} | awk '{ print $5}'`
-		if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
-			rm ${KERNEL_OUTPUT}
-			die "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular."
+		if [ -f ${B}/${KERNEL_OUTPUT} ]; then
+			# vmlinux.bin is usually found here
+			koutf="${B}/${KERNEL_OUTPUT}"
+		elif [ -f ${B}/${KERNEL_IMAGETYPE} ]; then
+			# vmlinux is usually found here
+			koutf="${B}/${KERNEL_IMAGETYPE}"
+		else
+			# if we're lucky we'll catch some other image
+			# types in the previous conditions; otherwise:
+			koutf=""
+		fi
+
+		if [ -z "$koutf" ]; then
+			bbwarn "KERNEL_IMAGE_MAXSIZE enabled but" \

meta/classes/kernel.bbclass python split_kernel_packages () { · line 326

Quoted 10 lines
meta/classes/kernel.bbclass +7 -0
+			       "${KERNEL_IMAGETYPE} not supported (or not found)"
+		else
+			size=`ls -l $koutf | awk '{ print $5}'`
+			if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
+				die "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular."
+			fi
+			bbnote "kernel image size check... done"
 		fi
 	fi
 }

Sorry but this is a bit crazy. We should be pretty clear about which file is the output kernel and this is the file that we should test (resolving links if need be). If we don't know which file is the correct kernel, we have bigger issues.

kernel_do_deploy says its KERNEL_OUTPUT:

"""
install -m 0644 ${KERNEL_OUTPUT} ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin """

I'd note we have:

do_deploy[dirs] = "${DEPLOYDIR} ${B}"

so perhaps we need a:

do_sizecheck[dirs] = "${B}"

to ensure we run in the correct place?

Cheers,

Richard

#4 lore raw

Re: [OE-core] [PATCH 2/2] kernel.bbclass: do_sizecheck: update path to build image and do not delete

In reply to [email protected]
Quoted 4 lines · On Thu, Mar 28, 2013 at 8:32 PM, <[email protected]> wrote:

From: Michel Thebeau <[email protected]>

do_sizecheck has been around for a while but looks to have been unused.

FYI in meta-handheld [1] we are building for challenged devices allowing max 1,2 or even 1,0 MB kernel size and the check has always be done properly.
So any improvement is allowed but please don't break the things ;)

Cheers

Andrea

[1]
http://cgit.openembedded.org/meta-handheld/tree/recipes-kernel/linux/linux-yocto-tiny-kexecboot_3.2.bbappend

There are a few issues.

Quoted 75 lines

It breaks because KERNEL_OUTPUT is a path relative to ${B}, and resolves to a soft link to ${B}/${KERNEL_IMAGETYPE}. When do_sizecheck runs it does not find the file (because the working directory is elsewhere) and does not fail.

Also, when do_sizecheck deletes the oversized kernel image it leaves the previously run do_compile task with inaccurate status.

So, do the following:
- keep the oversized image file so the status of do_compile is valid
- specify the full path with ${B} to break the dependency on working directory
- test for the image file in two typical locations and print a "not supported" warning when it is not found
- finally, print a note that the size check was run successfully

[YOCTO #3514]

---
 meta/classes/kernel.bbclass |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
meta/classes/kernel.bbclass +0 -0
index 6f988e7..d25d98a 100644
@@ -300,10 +300,27 @@ python split_kernel_packages () {
 # with a fixed length or there is a limit in transferring the kernel to

memory

 do_sizecheck() {
        if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
meta/classes/kernel.bbclass +0 -4
-               size=`ls -l ${KERNEL_OUTPUT} | awk '{ print $5}'`
-               if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
-                       rm ${KERNEL_OUTPUT}
-                       die "This kernel (size=$size >

${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular."

meta/classes/kernel.bbclass +15 -0
+               if [ -f ${B}/${KERNEL_OUTPUT} ]; then
+                       # vmlinux.bin is usually found here
+                       koutf="${B}/${KERNEL_OUTPUT}"
+               elif [ -f ${B}/${KERNEL_IMAGETYPE} ]; then
+                       # vmlinux is usually found here
+                       koutf="${B}/${KERNEL_IMAGETYPE}"
+               else
+                       # if we're lucky we'll catch some other image
+                       # types in the previous conditions; otherwise:
+                       koutf=""
+               fi
+
+               if [ -z "$koutf" ]; then
+                       bbwarn "KERNEL_IMAGE_MAXSIZE enabled but" \
+                              "${KERNEL_IMAGETYPE} not supported (or not

found)"

meta/classes/kernel.bbclass +4 -0
+               else
+                       size=`ls -l $koutf | awk '{ print $5}'`
+                       if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
+                               die "This kernel (size=$size >

${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular."

meta/classes/kernel.bbclass +2 -1
+                       fi
+                       bbnote "kernel image size check... done"
                fi
        fi
 }
--

1.7.9.7

_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky