[PATCH 4/4] uboot-mediatek: GatoNetworks GDSP: only read the FIT image when booting

Enrico Mioso mrkiko.rs at gmail.com
Sat Nov 21 12:20:28 PST 2026


boot_nor read the whole 30.5 MiB "firmware" partition into RAM before
booting, even though the FIT image usually takes only a fraction of it.
The rest of the partition holds rootfs_data, which U-Boot does not need.

Read the first 128 KiB, use imsz to get the total FIT size (which
includes the externally stored kernel, DTBs, overlays and rootfs), check
it against the partition size, then read only the image. This makes
booting from NOR faster. If the partition does not hold a valid FIT, it
now stops before calling bootm.

Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Signed-off-by: Enrico Mioso <mrkiko.rs at gmail.com>
---
 .../patches/458-add-GatoNetworks-GDSP.patch              | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/package/boot/uboot-mediatek/patches/458-add-GatoNetworks-GDSP.patch b/package/boot/uboot-mediatek/patches/458-add-GatoNetworks-GDSP.patch
index b9484eceff..25ab214d74 100644
--- a/package/boot/uboot-mediatek/patches/458-add-GatoNetworks-GDSP.patch
+++ b/package/boot/uboot-mediatek/patches/458-add-GatoNetworks-GDSP.patch
@@ -7,8 +7,8 @@ Signed-off-by: Enrico Mioso <mrkiko.rs at gmail.com>
 ---
  arch/arm/dts/mt7981-gatonetworks_gdsp.dts  | 237 +++++++++++++++++++++
  configs/mt7981_gatonetworks_gdsp_defconfig | 150 +++++++++++++++
- defenvs/gatonetworks_gdsp_env              |  48 ++++
- 3 files changed, 435 insertions(+)
+ defenvs/gatonetworks_gdsp_env              |  49 ++++
+ 3 files changed, 436 insertions(+)
  create mode 100644 arch/arm/dts/mt7981-gatonetworks_gdsp.dts
  create mode 100644 configs/mt7981_gatonetworks_gdsp_defconfig
  create mode 100644 defenvs/gatonetworks_gdsp_env
@@ -408,7 +408,7 @@ Signed-off-by: Enrico Mioso <mrkiko.rs at gmail.com>
 +CONFIG_HEXDUMP=y
 --- /dev/null
 +++ b/defenvs/gatonetworks_gdsp_env
-@@ -0,0 +1,48 @@
+@@ -0,0 +1,49 @@
 +load_factory_data=if env exists factory_data_present ; then else mtd read Factory $loadaddr 0x0 0x1000 ; setenv factory_data_present 1 ; fi
 +lan_mac_factory=run load_factory_data ; setexpr macoffs $loadaddr + 0x2a ; env readmem -b lan_mac $macoffs 0x6 ; setenv lan_mac_factory ; setenv macoffs
 +wan_mac_factory=run load_factory_data ; setexpr macoffs $loadaddr + 0x24 ; env readmem -b wan_mac $macoffs 0x6 ; setenv wan_mac_factory ; setenv macoffs
@@ -439,7 +439,8 @@ Signed-off-by: Enrico Mioso <mrkiko.rs at gmail.com>
 +bootmenu_5=Reboot.=reset
 +boot_first=if button reset ; then run boot_tftp ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu
 +boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_tftp_forever
-+boot_nor=mtd read firmware ${loadaddr} && bootm $loadaddr#$bootconf
++boot_nor=run nor_read_firmware && bootm $loadaddr#$bootconf
++nor_read_firmware=mtd read firmware $loadaddr 0x0 0x20000 && imsz $loadaddr image_size && test 0x$image_size -le 0x1e80000 && mtd read firmware $loadaddr 0x0 $image_size
 +boot_sd_firmware=setenv bootconf "config-1#mt7981b-gatonetworks-gdsp-sd#mt7981b-gatonetworks-gdsp-sd-boot"; run sdmmc_read_firmware && bootm $loadaddr#$bootconf
 +boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
 +boot_tftp_forever=while true ; do run boot_tftp ; sleep 1 ; done
-- 
2.56.1




More information about the openwrt-devel mailing list