- Package:
- flash-kernel
- Source:
- flash-kernel
- Submitter:
- Uwe Kleine-König
- Date:
- 2021-09-10 21:33:02 UTC
- Severity:
- normal
Hello,
when the active machine entry has an "Mtd-Kernel" field, flash-kernel
checks if the kernel fits into the specified mtd partition. However if
the machine entry also has "DTB-Append: yes" the image written to said
partition is a combination of kernel and dtb, and so the check must
include the dtb's size, too.
Here is an untested patch:
diff --git a/functions b/functions
index 260be2ba2b3d..d5fd0f714300 100644
--- a/functions
+++ b/functions
@@ -842,6 +842,12 @@ if [ -n "$dtb_append_from" ]; then
fi
fi
+if [ "$dtb_append" = "yes" ]; then
+ dtb=$(find_dtb_file)
+ dfilesize=$(stat -c '%s' "$dtb")
+ kfilesize=$(($kfilesize + $dfilesize))
+fi
+
if [ -n "$mtd_kernel" ] || [ -n "$mtd_initrd" ]; then
if [ ! -e "$PROC_MTD" ]; then
error "$PROC_MTD doesn't exist"
Best regards
Uwe
Hello,
This is actually wrong, the misleading bit is, that the kernel
partition's size is checked twice. The first time with the plain
kernel's size (which might be a too weak check) and then later with the
actual size which also includes U-Boot header and initrd size (in the
case of a multi image). See commit abdc93372ef965a992850af8eed9381ccad83f76.
So I suggest the following patch instead:
diff --git a/functions b/functions
index 260be2ba2b3d..9824f6534111 100644
--- a/functions
+++ b/functions
@@ -855,7 +855,10 @@ if [ -n "$mtd_kernel" ]; then
check_char_dev "$kmtd"
kmtdsize=$(mtdsize "$mtd_kernel")
kreqsize=$kfilesize
- check_mtd_size "$mtd_kernel" $kreqsize $kmtdsize kernel
+
+ # The actual check is done later to take into account things
added the
+ # kernel image (e.g. U-Boot image header, initrd (for multi images)
+ # and/or an appended dtb
fi
if [ -n "$mtd_initrd" ]; then
imtd=$(mtdchar "$mtd_initrd")