From f16dc4b42fb265affb2298e815a7ce0a13d60da6 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 23 Jul 2023 12:38:15 +0100 Subject: mediatek: add support for BananaPi BPI-R4 board Hardware -------- SOC: MediaTek MT7988A (4x Cortex-A73) RAM: 4 GiB DDR4 Flash: 128 MiB Winbond SPI-NAND MMC: 8 GiB eMMC *or* microSD (cannot be used both) ETH: 4x 1GE (1x WAN, 3x LAN) 2x SFP+ (10G, 5G, 2.5G, 1G) USB: on-board USB 3.2 4-port hub 1x USB 3.2 port (type A connector) 1x M.2 for 4G/5G modem 2x mPCIe for additional modems WiFi: optional MediaTek MT7996 Wi-Fi 7 module (using 2x PCIe gen3 x2 on the mPCIe slots and 12V power) Installation ------------ 1. Decompress and write the sdcard image to a micro SD card and use that to boot the R4 (both dip switches in upper position). 2. Use the bootloader menu accessible via the serial console to install to SPI-NAND. 3. Switch to boot from SPI-NAND and install to eMMC. Known issues ------------ - The RST button is hard-wired to the SoC reset and can't be read from software. This can be changed by modifying the board (ie. moving a 0-ohm resistor). However, in order to maintain compatibility with the board as it comes from factory the button isn't used by OpenWrt and the WPS button is used as factory/reset button instead. - various small things still need to be fixed in DT Signed-off-by: Daniel Golle --- .../filogic/base-files/lib/upgrade/platform.sh | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'target/linux/mediatek/filogic/base-files/lib') 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 97c09f35a8..889a1e2bd1 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -1,4 +1,5 @@ REQUIRE_IMAGE_METADATA=1 +RAMFS_COPY_BIN='fitblk' asus_initial_setup() { @@ -59,6 +60,21 @@ xiaomi_initial_setup() esac } +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) @@ -99,6 +115,21 @@ platform_do_upgrade() { ;; esac ;; + bananapi,bpi-r4) + [ -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 + ;; cmcc,rax3000m) case "$(cmdline_get_var root)" in /dev/mmc*) @@ -175,6 +206,7 @@ platform_check_image() { case "$board" in bananapi,bpi-r3|\ + bananapi,bpi-r4|\ cmcc,rax3000m) [ "$magic" != "d00dfeed" ] && { echo "Invalid image type." @@ -201,6 +233,13 @@ platform_copy_config() { ;; esac ;; + bananapi,bpi-r4) + case "$(platform_get_bootdev)" in + mmcblk*) + emmc_copy_config + ;; + esac + ;; acer,predator-w6|\ glinet,gl-mt2500|\ glinet,gl-mt6000|\ -- cgit v1.2.3