Skip to content

Commit

Permalink
mediatek: BananaPi BPi-R3 bootloader update
Browse files Browse the repository at this point in the history
 * 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 <daniel@makrotopia.org>
  • Loading branch information
dangowrt committed Jan 20, 2024
1 parent dde635c commit e08ea9f
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 1 addition & 20 deletions target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,7 @@ platform_do_upgrade() {
CI_KERNPART="linux"
nand_do_upgrade "$1"
;;
bananapi,bpi-r3)
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)
fitblk /dev/fit0
[ -e /dev/fitrw ] && fitblk /dev/fitrw
Expand Down
12 changes: 6 additions & 6 deletions target/linux/mediatek/image/filogic.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -241,15 +241,15 @@ 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 |\
pad-to 6656k | mt7986-bl31-uboot bananapi_bpi-r3-sdmmc |\
$(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 |\
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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>;
};
};
};

0 comments on commit e08ea9f

Please sign in to comment.