diff options
| author | Daniel Golle <daniel@makrotopia.org> | 2024-01-21 23:50:02 +0000 |
|---|---|---|
| committer | Daniel Golle <daniel@makrotopia.org> | 2024-02-15 19:30:08 +0000 |
| commit | 208f6c1232901835708eb4ace44ae17628fc12f5 (patch) | |
| tree | 7a8b3f199d98baccdf3e356b203b6249ae71aa78 /target/linux | |
| parent | 8f9b10d917dd812e2549d9ef0375420135c25e8b (diff) | |
| download | upstream-208f6c1232901835708eb4ace44ae17628fc12f5.tar.gz upstream-208f6c1232901835708eb4ace44ae17628fc12f5.tar.bz2 upstream-208f6c1232901835708eb4ace44ae17628fc12f5.zip | |
mediatek: mt7622: convert BPi-R64 to all-UBI layout and fitblk
Modernize bootloader and flash memory layout of the BPi-R64 similar to
how it has also been done for the BPi-R3.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'target/linux')
12 files changed, 149 insertions, 26 deletions
diff --git a/target/linux/mediatek/image/mt7622.mk b/target/linux/mediatek/image/mt7622.mk index 7df5eade822..0d631c19963 100644 --- a/target/linux/mediatek/image/mt7622.mk +++ b/target/linux/mediatek/image/mt7622.mk @@ -90,7 +90,7 @@ define Device/bananapi_bpi-r64 DEVICE_MODEL := BPi-R64 DEVICE_DTS := mt7622-bananapi-bpi-r64 DEVICE_DTS_OVERLAY := mt7622-bananapi-bpi-r64-pcie1 mt7622-bananapi-bpi-r64-sata - DEVICE_PACKAGES := kmod-ata-ahci-mtk kmod-btmtkuart kmod-usb3 e2fsprogs mkf2fs f2fsck + DEVICE_PACKAGES := fitblk kmod-ata-ahci-mtk kmod-btmtkuart kmod-usb3 e2fsprogs mkf2fs f2fsck DEVICE_DTC_FLAGS := --pad 4096 DEVICE_DTS_LOADADDR := 0x43f00000 ARTIFACTS := emmc-preloader.bin emmc-bl31-uboot.fip sdcard.img.gz snand-preloader.bin snand-bl31-uboot.fip @@ -98,7 +98,7 @@ define Device/bananapi_bpi-r64 KERNEL_INITRAMFS_SUFFIX := -recovery.itb ARTIFACT/emmc-preloader.bin := bl2 emmc-2ddr ARTIFACT/emmc-bl31-uboot.fip := bl31-uboot bananapi_bpi-r64-emmc - ARTIFACT/snand-preloader.bin := bl2 snand-2ddr + ARTIFACT/snand-preloader.bin := bl2 snand-ubi-2ddr ARTIFACT/snand-bl31-uboot.fip := bl31-uboot bananapi_bpi-r64-snand ARTIFACT/sdcard.img.gz := mt7622-gpt sdmmc |\ pad-to 512k | bl2 sdmmc-2ddr |\ @@ -109,7 +109,7 @@ define Device/bananapi_bpi-r64 pad-to 38912k | mt7622-gpt emmc |\ pad-to 39424k | bl2 emmc-2ddr |\ pad-to 40960k | bl31-uboot bananapi_bpi-r64-emmc |\ - pad-to 43008k | bl2 snand-2ddr |\ + pad-to 43008k | bl2 snand-ubi-2ddr |\ pad-to 43520k | bl31-uboot bananapi_bpi-r64-snand |\ $(if $(CONFIG_TARGET_ROOTFS_SQUASHFS), \ pad-to 46080k | append-image squashfs-sysupgrade.itb | check-size |\ @@ -121,8 +121,8 @@ endif KERNEL := kernel-bin | gzip KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb with-initrd | pad-to 128k IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb external-static-with-rootfs | append-metadata - 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-r64 diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/05_compat-version b/target/linux/mediatek/mt7622/base-files/etc/board.d/05_compat-version index c8fb2c08f69..2fdbe764073 100644 --- a/target/linux/mediatek/mt7622/base-files/etc/board.d/05_compat-version +++ b/target/linux/mediatek/mt7622/base-files/etc/board.d/05_compat-version @@ -6,7 +6,7 @@ board_config_update case "$(board_name)" in bananapi,bpi-r64) - ucidef_set_compat_version "1.1" + ucidef_set_compat_version "1.2" ;; esac diff --git a/target/linux/mediatek/mt7622/base-files/etc/uci-defaults/05_fix-compat-version b/target/linux/mediatek/mt7622/base-files/etc/uci-defaults/05_fix-compat-version index 83310378694..3359d4a4001 100644 --- a/target/linux/mediatek/mt7622/base-files/etc/uci-defaults/05_fix-compat-version +++ b/target/linux/mediatek/mt7622/base-files/etc/uci-defaults/05_fix-compat-version @@ -1,7 +1,10 @@ . /lib/functions.sh case "$(board_name)" in - bananapi,bpi-r64|\ + bananapi,bpi-r64) + uci set system.@system[0].compat_version="1.2" + uci commit system + ;; buffalo,wsr-2533dhp2) uci set system.@system[0].compat_version="1.1" uci commit system diff --git a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh index 3a2d7a4cd62..5836e1aa3ee 100755 --- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh @@ -1,4 +1,20 @@ REQUIRE_IMAGE_METADATA=1 +RAMFS_COPY_BIN='fitblk' + +platform_get_bootdev() { + local rootdisk="$(cat /sys/firmware/devicetree/base/chosen/rootdisk)" + local handle bootdev + for handle in /sys/class/block/*/of_node/phandle /sys/class/block/*/device/of_node/phandle; do + [ ! -e "$handle" ] && continue + if [ "$rootdisk" = "$(cat $handle)" ]; then + bootdev="${handle%/of_node/phandle}" + bootdev="${bootdev%/device}" + bootdev="${bootdev#/sys/class/block/}" + echo "$bootdev" + break + fi + done +} platform_do_upgrade() { local board=$(board_name) @@ -6,21 +22,21 @@ platform_do_upgrade() { case "$board" in bananapi,bpi-r64) - local rootdev="$(cmdline_get_var root)" - rootdev="${rootdev##*/}" - rootdev="${rootdev%p[0-9]*}" - case "$rootdev" in - mmc*) - CI_ROOTDEV="$rootdev" - CI_KERNPART="production" + [ -e /dev/fit0 ] && fitblk /dev/fit0 + [ -e /dev/fitrw ] && fitblk /dev/fitrw + bootdev="$(platform_get_bootdev)" + case "$bootdev" in + mmcblk*) + EMMC_KERN_DEV="/dev/$bootdev" emmc_do_upgrade "$1" ;; - *) + ubiblock*) CI_KERNPART="fit" nand_do_upgrade "$1" ;; esac ;; + buffalo,wsr-2533dhp2|\ buffalo,wsr-3200ax4s) local magic="$(get_magic_long "$1")" @@ -99,9 +115,7 @@ platform_check_image() { platform_copy_config() { case "$(board_name)" in bananapi,bpi-r64) - export_bootdevice - export_partdevice rootdev 0 - if echo $rootdev | grep -q mmc; then + if platform_get_bootdev | grep -q mmc; then emmc_copy_config fi ;; diff --git a/target/linux/mediatek/mt7622/config-6.1 b/target/linux/mediatek/mt7622/config-6.1 index 0a876bce74e..cdaae0fe25c 100644 --- a/target/linux/mediatek/mt7622/config-6.1 +++ b/target/linux/mediatek/mt7622/config-6.1 @@ -455,6 +455,7 @@ CONFIG_TREE_RCU=y CONFIG_TREE_SRCU=y CONFIG_UBIFS_FS=y # CONFIG_UCLAMP_TASK is not set +CONFIG_UIMAGE_FIT_BLK=y # CONFIG_UNMAP_KERNEL_AT_EL0 is not set CONFIG_USB_SUPPORT=y CONFIG_VMAP_STACK=y diff --git a/target/linux/mediatek/patches-6.1/113-dts-fix-bpi64-leds-and-buttons.patch b/target/linux/mediatek/patches-6.1/113-dts-fix-bpi64-leds-and-buttons.patch index bf1912a9163..1cca6f35341 100644 --- a/target/linux/mediatek/patches-6.1/113-dts-fix-bpi64-leds-and-buttons.patch +++ b/target/linux/mediatek/patches-6.1/113-dts-fix-bpi64-leds-and-buttons.patch @@ -1,6 +1,6 @@ --- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts -@@ -21,6 +21,10 @@ +@@ -21,6 +21,12 @@ aliases { serial0 = &uart0; ethernet0 = &gmac0; @@ -8,10 +8,12 @@ + led-failsafe = &led_system_blue; + led-running = &led_system_green; + led-upgrade = &led_system_blue; ++ mmc0 = &mmc0; ++ mmc1 = &mmc1; }; chosen { -@@ -44,8 +48,8 @@ +@@ -44,8 +50,8 @@ compatible = "gpio-keys"; factory-key { @@ -22,7 +24,7 @@ gpios = <&pio 0 GPIO_ACTIVE_HIGH>; }; -@@ -59,17 +63,17 @@ +@@ -59,17 +65,17 @@ leds { compatible = "gpio-leds"; diff --git a/target/linux/mediatek/patches-6.1/114-dts-bpi64-disable-rtc.patch b/target/linux/mediatek/patches-6.1/114-dts-bpi64-disable-rtc.patch index e30d9e5e12a..0d324084b1c 100644 --- a/target/linux/mediatek/patches-6.1/114-dts-bpi64-disable-rtc.patch +++ b/target/linux/mediatek/patches-6.1/114-dts-bpi64-disable-rtc.patch @@ -1,6 +1,6 @@ --- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts -@@ -554,12 +554,16 @@ +@@ -556,12 +556,16 @@ status = "okay"; }; diff --git a/target/linux/mediatek/patches-6.1/115-dts-bpi64-add-snand-support.patch b/target/linux/mediatek/patches-6.1/115-dts-bpi64-add-snand-support.patch index 93f87fe697f..16aed70b44e 100644 --- a/target/linux/mediatek/patches-6.1/115-dts-bpi64-add-snand-support.patch +++ b/target/linux/mediatek/patches-6.1/115-dts-bpi64-add-snand-support.patch @@ -1,6 +1,6 @@ --- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts -@@ -251,14 +251,42 @@ +@@ -253,14 +253,42 @@ status = "disabled"; }; diff --git a/target/linux/mediatek/patches-6.1/180-dts-mt7622-bpi-r64-add-mt7531-irq.patch b/target/linux/mediatek/patches-6.1/180-dts-mt7622-bpi-r64-add-mt7531-irq.patch index 676c09f656c..03e7aef9f03 100644 --- a/target/linux/mediatek/patches-6.1/180-dts-mt7622-bpi-r64-add-mt7531-irq.patch +++ b/target/linux/mediatek/patches-6.1/180-dts-mt7622-bpi-r64-add-mt7531-irq.patch @@ -1,6 +1,6 @@ --- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts -@@ -152,6 +152,10 @@ +@@ -154,6 +154,10 @@ switch@0 { compatible = "mediatek,mt7531"; reg = <0>; diff --git a/target/linux/mediatek/patches-6.1/900-dts-mt7622-bpi-r64-aliases-for-dtoverlay.patch b/target/linux/mediatek/patches-6.1/900-dts-mt7622-bpi-r64-aliases-for-dtoverlay.patch index 8e56be9ff44..6dede02003a 100644 --- a/target/linux/mediatek/patches-6.1/900-dts-mt7622-bpi-r64-aliases-for-dtoverlay.patch +++ b/target/linux/mediatek/patches-6.1/900-dts-mt7622-bpi-r64-aliases-for-dtoverlay.patch @@ -1,6 +1,6 @@ --- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts -@@ -310,7 +310,7 @@ +@@ -312,7 +312,7 @@ /* Attention: GPIO 90 is used to switch between PCIe@1,0 and * SATA functions. i.e. output-high: PCIe, output-low: SATA */ diff --git a/target/linux/mediatek/patches-6.1/910-dts-mt7622-bpi-r64-wifi-eeprom.patch b/target/linux/mediatek/patches-6.1/910-dts-mt7622-bpi-r64-wifi-eeprom.patch index b6762e29ac0..09ce417c351 100644 --- a/target/linux/mediatek/patches-6.1/910-dts-mt7622-bpi-r64-wifi-eeprom.patch +++ b/target/linux/mediatek/patches-6.1/910-dts-mt7622-bpi-r64-wifi-eeprom.patch @@ -1,6 +1,6 @@ --- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts -@@ -637,5 +637,28 @@ +@@ -639,5 +639,28 @@ }; &wmac { diff --git a/target/linux/mediatek/patches-6.1/911-dts-mt7622-bpi-r64-add-rootdisk.patch b/target/linux/mediatek/patches-6.1/911-dts-mt7622-bpi-r64-add-rootdisk.patch new file mode 100644 index 00000000000..a141743194f --- /dev/null +++ b/target/linux/mediatek/patches-6.1/911-dts-mt7622-bpi-r64-add-rootdisk.patch @@ -0,0 +1,103 @@ +--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts ++++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +@@ -32,6 +32,9 @@ + chosen { + stdout-path = "serial0:115200n8"; + bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n1 swiotlb=512"; ++ rootdisk-emmc = <&emmc_rootfs>; ++ rootdisk-sd = <&sd_rootfs>; ++ rootdisk-snfi = <&ubi_rootfs>; + }; + + cpus { +@@ -233,6 +236,26 @@ + assigned-clocks = <&topckgen CLK_TOP_MSDC30_0_SEL>; + assigned-clock-parents = <&topckgen CLK_TOP_UNIV48M>; + non-removable; ++ ++ card@0 { ++ compatible = "mmc-card"; ++ reg = <0>; ++ ++ block { ++ compatible = "block-device"; ++ partitions { ++ block-partition-env { ++ partname = "ubootenv"; ++ nvmem-layout { ++ compatible = "u-boot,env-layout"; ++ }; ++ }; ++ emmc_rootfs: block-partition-production { ++ partname = "production"; ++ }; ++ }; ++ }; ++ }; + }; + + &mmc1 { +@@ -249,6 +272,26 @@ + vqmmc-supply = <®_3p3v>; + assigned-clocks = <&topckgen CLK_TOP_MSDC30_1_SEL>; + assigned-clock-parents = <&topckgen CLK_TOP_UNIV48M>; ++ ++ card@0 { ++ compatible = "mmc-card"; ++ reg = <0>; ++ ++ block { ++ compatible = "block-device"; ++ partitions { ++ block-partition-env { ++ partname = "ubootenv"; ++ nvmem-layout { ++ compatible = "u-boot,env-layout"; ++ }; ++ }; ++ sd_rootfs: block-partition-production { ++ partname = "production"; ++ }; ++ }; ++ }; ++ }; + }; + + &nandc { +@@ -283,14 +326,29 @@ + }; + + partition@80000 { +- label = "fip"; +- reg = <0x80000 0x200000>; +- read-only; +- }; +- +- partition@280000 { + label = "ubi"; +- reg = <0x280000 0x7d80000>; ++ reg = <0x80000 0x7f80000>; ++ compatible = "linux,ubi"; ++ ++ volumes { ++ ubi-volume-ubootenv { ++ volname = "ubootenv"; ++ nvmem-layout { ++ compatible = "u-boot,env-redundant-bool-layout"; ++ }; ++ }; ++ ++ ubi-volume-ubootenv2 { ++ volname = "ubootenv2"; ++ nvmem-layout { ++ compatible = "u-boot,env-redundant-bool-layout"; ++ }; ++ }; ++ ++ ubi_rootfs: ubi-volume-fit { ++ volname = "fit"; ++ }; ++ }; + }; + }; + }; |
