Skip to content

Commit

Permalink
mediatek: add support for BananaPi BPI-R4 MT7988 board
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed Jun 30, 2024
1 parent e157234 commit b35c02a
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 2 deletions.
6 changes: 6 additions & 0 deletions target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ case $board in
abt,asr3000)
ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
;;
bananapi,bpi-r4)
ucidef_set_led_netdev "wan" "wan" "mt7530-0:00:green:lan" "wan" "link tx rx"
ucidef_set_led_netdev "lan1" "lan1" "mt7530-0:01:green:lan" "lan1" "link tx rx"
ucidef_set_led_netdev "lan2" "lan2" "mt7530-0:02:green:lan" "lan2" "link tx rx"
ucidef_set_led_netdev "lan3" "lan3" "mt7530-0:03:green:lan" "lan3" "link tx rx"
;;
hf,m7986r1*)
ucidef_set_led_netdev "led-1" "LAN1" "led-1" "lan1"
ucidef_set_led_netdev "led-2" "LAN2" "led-2" "lan2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ mediatek_setup_interfaces()
bananapi,bpi-r3)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 sfp2" "eth1 wan"
;;
bananapi,bpi-r4)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 eth1" "wan eth2"
;;
cetron,ct3003*|\
fzs,5gcpe-p3|\
jcg,q30-pro|\
Expand Down
41 changes: 40 additions & 1 deletion target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
REQUIRE_IMAGE_METADATA=1
RAMFS_COPY_BIN='fitblk'

asus_initial_setup()
{
Expand All @@ -11,6 +12,21 @@ asus_initial_setup()
ubimkvol /dev/ubi0 -N jffs2 -s 0x3e000
}

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)

Expand Down Expand Up @@ -40,6 +56,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-emmc|\
glinet,gl-mt2500|\
glinet,gl-mt6000|\
Expand All @@ -63,7 +94,8 @@ platform_check_image() {
[ "$#" -gt 1 ] && return 1

case "$board" in
bananapi,bpi-r3)
bananapi,bpi-r3|\
bananapi,bpi-r4)
[ "$magic" != "d00dfeed" ] && {
echo "Invalid image type."
return 1
Expand All @@ -88,6 +120,13 @@ platform_copy_config() {
;;
esac
;;
bananapi,bpi-r4)
case "$(platform_get_bootdev)" in
mmcblk*)
emmc_copy_config
;;
esac
;;
cmcc,rax3000m-emmc|\
glinet,gl-mt2500|\
glinet,gl-mt6000|\
Expand Down
1 change: 1 addition & 0 deletions target/linux/mediatek/filogic/config-6.6
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_SD=y
CONFIG_BLK_MQ_PCI=y
CONFIG_BLK_NVMEM=y
CONFIG_BLK_PM=y
CONFIG_BLOCK_NOTIFIERS=y
CONFIG_BSD_PROCESS_ACCT=y
Expand Down
51 changes: 50 additions & 1 deletion target/linux/mediatek/image/filogic.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define Build/mt7988-bl31-uboot
cat $(STAGING_DIR_IMAGE)/mt7988_$1-u-boot.fip >> $@
endef

define Build/mt7986-gpt
define Build/mt798x-gpt
cp $@ $@.tmp 2>/dev/null || true
ptgen -g -o $@.tmp -a 1 -l 1024 \
$(if $(findstring sdmmc,$1), \
Expand Down Expand Up @@ -147,6 +147,55 @@ define Device/bananapi_bpi-r3
endef
TARGET_DEVICES += bananapi_bpi-r3

define Device/bananapi_bpi-r4-common
DEVICE_VENDOR := Bananapi
DEVICE_DTS_DIR := $(DTS_DIR)/
DEVICE_DTS_LOADADDR := 0x45f00000
DEVICE_DTS_OVERLAY:= mt7988a-bananapi-bpi-r4-emmc mt7988a-bananapi-bpi-r4-rtc mt7988a-bananapi-bpi-r4-sd mt7988a-bananapi-bpi-r4-wifi-mt7996a
DEVICE_DTC_FLAGS := --pad 4096
DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-mux-pca954x kmod-eeprom-at24 kmod-mt7996-firmware \
kmod-rtc-pcf8563 kmod-sfp kmod-usb3 e2fsprogs f2fsck mkf2fs
IMAGES := sysupgrade.itb
KERNEL_LOADADDR := 0x46000000
KERNEL_INITRAMFS_SUFFIX := -recovery.itb
ARTIFACTS := \
emmc-preloader.bin emmc-bl31-uboot.fip \
sdcard.img.gz \
snand-preloader.bin snand-bl31-uboot.fip
ARTIFACT/emmc-preloader.bin := mt7988-bl2 emmc-comb
ARTIFACT/emmc-bl31-uboot.fip := mt7988-bl31-uboot $$(DEVICE_NAME)-emmc
ARTIFACT/snand-preloader.bin := mt7988-bl2 spim-nand-ubi-comb
ARTIFACT/snand-bl31-uboot.fip := mt7988-bl31-uboot $$(DEVICE_NAME)-snand
ARTIFACT/sdcard.img.gz := mt798x-gpt sdmmc |\
pad-to 17k | mt7988-bl2 sdmmc-comb |\
pad-to 6656k | mt7988-bl31-uboot $$(DEVICE_NAME)-sdmmc |\
$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),\
pad-to 12M | append-image-stage initramfs-recovery.itb | check-size 44m |\
) \
pad-to 44M | mt7988-bl2 spim-nand-ubi-comb |\
pad-to 45M | mt7988-bl31-uboot $$(DEVICE_NAME)-snand |\
pad-to 51M | mt7988-bl2 emmc-comb |\
pad-to 52M | mt7988-bl31-uboot $$(DEVICE_NAME)-emmc |\
pad-to 56M | mt798x-gpt emmc |\
$(if $(CONFIG_TARGET_ROOTFS_SQUASHFS),\
pad-to 64M | append-image squashfs-sysupgrade.itb | check-size |\
) \
gzip
IMAGE_SIZE := $$(shell expr 64 + $$(CONFIG_TARGET_ROOTFS_PARTSIZE))m
KERNEL := kernel-bin | gzip
KERNEL_INITRAMFS := kernel-bin | lzma | \
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-with-rootfs | pad-rootfs | append-metadata
endef

define Device/bananapi_bpi-r4
DEVICE_MODEL := BPi-R4
DEVICE_DTS := mt7988a-bananapi-bpi-r4
DEVICE_DTS_CONFIG := config-mt7988a-bananapi-bpi-r4
$(call Device/bananapi_bpi-r4-common)
endef
TARGET_DEVICES += bananapi_bpi-r4

define Device/cetron_ct3003
DEVICE_VENDOR := Cetron
DEVICE_MODEL := CT3003
Expand Down

0 comments on commit b35c02a

Please sign in to comment.