]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
sunxi: binman: Add U-Boot binary size check
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Thu, 19 Oct 2017 09:36:35 +0000 (11:36 +0200)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Wed, 25 Oct 2017 08:05:06 +0000 (10:05 +0200)
The U-Boot binary may trip over its actual allocated size in the storage.
In such a case, the environment will not be readable anymore (because
corrupted when the new image was flashed), and any attempt at using saveenv
to reconstruct the environment will result in a corrupted U-Boot binary.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
arch/arm/dts/sunxi-u-boot.dtsi

index 5adfd9bca2ec1ffa8ff8360f02d51071948009a3..72e95afd780e936e511e92557a7f4c5b51893fa9 100644 (file)
@@ -1,5 +1,14 @@
 #include <config.h>
 
+/*
+ * This is the maximum size the U-Boot binary can be, which is basically
+ * the start of the environment, minus the start of the U-Boot binary in
+ * the MMC. This makes the assumption that the MMC is using 512-bytes
+ * blocks, but devices using something other than that remains to be
+ * seen.
+ */
+#define UBOOT_MMC_MAX_SIZE     (CONFIG_ENV_OFFSET - (CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512))
+
 / {
        binman {
                filename = "u-boot-sunxi-with-spl.bin";
@@ -8,6 +17,9 @@
                        filename = "spl/sunxi-spl.bin";
                };
                u-boot-img {
+#ifdef CONFIG_MMC
+                       size = <UBOOT_MMC_MAX_SIZE>;
+#endif
                        pos = <CONFIG_SPL_PAD_TO>;
                };
        };