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 <daniel@makrotopia.org>
This commit is contained in:
Daniel Golle
2023-07-23 12:38:15 +01:00
parent 74a8f416f4
commit f16dc4b42f
11 changed files with 735 additions and 4 deletions

View File

@@ -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|\