Hello,

On 9/10/21 11:07 PM, Uwe Kleine-König wrote:
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.

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")

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to