From: Daniel Golle Date: Thu, 18 Jan 2024 22:15:35 +0000 (+0000) Subject: mediatek: BananaPi BPi-R3 bootloader update X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=61137a88952e125c574aa35209fd581591d8796a;p=openwrt%2Fstaging%2Fxback.git mediatek: BananaPi BPi-R3 bootloader update * Switch to all-UBI layout on SPI-NAND * use fitblk driver instead of uImage.FIT partition parser * adapt sysupgrade * bump COMPAT_VERSION Remove BROKEN mark now that all needed changes are done. Boards running images generated before this commit will require full reflash of the bootloader, re-install from SD card is the easiest way to achieve that. Signed-off-by: Daniel Golle --- diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/05_compat-version b/target/linux/mediatek/filogic/base-files/etc/board.d/05_compat-version index e0e1a8ecc7..d0cfd8f0a1 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/05_compat-version +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/05_compat-version @@ -6,7 +6,7 @@ board_config_update case "$(board_name)" in bananapi,bpi-r3) - ucidef_set_compat_version "1.1" + ucidef_set_compat_version "1.2" ;; esac diff --git a/target/linux/mediatek/filogic/base-files/etc/uci-defaults/05_fix-compat-version b/target/linux/mediatek/filogic/base-files/etc/uci-defaults/05_fix-compat-version index 4486f2f090..f39d2575e1 100644 --- a/target/linux/mediatek/filogic/base-files/etc/uci-defaults/05_fix-compat-version +++ b/target/linux/mediatek/filogic/base-files/etc/uci-defaults/05_fix-compat-version @@ -2,7 +2,7 @@ case "$(board_name)" in bananapi,bpi-r3) - uci set system.@system[0].compat_version="1.1" + uci set system.@system[0].compat_version="1.2" uci commit system ;; esac diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh index 889a1e2bd1..6f539eba8e 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -95,26 +95,7 @@ platform_do_upgrade() { CI_KERNPART="linux" nand_do_upgrade "$1" ;; - bananapi,bpi-r3) - local rootdev="$(cmdline_get_var root)" - rootdev="${rootdev##*/}" - rootdev="${rootdev%p[0-9]*}" - case "$rootdev" in - mmc*) - CI_ROOTDEV="$rootdev" - CI_KERNPART="production" - emmc_do_upgrade "$1" - ;; - mtdblock*) - PART_NAME="fit" - default_do_upgrade "$1" - ;; - ubiblock*) - CI_KERNPART="fit" - nand_do_upgrade "$1" - ;; - esac - ;; + bananapi,bpi-r3|\ bananapi,bpi-r4) [ -e /dev/fit0 ] && fitblk /dev/fit0 [ -e /dev/fitrw ] && fitblk /dev/fitrw @@ -124,6 +105,10 @@ platform_do_upgrade() { EMMC_KERN_DEV="/dev/$bootdev" emmc_do_upgrade "$1" ;; + mtdblock*) + PART_NAME="/dev/mtd${bootdev:8}" + default_do_upgrade "$1" + ;; ubiblock*) CI_KERNPART="fit" nand_do_upgrade "$1" @@ -225,7 +210,6 @@ platform_check_image() { platform_copy_config() { case "$(board_name)" in - bananapi,bpi-r3|\ cmcc,rax3000m) case "$(cmdline_get_var root)" in /dev/mmc*) @@ -233,6 +217,7 @@ platform_copy_config() { ;; esac ;; + bananapi,bpi-r3|\ bananapi,bpi-r4) case "$(platform_get_bootdev)" in mmcblk*) diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index cb8ab4c050..06777bc46e 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -218,7 +218,6 @@ endef TARGET_DEVICES += asus_tuf-ax6000 define Device/bananapi_bpi-r3 - BROKEN := 1 DEVICE_VENDOR := Bananapi DEVICE_MODEL := BPi-R3 DEVICE_DTS := mt7986a-bananapi-bpi-r3 @@ -228,7 +227,8 @@ define Device/bananapi_bpi-r3 mt7986a-bananapi-bpi-r3-respeaker-2mics DEVICE_DTS_DIR := $(DTS_DIR)/ DEVICE_DTS_LOADADDR := 0x43f00000 - DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-gpio kmod-mt7986-firmware kmod-sfp kmod-usb3 e2fsprogs f2fsck mkf2fs mt7986-wo-firmware + DEVICE_PACKAGES := fitblk kmod-hwmon-pwmfan kmod-i2c-gpio kmod-mt7986-firmware kmod-sfp kmod-usb3 \ + e2fsprogs f2fsck mkf2fs mt7986-wo-firmware IMAGES := sysupgrade.itb KERNEL_LOADADDR := 0x44000000 KERNEL_INITRAMFS_SUFFIX := -recovery.itb @@ -241,7 +241,7 @@ define Device/bananapi_bpi-r3 ARTIFACT/emmc-bl31-uboot.fip := mt7986-bl31-uboot bananapi_bpi-r3-emmc ARTIFACT/nor-preloader.bin := mt7986-bl2 nor-ddr4 ARTIFACT/nor-bl31-uboot.fip := mt7986-bl31-uboot bananapi_bpi-r3-nor - ARTIFACT/snand-preloader.bin := mt7986-bl2 spim-nand-ddr4 + ARTIFACT/snand-preloader.bin := mt7986-bl2 spim-nand-ubi-ddr4 ARTIFACT/snand-bl31-uboot.fip := mt7986-bl31-uboot bananapi_bpi-r3-snand ARTIFACT/sdcard.img.gz := mt798x-gpt sdmmc |\ pad-to 17k | mt7986-bl2 sdmmc-ddr4 |\ @@ -249,7 +249,7 @@ define Device/bananapi_bpi-r3 $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),\ pad-to 12M | append-image-stage initramfs-recovery.itb | check-size 44m |\ ) \ - pad-to 44M | mt7986-bl2 spim-nand-ddr4 |\ + pad-to 44M | mt7986-bl2 spim-nand-ubi-ddr4 |\ pad-to 45M | mt7986-bl31-uboot bananapi_bpi-r3-snand |\ pad-to 49M | mt7986-bl2 nor-ddr4 |\ pad-to 50M | mt7986-bl31-uboot bananapi_bpi-r3-nor |\ @@ -268,8 +268,8 @@ endif fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | pad-rootfs | append-metadata DEVICE_DTC_FLAGS := --pad 4096 - DEVICE_COMPAT_VERSION := 1.1 - DEVICE_COMPAT_MESSAGE := Device tree overlay mechanism needs bootloader update + DEVICE_COMPAT_VERSION := 1.2 + DEVICE_COMPAT_MESSAGE := SPI-NAND flash layout changes require bootloader update endef TARGET_DEVICES += bananapi_bpi-r3 diff --git a/target/linux/mediatek/patches-6.1/196-dts-mt7986a-bpi-r3-use-all-ubi-nand-layout.patch b/target/linux/mediatek/patches-6.1/196-dts-mt7986a-bpi-r3-use-all-ubi-nand-layout.patch new file mode 100644 index 0000000000..38510c0fc7 --- /dev/null +++ b/target/linux/mediatek/patches-6.1/196-dts-mt7986a-bpi-r3-use-all-ubi-nand-layout.patch @@ -0,0 +1,131 @@ +--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dtso ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dtso +@@ -23,7 +23,27 @@ + no-sd; + no-sdio; + status = "okay"; ++ ++ card@0 { ++ compatible = "mmc-card"; ++ reg = <0>; ++ ++ block { ++ compatible = "block-device"; ++ partitions { ++ emmc_rootdisk: block-partition-production { ++ partname = "production"; ++ }; ++ }; ++ }; ++ }; + }; + }; +-}; + ++ fragment@1 { ++ target-path = "/chosen"; ++ __overlay__ { ++ rootdisk-emmc = <&emmc_rootdisk>; ++ }; ++ }; ++}; +--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nand.dtso ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nand.dtso +@@ -29,27 +29,30 @@ + + partition@0 { + label = "bl2"; +- reg = <0x0 0x100000>; ++ reg = <0x0 0x200000>; + read-only; + }; + +- partition@100000 { +- label = "reserved"; +- reg = <0x100000 0x280000>; +- }; +- +- partition@380000 { +- label = "fip"; +- reg = <0x380000 0x200000>; +- read-only; +- }; +- +- partition@580000 { ++ partition@200000 { + label = "ubi"; +- reg = <0x580000 0x7a80000>; ++ reg = <0x200000 0x7e00000>; ++ compatible = "linux,ubi"; ++ ++ volumes { ++ nand_rootdisk: ubi-volume-fit { ++ volname = "fit"; ++ }; ++ }; + }; + }; + }; + }; + }; ++ ++ fragment@1 { ++ target-path = "/chosen"; ++ __overlay__ { ++ rootdisk-spim-nand = <&nand_rootdisk>; ++ }; ++ }; + }; +--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso +@@ -52,7 +52,7 @@ + reg = <0x180000 0xa80000>; + }; + +- partition@c00000 { ++ nor_rootdisk: partition@c00000 { + label = "fit"; + reg = <0xc00000 0x1400000>; + compatible = "denx,fit"; +@@ -61,4 +61,11 @@ + }; + }; + }; ++ ++ fragment@1 { ++ target-path = "/chosen"; ++ __overlay__ { ++ rootdisk-nor = <&nor_rootdisk>; ++ }; ++ }; + }; +--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dtso ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dtso +@@ -17,6 +17,27 @@ + max-frequency = <52000000>; + cap-sd-highspeed; + status = "okay"; ++ ++ card@0 { ++ compatible = "mmc-card"; ++ reg = <0>; ++ ++ block { ++ compatible = "block-device"; ++ partitions { ++ sd_rootdisk: block-partition-production { ++ partname = "production"; ++ }; ++ }; ++ }; ++ }; ++ }; ++ }; ++ ++ fragment@1 { ++ target-path = "/chosen"; ++ __overlay__ { ++ rootdisk-sd = <&sd_rootdisk>; + }; + }; + };