uboot-mediatek: add support for compressed BL3/FIP image
authorDaniel Golle <daniel@makrotopia.org>
Wed, 13 Jul 2022 20:06:36 +0000 (21:06 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 28 Aug 2022 19:33:15 +0000 (20:33 +0100)
MediaTek's ARM Trusted Firmware v2.7+ allows the images inside a FIP
structure to be compressed. Make use of that for boards with NOR flash.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/boot/arm-trusted-firmware-mediatek/patches/100-increase-nor-bl3-size.patch [deleted file]
package/boot/uboot-mediatek/Makefile

diff --git a/package/boot/arm-trusted-firmware-mediatek/patches/100-increase-nor-bl3-size.patch b/package/boot/arm-trusted-firmware-mediatek/patches/100-increase-nor-bl3-size.patch
deleted file mode 100644 (file)
index 8de3cd7..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/plat/mediatek/mt7622/bl2_boot_nor.c
-+++ b/plat/mediatek/mt7622/bl2_boot_nor.c
-@@ -12,7 +12,7 @@
- #define MT7622_NOR_MAP_BASE           0x30000000
- #define FIP_BASE                      0x20000
--#define FIP_SIZE                      0x80000
-+#define FIP_SIZE                      0xa0000
- const io_block_spec_t mtk_boot_dev_fip_spec = {
-       .offset = MT7622_NOR_MAP_BASE + FIP_BASE,
index 314cb8b84b43879996a0eae1baf1f71e9e5b3ba0..a8add7ef94cc0e420d3c9787957501c0244b0cd5 100644 (file)
@@ -132,6 +132,7 @@ define U-Boot/mt7622_ubnt_unifi-6-lr
   BL2_BOOTDEV:=nor
   BL2_DDRBLOB:=2
   DEPENDS:=+trusted-firmware-a-mt7622-nor-2ddr
+  FIP_COMPRESS:=1
 endef
 
 define U-Boot/mt7623a_unielec_u7623
@@ -196,9 +197,13 @@ UBOOT_MAKE_FLAGS += $(UBOOT_IMAGE:.fip=.bin)
 endif
 
 define Build/fip-image
+       $(if $(FIP_COMPRESS),\
+               xz -f -e -k -9 -C crc32 $(STAGING_DIR_IMAGE)/$(BUILD_SUBTARGET)-$(BL2_BOOTDEV)-$(BL2_DDRBLOB)ddr-bl31.bin ;\
+               xz -f -e -k -9 -C crc32 $(PKG_BUILD_DIR)/u-boot.bin \
+       )
        $(STAGING_DIR_HOST)/bin/fiptool create \
-               --soc-fw $(STAGING_DIR_IMAGE)/$(BUILD_SUBTARGET)-$(BL2_BOOTDEV)-$(BL2_DDRBLOB)ddr-bl31.bin \
-               --nt-fw $(PKG_BUILD_DIR)/u-boot.bin \
+               --soc-fw $(STAGING_DIR_IMAGE)/$(BUILD_SUBTARGET)-$(BL2_BOOTDEV)-$(BL2_DDRBLOB)ddr-bl31.bin$(if $(FIP_COMPRESS),.xz) \
+               --nt-fw $(PKG_BUILD_DIR)/u-boot.bin$(if $(FIP_COMPRESS),.xz) \
                $(PKG_BUILD_DIR)/u-boot.fip
 endef