====== BananaPi R4 ====== https://wiki.banana-pi.org/Banana_Pi_BPI-R4 ===== Hardware ===== * MediaTek MT7988A (Filogic 880) * MT7530 switch builtin (1 cpu-port with 4GBit/s + 1Gbit/s user-ports) * 4G RAM * 8GB eMMC flash * 128MB SPI-NAND Flash * either 2x SFP+ (10GBit/s USXGMII) or 1SFP+ and 2g5 rj45 with PoE ([[https://forum.banana-pi.org/t/bpi-r4-any-information/15404/25|link]]) * Wifi7 with additional module connected to the 2 PCIe slots at bottom of board * BPI-R4-NIC-BE19 (no public sale): MT7996 + MT7975 (2.4G) + MT7977A (6G) + MT7977B (5G) * BPI-R4-NIC-BE14: MT7995AV + MT7976CN + MT7977IAN * powersupply 12V/5A required when using wifi card,2A (like on other BPi Routers) is not enough {{ :en:bpi-r4:bpi-r4-blockschematic.png?direct&600 |}} v00: {{:en:bpi-r4:bpi-r4_v00-top.jpg?direct&400 |}} {{ :en:bpi-r4:bpi-r4_v00-bottom-wifi.jpg?direct&400 |}} v1.0: {{:en:bpi-r4:bpi-r4_v1-top.jpg?direct&400 |}} {{ :en:bpi-r4:bpi-r4_v1-bottom.jpg?direct&400 |}} Changes between v0 and v1 (pm): https://forum.banana-pi.org/t/bpi-r4-linux-bootup/15926/59 v1.1: {{:en:bpi-r4:bpi-r4_v1.1_top.jpg?direct&400 |}} {{ :en:bpi-r4:bpi-r4_v1.1_bottom.jpg?direct&400|}} ===== thermal ===== cat /sys/class/thermal/thermal_zone0/temp Uses lvts driver Thermalpad size: https://forum.banana-pi.org/t/banana-pi-bpi-r4-heatsink-and-case-design/16638/53 ==== testing fan ==== by default first trip point is set to 40°C and second is 85°C...for testing the fan it is a bit high when using a passive heatsink. so just set first to 35 and second to 45. root@bpi-r4-v11:/sys/class/thermal/thermal_zone0 # cat trip_point_4_temp 40000 root@bpi-r4-v11:/sys/class/thermal/thermal_zone0 # cat trip_point_3_temp 85000 root@bpi-r4-v11:/sys/class/thermal/thermal_zone0 # echo 45000 > trip_point_3_temp root@bpi-r4-v11:/sys/class/thermal/thermal_zone0 # echo 35000 > trip_point_4_temp root@bpi-r4-v11:/sys/class/thermal/thermal_zone0 ===== Network ===== GMAC0 (4GBit/s) is connected internally to mt7530 switch variant where the 4 user-Ports are exposed as rj45 on board (1xWan,3xLan). The SFP(+) cages are connected to SerDes lanes of GMAC1 and GMAC2, and those can be switched between SGMII/1000Base-X/2500Base-X mode for 10M/100M/1000M/2500M (via mtk-pcs-lynxi, just like on MT7622 and MT7986) and USXGMII/10GBase-KR for 5000M and 10000M. Hence it should be possible to support both, SFP modules with 1000M and 2500M, as well as SFP+ modules with 5000M and 10000M. Sfp-connections ^ USB-A ^ SFP1-WAN ^ SFP2-LAN ^ 4xRJ-45 ^ 12V ^ USB-C ^ | | USXGMII0 | USXGMII1 | GSW | | | | | eth2 | eth1 | eth0 | | | pm: https://forum.banana-pi.org/t/bpi-r4-linux-bootup/15926/101 (changed interface-names because eth2 is wan-sfp) full 10G will need RSS+LRO implemented in mtk ethernet driver and enabled (not yet working): ethtool -K eth2 lro on # enable hw_lro ethtool -k eth2 | grep large large-receive-offload: on iperf3 -bidir -c 192.168.90.10 RSS: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/18f46a84d87308a4f56f9176ca166dc75c38bb20%5E%21/ LRO: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/ddc366751fad05dade79b09932a999c5d5ae890c%5E%21/#F0 NETSYS: V2 for mt7986 (bpi-r3) V3 for mt7988 (bpi-r4) Daniel tells me that lro should be enabled via userspace with ethtool -N $ifname flow-type tcp4 dst-ip $lan_ip loc 0 ==== Wifi ==== wifi is realized with daughter board (Network Interface Card) in the 2 mPCIe-Slots at bottom of the board. Wifi-Module needs 12V...v1 uses sw4 in on-position, v0 used devicetree-overlay which enables the WIFI_PWR_EN regulator. Be careful with this setting when using different card in mPCIe slots! kernel-module: mt7996e.ko {{:en:bpi-r4:wifi-nic.jpg?direct&400 |}} {{ :en:bpi-r4:r4-wifi-be14.jpg?direct&400 |}} Newer wifi card with reduced antenna-count (6 instead of 14): https://forum.banana-pi.org/t/banana-pi-bpi-r4-bpi-be14-wi-fi7-nic-module/17182 newer card currently has timeout on 3rd wifi interface (6.8-netnext), i guess we need another firmware file for the mt7977ia frontend ===== PCIE ===== 2x1Lane (M.2 slots) and 2x2lane. the 2x2lane is for wifi (mPCIe slots). ===== USB ===== ===== Bootswitch ===== ^ ^ A ^ B ^ | nand | 0 | 1 | | eMMC | 1 | 0 | | SD | 1 | 1 | switch down is "1", so both down booting from sdcard (v0 had both up to boot from sdcard) v0: - both switches up => sdcard - down (1),up (0) seems to be nand as this have mtd command - up(0),down(1) also boots into bpis bootmenu, but i have no mtd command, so i guess this is the emmc - both down failed ===== GPIO ===== {{ :en:bpi-r4:bpi-r4-gpio.png?direct&400 |}} ===== eeprom ===== BPI-R4 has an eeprom on i2c-mux channel 0 [ 1.515672] at24 2-0057: 256 byte 24c02 EEPROM, writable, 1 bytes/write write-mode (wp-gpio is linked to green led): # echo 0 > /sys/devices/platform/gpio-leds/leds/green:status/brightness root@bpi-r4-v11:~ # echo "test" > /sys/bus/i2c/devices/2-0057/eeprom root@bpi-r4-v11:~ # hexdump -C /sys/bus/i2c/devices/2-0057/eeprom 00000000 74 65 73 74 0a ff ff ff ff ff ff ff ff ff ff ff |test............| 00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00000100 root@bpi-r4-v11:~ # echo 1 > /sys/devices/platform/gpio-leds/leds/green:status/brightness root@bpi-r4-v11:~ ===== rtc ===== Battery connection looks like charging circuit for ml2032. You should not connect non-rechargeable battery like cr2032. https://forum.banana-pi.org/t/bpi-r3-bpi-r4-does-the-bpi-r3-r4-have-a-rtc/17763/36 Connector is JST with 1.25mm pitch RTC time will survive software reboot # dmesg | grep rtc [ 1.479923] rtc-pcf8563 2-0051: low voltage detected, date/time is not reliable. [ 1.487390] rtc-pcf8563 2-0051: registered as rtc0 [ 1.493378] rtc-pcf8563 2-0051: low voltage detected, date/time is not reliable. [ 1.500771] rtc-pcf8563 2-0051: hctosys: unable to read the hardware clock root@bpi-r4-v11:~ # date -s "2024-04-27 09:55 CEST" Sat Apr 27 07:55:00 UTC 2024 root@bpi-r4-v11:~ # hwclock -w root@bpi-r4-v11:~ # hwclock -r 2024-04-27 07:56:23.979830+00:00 root@bpi-r4-v11:~ # reboot ... root@bpi-r4-v11:~ # dmesg | grep rtc [ 1.480067] rtc-pcf8563 2-0051: registered as rtc0 [ 1.486061] rtc-pcf8563 2-0051: setting system clock to 2024-04-27T07:56:53 ) root@bpi-r4-v11:~ # date Sat Apr 27 08:00:46 UTC 2024 root@bpi-r4-v11:~ ===== uboot/ATF ===== currently use these: * uboot: https://github.com/frank-w/u-boot/tree/2024-04-bpi * ATF: https://github.com/frank-w/u-boot/tree/mtk-atf and bootup [[https://github.com/frank-w/BPI-Router-Linux/tree/6.5-mt7988|"my" kernel]] like this: MT7988> setenv fit 6.5.0-rc1-mt7988.itb MT7988> setenv kaddr 0x48000000 MT7988> fatload mmc 0:5 ${kaddr} ${fit} 4970220 bytes read in 417 ms (11.4 MiB/s) MT7988> bootm ${kaddr} kaddr 0x46000000 works too, if uncompressed kernelimage is smaller than 32M (fit size of 14M was too large) in newer u-boot i have set kaddr to 0x46000000 (fit loadaddr 0x44000000, rdaddr 0x48000000) [[uboot]] ===== tftp ===== BPI-R4> setenv bootfile 6.5.0-rc1-mt7988-r4.itb BPI-R4> run bootnetfit ===== openwrt image ===== using bin/targets/mediatek/filogic/openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb BPI-R4> usb start BPI-R4> ls usb 0:1 r4 ./ ../ 7929856 openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb 1 file(s), 2 dir(s) BPI-R4> fatload usb 0:1 0x50000000 r4/openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb 7929856 bytes read in 672 ms (11.3 MiB/s) BPI-R4> bootm 0x50000000#config-mt7988a-bananapi-bpi-r4#mt7988a-bananapi-bpi-r4-sd to get the bootconfigs (after #) we can use dumpimage from uboot-tools, see https://www.gibbard.me/linux_fit_images/ ===== linux ===== https://www.kernel.org/doc/html/v6.1/admin-guide/kernel-parameters.html 3GB Ram limit not needed anymore as ethernet driver now uses 36bit addressing Currently we need to limit ram to 3G because of swiotlb buffer full issues in ethernet driver (32bit border) mem=3G in cmdline (bootopts in my uboot uEnv.txt) ==== kernel ==== https://github.com/frank-w/BPI-Router-Linux/tree/6.6-dango ==== debug ==== # mount -t debugfs none /sys/kernel/debug/ # cat /sys/kernel/debug/gpio # cat /sys/kernel/debug/pinctrl/pinctrl-handles # cat /sys/kernel/debug/regulator/regulator_summary # cat /sys/kernel/debug/clk/clk_summary #enable debug for driver probe # echo 'file dd.c +p'>/sys/kernel/debug/dynamic_debug/control # echo 'file core.c +p'>/sys/kernel/debug/dynamic_debug/control # echo '11230000.mmc' > /sys/bus/platform/drivers/mtk-msdc/unbind # echo '11230000.mmc' > /sys/bus/platform/drivers/mtk-msdc/bind ==== interface config ==== ip link set lan0 up ip a a 192.168.0.19/24 dev lan0 ip r a default via 192.168.0.10 date -s "2023-08-23 19:37 CEST" #stats ip -s link show dev eth2 ethtool -S eth2 DNS needs to be set in /etc/resolv.conf or in systemd like this: mkdir -p /etc/systemd/resolved.conf.d/ cp /etc/systemd/resolved.conf /etc/systemd/resolved.conf.d/TEST.conf echo "DNS = 192.168.0.10" >> /etc/systemd/resolved.conf.d/TEST.conf systemctl restart systemd-resolved.service modules in initrd: mount /dev/mmcblk0p6 /mnt mkdir /lib/modules mkdir /lib/firmware mount -o bind /mnt/lib/modules /lib/modules mount -o bind /mnt/lib/firmware /lib/firmware modprobe mt7996e ==== openwrt ==== === upstream === same as for r3 https://forum.banana-pi.org/t/banana-pi-r3-bsp-source-code/14257/2 but select BananaPi BPI-R4 of course :) i had to do a "make distclean" after "git pull" followed by the documented steps # Update the feeds ./scripts/feeds update -a ./scripts/feeds install -a make menuconfig #select "Target System (MediaTek Ralink ARM)" => "Subtarget (Filogic 8x0 (MT798x))" => "Target Profile (Bananapi BPi-R4)" make -j$(nproc) then write the sdcard image... gunzip -c bin/targets/mediatek/filogic/openwrt-mediatek-filogic-bananapi_bpi-r4-sdcard.img.gz | sudo dd bs=1M status=progress conv=notrunc,fsync of=/dev/sdX === downstream (sdk) === * clone openwrt master * add this to feeds.conf.default: “src-git mtksdk https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds” * scripts/feeds update -f mtksdk * make menuconfig: * Target System (MediaTek Ralink ARM) * Subtarget (Filogic 8x0 (MT798x)) * Target Profile (MediaTek MT7988a nand rfb) #here i see no sd-variant adding additional options: CONFIG_PACKAGE_f2fs-tools=y CONFIG_PACKAGE_e2fsprogs=y CONFIG_PACKAGE_dosfstools=y CONFIG_PACKAGE_resize2fs=y CONFIG_PACKAGE_nano=y CONFIG_PACKAGE_iperf3=y #CONFIG_PACKAGE_netcat CONFIG_PACKAGE_tcpdump=y CONFIG_BUSYBOX_CUSTOM=y CONFIG_BUSYBOX_CONFIG_TELNET=y > *-initramfs-kernel.bin is not the production image we’re using. We only use it for testing purpose since it contains rootfs and won’t read the flash. > *-sysupgrade.bin is the actual production image. It’s a tar ball for nand/emmc/sd boards. It contains separate kernel and rootfs that will be written to ubi volume for nand, or the partitions defined for sd/emmc. tar -xf bin/targets/mediatek/filogic/openwrt-mediatek-filogic-mediatek_mt7988a-rfb-nand-squashfs-sysupgrade.bin sysupgrade-mediatek_mt7988a-rfb-nand/kernel dumpimage -l sysupgrade-mediatek_mt7988a-rfb-nand/kernel tftpboot 0x50000000 openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb bootm 0x50000000#config-mt7988a-bananapi-bpi-r4#mt7988a-bananapi-bpi-r4-sd ===== Known Issues ===== * Card in M.2 slot causes i2c issues (sfp not detected): https://forum.banana-pi.org/t/bpi-r4-nvme-i2c/17152/2 * pcie2 and some others (offloading with 4G, multiple ppe, rss/lro) not yet working (https://forum.banana-pi.org/t/banana-pi-bpi-r4-wifi-7-router-board-with-mediatek-mt7988a-filogic-880-4g-ram-and-8g-emmc/15757/241)