BananaPiBPI-R4开源路由器使用手册--frank

开源不如不打烊 2024-11-14 05:38:12
硬件

联发科 MT7988A (Filogic 880)内置 MT7530 交换机(1 个 4GBit/s CPU 端口 + 1Gbit/s 用户端口)4G内存8GB eMMC 闪存128MB SPI-NAND 闪存2x SFP+ (10GBit/s USXGMII) 或 1SFP+ 和 2g5 rj45 带 PoE (链接)Wifi7 带有附加模块,连接到板底部的 2 个 PCIe 插槽BPI-R4-NIC-BE19(未公开出售):MT7996 + MT7975(2.4G)+ MT7977A(6G)+ MT7977B(5G)BPI-R4-NIC-BE14:MT7995AV + MT7976CN + MT7977IAN使用 wifi 卡时需要 12V/5A 电源,2A(与其他 BPi 路由器一样)不够热能cat /sys/class/thermal/thermal_zone0/temp

使用 lvts 驱动程序

导热垫尺寸:https://forum.banana-pi.org/t/banana-pi-bpi-r4-heatsink-and-case-design/16638/53

测试风扇

默认情况下,第一个跳闸点设置为 40°C,第二个跳闸点设置为 85°C...对于测试风扇,使用无源散热器时温度有点高。因此,只需将第一个设置为 35,将第二个设置为 45。

root@bpi-r4-v11:/sys/class/thermal/thermal_zone0# cat trip_point_4_temp40000root@bpi-r4-v11:/sys/class/thermal/thermal_zone0# cat trip_point_3_temp85000root@bpi-r4-v11:/sys/class/thermal/thermal_zone0# echo 45000 > trip_point_3_temproot@bpi-r4-v11:/sys/class/thermal/thermal_zone0# echo 35000 > trip_point_4_temproot@bpi-r4-v11:/sys/class/thermal/thermal_zone0网络

GMAC0(4GBit/s)内部连接到 mt7530 交换机变体,其中 4 个用户端口作为板载 rj45 公开(1xWan、3xLan)。

SFP(+) 笼子连接到 GMAC1 和 GMAC2 的 SerDes 通道,并且可以在 10M/100M/1000M/2500M 的 SGMII/1000Base-X/2500Base-X 模式之间切换(通过 mtk-pcs-lynxi,就像在 MT7622 和 MT7986 上一样)以及 5000M 和 10000M 的 USXGMII/10GBase-KR 模式之间切换。

R4 的 SFP+ 笼支持的接口模式有:SGMII、1000Base-X、2500Base-X、5GBase-R、10GBase-R、USXGMII

因此 1.25Gbps(= 1000Base-X 或 SGMII)和 3.125Gbps(= 2500Base-X)SFP 模块可以与 R4 正常工作。

Sfp 连接

USB-A

SFP1-广域网

SFP2-局域网

4 个 RJ-45

12伏

USB-C

美国XGMII0

美国XGMII1

格斯沃

eth2

eth1

eth0

点击显示 ⇲

Forward 10g 应该与 ppe 补丁一起工作,但是输入需要 rss+lro。

https://forum.banana-pi.org/t/bpi-r4-not-getting-full-10gbps-speed-on-wan/18134/30

完整的 10G 需要在 mtk 以太网驱动程序中实现并启用 RSS+LRO(尚未工作):

ethtool -K eth2 lro on #启用 hw_lroethtool -k eth2 | grep large大型接收卸载:开启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 适用于 mt7986 (bpi-r3) V3 适用于 mt7988 (bpi-r4)

Daniel 告诉我,lro 应该通过用户空间启用

ethtool -N $ifname 流类型 tcp4 dst-ip $lan_ip loc 0无线上网

wifi 是通过主板底部 2 个 mPCIe 插槽中的子板(网络接口卡)实现的。

Wifi 模块需要 12V…v1 使用 sw4 处于开启状态,v0 使用设备树覆盖来启用 WIFI_PWR_EN 调节器。在 mPCIe 插槽中使用不同的卡时,请小心使用此设置!

内核模块:mt7996e.ko

较新的 WiFi 卡具有较少的天线数量(6 个而不是 14 个):

https://forum.banana-pi.org/t/banana-pi-bpi-r4-bpi-be14-wi-fi7-nic-module/17182

较新的卡目前在第三个 wifi 接口(6.8-netnext)上超时,我想我们需要另一个用于 mt7977ia 前端的固件文件

wifi配置(正在进行中未经测试):

Click to hide ⇱

5GHz

driver=nl80211logger_syslog=127logger_syslog_level=2logger_stdout=127logger_stdout_level=2country_code=PTieee80211d=1ieee80211h=1hw_mode=abeacon_int=100channel=acs_surveytx_queue_data2_burst=2.0#num_global_macaddr=1ieee80211n=1ht_coex=0ht_capab=[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][MAX-AMSDU-7935]ieee80211ac=1vht_oper_chwidth=2vht_oper_centr_freq_seg0_idx=acs_surveyvht_capab=[RXLDPC][SHORT-GI-80][SHORT-GI-160][TX-STBC-2BY1][SU-BEAMFORMER][SU-BEAMFORMEE][MU-BEAMFORMER][MU-BEAMFORMEE][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN][RX-STBC-1][SOUNDING-DIMENSION-3][BF-ANTENNA-3][VHT160][MAX-MPDU-11454][MAX-A-MPDU-LEN-EXP7]ieee80211ax=1he_oper_chwidth=2he_oper_centr_freq_seg0_idx=acs_surveyhe_su_beamformer=1he_su_beamformee=1he_mu_beamformer=1he_bss_color=128he_spr_sr_control=3he_default_pe_duration=4he_rts_threshold=1023he_mu_edca_qos_info_param_count=0he_mu_edca_qos_info_q_ack=0he_mu_edca_qos_info_queue_request=0he_mu_edca_qos_info_txop_request=0he_mu_edca_ac_be_aifsn=8he_mu_edca_ac_be_aci=0he_mu_edca_ac_be_ecwmin=9he_mu_edca_ac_be_ecwmax=10he_mu_edca_ac_be_timer=255he_mu_edca_ac_bk_aifsn=15he_mu_edca_ac_bk_aci=1he_mu_edca_ac_bk_ecwmin=9he_mu_edca_ac_bk_ecwmax=10he_mu_edca_ac_bk_timer=255he_mu_edca_ac_vi_ecwmin=5he_mu_edca_ac_vi_ecwmax=7he_mu_edca_ac_vi_aifsn=5he_mu_edca_ac_vi_aci=2he_mu_edca_ac_vi_timer=255he_mu_edca_ac_vo_aifsn=5he_mu_edca_ac_vo_aci=3he_mu_edca_ac_vo_ecwmin=5he_mu_edca_ac_vo_ecwmax=7he_mu_edca_ac_vo_timer=255interface=phy2-ap0ctrl_interface=/var/run/hostapdap_isolate=1bss_load_update_period=60chan_util_avg_period=600disassoc_low_ack=1skip_inactivity_poll=0preamble=1wmm_enabled=1ignore_broadcast_ssid=0uapsd_advertisement_enabled=1utf8_ssid=1multi_ap=0sae_require_mfp=1sae_pwe=2wpa_passphrase=testtesttestwpa_psk_file=/var/run/hostapd-phy2-ap0.pskauth_algs=1wpa=2wpa_pairwise=CCMPssid=MT7996-233-test-5bridge=br-lanwds_bridge=snoop_iface=br-lanwpa_disable_eapol_key_retries=0wpa_key_mgmt=SAEokc=1ieee80211w=2group_mgmt_cipher=AES-128-CMACdynamic_vlan=0vlan_naming=1vlan_no_bridge=1vlan_file=/var/run/hostapd-phy2-ap0.vlanqos_map_set=0,0,2,16,1,1,255,255,18,22,24,38,40,40,44,46,48,56bssid=fe:9c:48:0a:86:32#default_macaddr

2.4ghz:

driver=nl80211logger_syslog=127logger_syslog_level=2logger_stdout=127logger_stdout_level=2country_code=PTieee80211d=1hw_mode=gsupported_rates=60 90 120 180 240 360 480 540basic_rates=60 120 240beacon_int=100channel=acs_survey#num_global_macaddr=1ieee80211n=1ht_coex=0ht_capab=[LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][MAX-AMSDU-7935]ieee80211ax=1he_su_beamformer=1he_su_beamformee=1he_mu_beamformer=1he_bss_color=128he_spr_sr_control=3he_default_pe_duration=4he_rts_threshold=1023he_mu_edca_qos_info_param_count=0he_mu_edca_qos_info_q_ack=0he_mu_edca_qos_info_queue_request=0he_mu_edca_qos_info_txop_request=0he_mu_edca_ac_be_aifsn=8he_mu_edca_ac_be_aci=0he_mu_edca_ac_be_ecwmin=9he_mu_edca_ac_be_ecwmax=10he_mu_edca_ac_be_timer=255he_mu_edca_ac_bk_aifsn=15he_mu_edca_ac_bk_aci=1he_mu_edca_ac_bk_ecwmin=9he_mu_edca_ac_bk_ecwmax=10he_mu_edca_ac_bk_timer=255he_mu_edca_ac_vi_ecwmin=5he_mu_edca_ac_vi_ecwmax=7he_mu_edca_ac_vi_aifsn=5he_mu_edca_ac_vi_aci=2he_mu_edca_ac_vi_timer=255he_mu_edca_ac_vo_aifsn=5he_mu_edca_ac_vo_aci=3he_mu_edca_ac_vo_ecwmin=5he_mu_edca_ac_vo_ecwmax=7he_mu_edca_ac_vo_timer=255interface=phy1-ap0ctrl_interface=/var/run/hostapdap_isolate=1bss_load_update_period=60chan_util_avg_period=600disassoc_low_ack=1skip_inactivity_poll=0preamble=1wmm_enabled=1ignore_broadcast_ssid=0uapsd_advertisement_enabled=1utf8_ssid=1multi_ap=0sae_require_mfp=1sae_pwe=2wpa_passphrase=testtesttestwpa_psk_file=/var/run/hostapd-phy1-ap0.pskauth_algs=1wpa=2wpa_pairwise=CCMPssid=MT7996-233-test-2.4bridge=br-lanwds_bridge=snoop_iface=br-lanwpa_disable_eapol_key_retries=0wpa_key_mgmt=SAEokc=1ieee80211w=2group_mgmt_cipher=AES-128-CMACdynamic_vlan=0vlan_naming=1vlan_no_bridge=1vlan_file=/var/run/hostapd-phy1-ap0.vlanqos_map_set=0,0,2,16,1,1,255,255,18,22,24,38,40,40,44,46,48,56bssid=fe:9c:48:0a:86:31#default_macaddrPCI接口

2x1Lane(M.2 插槽)和 2x2lane。2x2lane 用于 wifi(mPCIe 插槽)。

USBSim 插槽CN16(M.2 键)– SIM1CN12(mPCIE)– SIM2CN14(mPCIE)– SIM3启动开关

一个

与非

0

1

嵌入式多媒体卡

1

0

标准差

1

1

向下切换为“1”,因此两者都从 SD 卡启动(v0 两者都从 SD 卡启动)

both switches up ⇒ sdcarddown (1),up (0) seems to be nand as this have mtd commandup(0),down(1) also boots into bpis bootmenu, but i have no mtd command, so i guess this is the emmcboth down failedGPIO通用输入输出

PWM

如何使 pwm6 工作:

https://forum.banana-pi.org/t/bpi-r4-cpu-fan-setup/17362/102

eeprom

BPI-R4 在 i2c-mux 通道 0 上有一个 eeprom

[ 1.515672] at24 2-0057: 256 byte 24c02 EEPROM, writable, 1 bytes/write

写入模式(wp-gpio 连接至绿色 led):

# echo 0 > /sys/devices/platform/gpio-leds/leds/green:status/brightnessroot@bpi-r4-v11:~# echo "test" > /sys/bus/i2c/devices/2-0057/eepromroot@bpi-r4-v11:~# hexdump -C /sys/bus/i2c/devices/2-0057/eeprom00000000 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 |................|*00000100root@bpi-r4-v11:~# echo 1 > /sys/devices/platform/gpio-leds/leds/green:status/brightnessroot@bpi-r4-v11:~rtc实时时钟

电池连接看起来像 ml2032 的充电电路。您不应连接 cr2032 等不可充电电池。

https://forum.banana-pi.org/t/bpi-r3-bpi-r4-does-the-bpi-r3-r4-have-a-rtc/17763/36

连接器为 JST,间距为 1.25 毫米

RTC 时间将在软件重启后继续有效

# 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 clockroot@bpi-r4-v11:~# date -s "2024-04-27 09:55 CEST"Sat Apr 27 07:55:00 UTC 2024root@bpi-r4-v11:~# hwclock -wroot@bpi-r4-v11:~# hwclock -r2024-04-27 07:56:23.979830+00:00root@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:~# dateSat Apr 27 08:00:46 UTC 2024root@bpi-r4-v11:~uboot/ATF

目前使用这些:

uboot: https://github.com/frank-w/u-boot/tree/2024-04-bpiATF: https://github.com/frank-w/u-boot/tree/mtk-atf

并像这样 启动

MT7988> setenv fit 6.5.0-rc1-mt7988.itbMT7988> setenv kaddr 0x48000000MT7988> fatload mmc 0:5 ${kaddr} ${fit}4970220 bytes read in 417 ms (11.4 MiB/s)MT7988> bootm ${kaddr}

如果未压缩的 kernelimage 小于 32M(14M 的适合大小太大),kaddr 0x46000000 也可以工作

在较新的 u-boot 中,我已将 kaddr 设置为 0x46000000(适合 loadaddr 0x44000000,rdaddr 0x48000000)

使用 mtk_uartboot 工具进行 ram-boot:

https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r3mini:start#fix_bricked_boot

bpi-r4_ram.tar.gz

./mtk_uartboot -s /dev/ttyUSB4 --aarch64 --payload bpi-r4_ram_bl2.bin --fip bpi-r4_ram_fip.bin./mtk_uartboot -s /dev/ttyUSB4 --aarch64 --payload bpi-r4_ram_bl2.bin --fip bpi-r4_ram_fip.bin

mtk_uartboot - 0.1.1Using serial port: /dev/ttyUSB4Handshake...hw code: 0x7988hw sub code: 0x8a00hw ver: 0xcb00sw ver: 0x1Baud rate set to 460800sending payload to 0x201000...Checksum: 0x32edSetting baudrate back to 115200Jumping to 0x201000 in aarch64...Waiting for BL2. Message below:==================================NOTICE: BL2: v2.9(release):v2.9.0-358-g4e064f88b83f ramNOTICE: BL2: Built : 18:38:51, Jun 11 2024NOTICE: WDT: Cold bootNOTICE: WDT: disabledNOTICE: CPU: MT7988NOTICE: EMI: Using DDR unknown settingsNOTICE: EMI: Detected DRAM size: 4096 MBNOTICE: EMI: complex R/W mem test passedNOTICE: Starting UART download handshake ...==================================BL2 UART DL version: 0x10Baudrate set to: 921600FIP sent.==================================NOTICE: Received FIP 0x4440d @ 0x40400000 ...==================================

tftpBPI-R4> setenv bootfile 6.5.0-rc1-mt7988-r4.itbBPI-R4> run bootnetfitopenwrt 镜像

使用 bin/targets/mediatek/filogic/openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb

BPI-R4> usb startBPI-R4> ls usb 0:1 r4 ./ ../ 7929856 openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb1 file(s), 2 dir(s)BPI-R4> fatload usb 0:1 0x50000000 r4/openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb7929856 bytes read in 672 ms (11.3 MiB/s)BPI-R4> bootm 0x50000000#config-mt7988a-bananapi-bpi-r4#mt7988a-bananapi-bpi-r4-sd

要获取 bootconfigs(# 之后),我们可以使用 uboot-tools 中的 dumpimage,请参阅https://www.gibbard.me/linux_fit_images/

debian/ubuntu镜像构建

基本上我有 3 个 github-repos 用于此……

我的u-boot repo创建了启动链(atf bl2+uboot fip+partitions+creating base image),因此请在此 ci-pipeline(.github/workflows/build.yaml)和 uboot 分支和 mtk-atf 分支中的 build.sh 中查找详细信息我的kernel-repo(BPI-Router-Linux)包含通过 ci 管道和 build.sh 构建的 Linux 内核我的图像仓库收集了这两个二进制文件(基础图像和内核包),并使用 rootfs 制作了一个完整图像(gdrive 分支中也有 ci 可用)

我的 gdrive 上预建的图像:https://drive.google.com/drive/folders/1A5S7_82Bg4EYxjzdQ5FKyBw9Qi2C3uK-? usp=drive_link

有关 nand 的更多信息和使用 ubi 的信息请参见: https: //gist.github.com/BtbN/9e5878d83816fb49d51d1f76c42d7945

Webgui(驾驶舱): https: //forum.banana-pi.org/t/bpi-r4-sd-debian-bookworm-b ullseye-images-on-kernel-6-8-0-dango/17487/43

Linux的

https://www.kernel.org/doc/html/v6.1/admin-guide/kernel-parameters.html

以太网驱动程序现在使用 36 位寻址,因此不再需要 3GB Ram 限制

核心

https://github.com/frank-w/BPI-Router-Linux/tree/6.6-dango

调试# 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/bindinterface configip link set lan0 upip a a 192.168.0.19/24 dev lan0ip r a default via 192.168.0.10date -s "2023-08-23 19:37 CEST"#statsip -s link show dev eth2ethtool -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.confecho "DNS = 192.168.0.10" >> /etc/systemd/resolved.conf.d/TEST.confsystemctl restart systemd-resolved.service

modules in initrd:

mount /dev/mmcblk0p6 /mntmkdir /lib/modulesmkdir /lib/firmwaremount -o bind /mnt/lib/modules /lib/modulesmount -o bind /mnt/lib/firmware /lib/firmwaremodprobe mt7996eopenwrtupstream

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 -amake 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

Resize rootfs: https://forum.banana-pi.org/t/bpi-r3-mini-how-to-extend-emmc-overlayfs/17732/43

downstream (sdk)clone openwrt masteradd this to feeds.conf.default: “src-git mtksdk https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds”scripts/feeds update -f mtksdkmake menuconfig:Target System (MediaTek Ralink ARM)Subtarget (Filogic 8×0 (MT798x))Target Profile (MediaTek MT7988a nand rfb) #here i see no sd-variant

adding additional options:

CONFIG_PACKAGE_f2fs-tools=yCONFIG_PACKAGE_e2fsprogs=yCONFIG_PACKAGE_dosfstools=yCONFIG_PACKAGE_resize2fs=yCONFIG_PACKAGE_nano=yCONFIG_PACKAGE_iperf3=y#CONFIG_PACKAGE_netcatCONFIG_PACKAGE_tcpdump=yCONFIG_BUSYBOX_CUSTOM=yCONFIG_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/kerneldumpimage -l sysupgrade-mediatek_mt7988a-rfb-nand/kerneltftpboot 0x50000000 openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itbbootm 0x50000000#config-mt7988a-bananapi-bpi-r4#mt7988a-bananapi-bpi-r4-sdGentoo

https://gist.github.com/BtbN/9e5878d83816fb49d51d1f76c42d7945

0 阅读:0

开源不如不打烊

简介:感谢大家的关注