diff options
author | Chuanhong Guo <gch981213@gmail.com> | 2024-03-02 21:12:54 +0800 |
---|---|---|
committer | Chuanhong Guo <gch981213@gmail.com> | 2024-03-21 16:55:13 +0800 |
commit | a6991fc7d251f7ab65a588546e22abfd4f8ce472 (patch) | |
tree | 96ecdb4163486c172994ee05888a3433efa8c89a /target/linux/mediatek/image/mt7622.mk | |
parent | ec8c3dc701cfd53e1ddc9817041e710fb4bbb0f3 (diff) | |
download | openwrt-a6991fc7d251f7ab65a588546e22abfd4f8ce472.tar.gz openwrt-a6991fc7d251f7ab65a588546e22abfd4f8ce472.tar.bz2 openwrt-a6991fc7d251f7ab65a588546e22abfd4f8ce472.zip |
mediatek: mt7622: add a second u-boot for redmi-ax6s
The vendor u-boot knows nothing about UBI, and we used to have a
fixed-size kernel partition for vendor u-boot and UBI for rootfs.
However, that fixed partition becomes too small eventually, and
expanding it requires complicated procedure.
This commit changed the flash layout and added a second u-boot
where the kernel supposed to be.
Now the vendor u-boot chainloads our mainline u-boot, and our
u-boot reads kernel+rootfs from UBI, verifies it, and boot
into OpenWrt.
There are two possible ways to convert from the old fw:
Flash the factory image using mtd (provided by @rany2):
mount -o remount,ro /
mount -o remount,ro /overlay
cd /tmp
dd if=factory.bin bs=1M count=4 | mtd write - kernel
dd if=factory.bin bs=1M skip=4 | mtd -r write - ubi
Or, flash the 2nd u-boot via mtd and upload the firmware
to the 2nd u-boot using tftp:
1. prepare a tftp server at 192.168.1.254 to serve the
sysupgrade image:
openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.itb
2. upload the ubi-loader.itb to OpenWrt /tmp, and flash it to
the old kernel partition:
mtd -r write openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-ubi-loader.itb
3. The router should reboot and flash the sysupgrade image via TFTP.
Procedure for flashing from vendor firmware shouldn't change.
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
Diffstat (limited to 'target/linux/mediatek/image/mt7622.mk')
-rw-r--r-- | target/linux/mediatek/image/mt7622.mk | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/target/linux/mediatek/image/mt7622.mk b/target/linux/mediatek/image/mt7622.mk index ab2bde0836..096a923457 100644 --- a/target/linux/mediatek/image/mt7622.mk +++ b/target/linux/mediatek/image/mt7622.mk @@ -37,6 +37,21 @@ define Build/bl31-uboot cat $(STAGING_DIR_IMAGE)/mt7622_$1-u-boot.fip >> $@ endef +define Build/uboot-bin + cat $(STAGING_DIR_IMAGE)/mt7622_$1-u-boot.bin >> $@ +endef + +define Build/uboot-fit + $(TOPDIR)/scripts/mkits.sh \ + -D $(DEVICE_NAME) -o $@.its -k $@ \ + -C $(word 1,$(1)) \ + -a 0x41e00000 -e 0x41e00000 \ + -c "config-1" \ + -A $(LINUX_KARCH) -v u-boot + PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new + @mv $@.new $@ +endef + # Append header to a D-Link M32/R32 Kernel 1 partition define Build/m32-r32-recovery-header-kernel1 $(eval header_start=$(word 1,$(1))) @@ -458,12 +473,20 @@ define Device/xiaomi_redmi-router-ax6s BOARD_NAME := xiaomi,redmi-router-ax6s DEVICE_PACKAGES := kmod-mt7915-firmware UBINIZE_OPTS := -E 5 - IMAGES += factory.bin BLOCKSIZE := 128k PAGESIZE := 2048 - KERNEL_SIZE := 4096k + KERNEL := kernel-bin | gzip + KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k KERNEL_INITRAMFS_SUFFIX := -recovery.itb - IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi - IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + IMAGES := sysupgrade.itb + IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | append-metadata + ARTIFACTS := ubi-loader.itb + ARTIFACT/ubi-loader.itb := uboot-bin xiaomi_redmi-router-ax6s-ubi-loader | lzma | uboot-fit lzma +ifneq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),) + ARTIFACTS += factory.bin + ARTIFACT/factory.bin := uboot-bin xiaomi_redmi-router-ax6s-ubi-loader | lzma | uboot-fit lzma | pad-to 512k | ubinize-image fit squashfs-sysupgrade.itb +endif + DEVICE_COMPAT_VERSION := 2.0 + DEVICE_COMPAT_MESSAGE := Flash layout changes require a manual reinstall using factory.bin. endef -# TARGET_DEVICES += xiaomi_redmi-router-ax6s +TARGET_DEVICES += xiaomi_redmi-router-ax6s |