BPI-R2 OpenWRT(LEDE) Support

image

Source code(Please note that the branch is bpi-r2-on-lede-v1)

Configurion of LEDE

TARGET=MediaTek Ralink ARM Boot Loaders=u-boot-bpi_r2 (This option is mandatory) …

How to build

make -j1 V=s

Images

When above steps is done, we will below two images under /build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-mediatek_32/:

mtk-bpi-r2-EMMC.img
mtk-bpi-r2-SD.img

How to use SD image

A SD card is requried and then install mtk-bpi-r2-SD.img to SD card by running below command: dd if=mtk-bpi-r2-SD.img of=/dev/sdb where /dev/sdb is the SD card.

And then install the SD card to R2 board, power it on, the board will boot from SD card.

How to use EMMC image

We need another system which is running on SD card to program EMMC image to EMMC, please follow below steps to do:

1. Copy EMMC image to a running system which is on SD card
2. Program EMMC image to User Data Area of EMMC: dd if=mtk-bpi-r2-EMMC.img of=/dev/mmcblk0
3. Unlock EMMC boot0 block: echo 0 > /sys/block/mmcblk0boot0/force_ro
4. Program preloader to EMMC boot0 block:
     dd if=mtk-bpi-r2-EMMC.img of=/dev/mmcblk0boot0 bs=1M count=1
5. Change the Partition configurion of EMMC is 48h: reboot the system which is running SD, and enter the 
    U-boot command line, run command
          _emmc pconf 48_
6. Power off, remove SD card, and then power on R2 board.

How to update by using sysupgrade

The sysupgrade image is located in “bin/targets/mediatek/32/”, and the upgrade command is sysupgrade lede-mediatek-32-bananapi,bpi-r2-sysupgrade.tar

Supported Features

  1. Two ethernet interfaces and hardware NAT
  2. USB2.0 and USB3.0
  3. SATA interface
  4. Embedded WIFI module (MT6625)
  5. PCIe interface
1 Like

@garywang Could you make it boot? I use git pull to update local code. When I make again and try to boot it in SD card. It print : jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x********: 0x**** instead

Finally, I roll back this and it works:

target/linux/mediatek/image/make_bundle_image.sh

line 25  -ROOTFS_OFFSET=67584  # 67584KB
            +ROOTFS_OFFSET=66816  # 66816KB

Should I Keep this change or run make dirclean :thinking:

Another question: Does the file “target/linux/mediatek/base-files/etc/config/network” lose “config i” in line 1

I try make dirclean and make it again. It does not work either. But it’s weird that after I clone the code again in a new directory and make. It works. :no_mouth:

what’s wrong? I try diff two code’s target. Nothing different, except my own macaddress in target/linux/mediatek/patches-4.9/0060-allow-bananpi-r2-dts-boot.patch

git diff LEDE-git/bpi-r2_lede/target LEDE/bpi-r2_lede/target

diff --git a/LEDE-git/bpi-r2_lede/target/linux/mediatek/patches-4.9/0060-allow-bananpi-r2-dts-boot.patch b/LEDE/bpi-r2_lede/target/linux/mediatek/patches-4.9/0060-allow-bananpi-r2-dts-boot.patch
index f0b04a6…a9c5413 100644
— a/LEDE-git/bpi-r2_lede/target/linux/mediatek/patches-4.9/0060-allow-bananpi-r2-dts-boot.patch
+++ b/LEDE/bpi-r2_lede/target/linux/mediatek/patches-4.9/0060-allow-bananpi-r2-dts-boot.patch
@@ -882,7 +882,7 @@ Index: linux-4.9.44/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
          compatible = “mediatek,eth-mac”;
          reg = <0>;
          phy-mode = “trgmii”;
-+
++      mac-address = [02 70 C6 F3 0C BA];
          fixed-link {
              speed = <1000>;
              full-duplex;

Could anybody give me an answer. I think there have some body upgrade the code from last updated.

Now, openwrt trunk natively support bpi-r2 with kernel 4.14. https://github.com/openwrt/openwrt/commit/7762c07c88980cff85ec20c12f18cd172260e9d9

1 Like

is dual-gmac and hw-nat available for 4.14?

edit: https://github.com/openwrt/openwrt/blob/7762c07c88980cff85ec20c12f18cd172260e9d9/target/linux/mediatek/patches-4.14/0033-dsa-multi-cpu.patch looks nice for 2gmac :slight_smile:

patch-overview:

Original mtkhnat was based on native netfilter hook, but new infrastructure of hardware NAT offload engine will come up soon, so HNAT feature will be added back when it is ready. http://patchwork.ozlabs.org/patch/852537/

I have ported the most parts (also new netfilter hooks from 4.13/4.14),but it failed by selecting the upstream-port which was not preset in default 4.14. Maybe now (with your cpu-port-patches) it works…you can take a look in my hnat-branch

@moore patch https://github.com/openwrt/openwrt/blob/7762c07c88980cff85ec20c12f18cd172260e9d9/target/linux/mediatek/patches-4.14/0046-net-mediatek-add-irq-delay.patch looks a bit strange (added only a commented line)

anyway i applied successful all patches in new branch gmac (copy of main with 4.14.19) for testing:

build successful and and uploaded to my gdrive,

booted up, and it looks well:

ifconfig
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group defau0
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP g0
    link/ether aa:6b:a3:8a:e9:89 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a86b:a3ff:fe8a:e989/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qle0
    link/ether 92:56:84:14:ad:e8 brd ff:ff:ff:ff:ff:ff
4: wan@eth1: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN group 0
    link/ether 92:56:84:14:ad:e8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.50.1/24 brd 192.168.50.255 scope global wan
       valid_lft forever preferred_lft forever
5: lan0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP0
    link/ether 02:01:02:03:04:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global lan0
       valid_lft forever preferred_lft forever
    inet6 fe80::1:2ff:fe03:400/64 scope link 
       valid_lft forever preferred_lft forever
6: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master0
    link/ether aa:6b:a3:8a:e9:89 brd ff:ff:ff:ff:ff:ff
7: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master0
    link/ether aa:6b:a3:8a:e9:89 brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group defaul0
    link/ether aa:6b:a3:8a:e9:89 brd ff:ff:ff:ff:ff:ff
9: wlan1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default ql0
    link/ether f8:62:aa:50:12:1d brd ff:ff:ff:ff:ff:ff
10: wan.60@wan: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN gro0
    link/ether 02:01:02:03:04:03 brd ff:ff:ff:ff:ff:ff
11: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 0
    link/ether aa:6b:a3:8a:e9:89 brd ff:ff:ff:ff:ff:ff
    inet 192.168.40.1/24 brd 192.168.40.255 scope global br0
       valid_lft forever preferred_lft forever

have no time today to test it further…

Btw in the patches internal wifi is missing you can use that for a patch

And this fix

Bluetooth is currently not working…if you know why please share it with me

i tried to set mac-adress to the ethx, but it seems that this mac is not used for lanx/wan

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP gr
oup default qlen 1000
    link/ether 02:01:02:03:04:00 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::1:2ff:fe03:400/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP gr
oup default qlen 1000
    link/ether 02:01:02:03:04:03 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::1:2ff:fe03:403/64 scope link 
       valid_lft forever preferred_lft forever
4: wan@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP g
roup default qlen 1000
    link/ether 86:58:49:d5:96:50 brd ff:ff:ff:ff:ff:ff
    inet 192.168.50.1/24 brd 192.168.50.255 scope global wan
       valid_lft forever preferred_lft forever
    inet6 fe80::8458:49ff:fed5:9650/64 scope link 
       valid_lft forever preferred_lft forever
5: lan0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
group default qlen 1000
    link/ether 3a:93:89:61:25:cc brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global lan0
       valid_lft forever preferred_lft forever
    inet6 fe80::3893:89ff:fe61:25cc/64 scope link 
       valid_lft forever preferred_lft forever
6: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master 
br0 state LOWERLAYERDOWN group default qlen 1000
    link/ether 3a:93:89:61:25:cc brd ff:ff:ff:ff:ff:ff
7: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master 
br0 state LOWERLAYERDOWN group default qlen 1000
    link/ether 3a:93:89:61:25:cc brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
 qlen 1000
    link/ether 3a:93:89:61:25:cc brd ff:ff:ff:ff:ff:ff
11: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN g
roup default qlen 1000
    link/ether 3a:93:89:61:25:cc brd ff:ff:ff:ff:ff:ff
    inet 192.168.40.1/24 brd 192.168.40.255 scope global br0
       valid_lft forever preferred_lft forever

lanx and wan getting own random macs…traffic itself works on wan…

if i set the mac on lan0 and wan it will be used, but only for these ports:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP gr
oup default qlen 1000
    link/ether aa:cf:60:36:70:5e brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a8cf:60ff:fe36:705e/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP gr
oup default qlen 1000
    link/ether ba:1e:01:5a:05:0f brd ff:ff:ff:ff:ff:ff
    inet6 fe80::b81e:1ff:fe5a:50f/64 scope link 
       valid_lft forever preferred_lft forever
4: wan@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP g
roup default qlen 1000
    link/ether 02:01:02:03:04:03 brd ff:ff:ff:ff:ff:ff
    inet 192.168.50.1/24 brd 192.168.50.255 scope global wan
       valid_lft forever preferred_lft forever
    inet6 fe80::1:2ff:fe03:403/64 scope link 
       valid_lft forever preferred_lft forever
5: lan0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
group default qlen 1000
    link/ether 02:01:02:03:04:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global lan0
       valid_lft forever preferred_lft forever
    inet6 fe80::1:2ff:fe03:400/64 scope link 
       valid_lft forever preferred_lft forever
6: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master 
br0 state LOWERLAYERDOWN group default qlen 1000
    link/ether aa:cf:60:36:70:5e brd ff:ff:ff:ff:ff:ff
7: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master 
br0 state LOWERLAYERDOWN group default qlen 1000
    link/ether aa:cf:60:36:70:5e brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
 qlen 1000
    link/ether aa:cf:60:36:70:5e brd ff:ff:ff:ff:ff:ff

do i need to set mac for each port separately?

i have the ability to set it for each port:

root@bpi-r2:~# ifconfig lan0
5: lan0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
group default qlen 1000
    link/ether 02:01:02:03:04:10 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global lan0
       valid_lft forever preferred_lft forever
    inet6 fe80::1:2ff:fe03:410/64 scope link 
       valid_lft forever preferred_lft forever
root@bpi-r2:~# ifconfig lan3
8: lan3@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
 qlen 1000
    link/ether 02:01:02:03:04:13 brd ff:ff:ff:ff:ff:ff

i have another problem…i cannot send ping over lan0, link comes up, but no traffic

last patch adds a block

memory {
	reg = <0 0x80000000 0 0x20000000>;
};

to bananapi.dts

but i have also

memory@80000000 {
	reg = <0 0x80000000 0 0x40000000>;
};

maybe this can be a problem, but that block seems to be default in 4.14

with 4.14.18-main not problem with the same config

i also see a warning on compile (i don’t know why i did not see that yesterday):

arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dtb: Warning (reg_format): "reg" property in /switch@0 has invalid length (4 bytes) (#address-cells == 2, #size-cells == 2)

i did not understand this error message…

that block is meant by the warning, right?

mt7530: switch@0 {
    compatible = "mediatek,mt7530";
};

maybe the problem is mt7530-definition here:

    &mt7530 {
        compatible = "mediatek,mt7530";
        #address-cells = <1>;
        #size-cells = <0>;
        reg = <0>;  // is that the problem??
        ...

if i disable the reg-property in &mt7530, the warning has gone…but also no ping over lan0, also with disabled old memory block still no traffic…have set down lan0 and eth0 and up again eth0+lan0…still the same

tried with native (unmodified) 4.14.11 (patches are build for that) and applied again all patches

mmcpatch is not included (arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts):

&mmc1 {
...
    //cd-gpios = <&pio 261 0>;
    cd-gpios = <&pio 261 GPIO_ACTIVE_LOW>;

i did that and as my previous assumtion, memory-block exists already in 4.14 and is not based on my patches in main-branch…

have now swapped mmc0 with mmc1 in mt7623.dtsi to start my debian-system from /dev/mmcblk0p2

now with that /etc/network/interfaces:

auto eth0
iface eth0 inet manual
  pre-up ip link set $IFACE up

auto eth1
iface eth1 inet manual
  pre-up ip link set $IFACE up

auto wan
iface wan inet static
  address 192.168.50.1
  netmask 255.255.255.0
  #rpi is 50.2

auto wan.60
iface wan.60 inet static
  address 192.168.60.1
  netmask 255.255.255.0

auto lan0
iface lan0 inet static
  #hwaddress ether 08:00:00:00:00:00 # if you want to set MAC manually
  address 192.168.0.10
  netmask 255.255.255.0
  gateway 192.168.0.5

auto br0
iface br0 inet static
    address 192.168.40.1
    netmask 255.255.255.0
    bridge_ports lan1 lan2
    bridge_fd 5
    bridge_stp no

allow-hotplug lan3
iface lan3 inet dhcp

source-directory /etc/network/interfaces.d

my network-state is that:

root@bpi-r2:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 32:82:e7:cc:ae:d0 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::3082:e7ff:fecc:aed0/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 1e:a6:33:e4:2d:41 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::1ca6:33ff:fee4:2d41/64 scope link 
       valid_lft forever preferred_lft forever
4: wan@eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether 1e:a6:33:e4:2d:41 brd ff:ff:ff:ff:ff:ff
    inet 192.168.50.1/24 brd 192.168.50.255 scope global wan
       valid_lft forever preferred_lft forever
5: lan0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 32:82:e7:cc:ae:d0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global lan0
       valid_lft forever preferred_lft forever
    inet6 fe80::3082:e7ff:fecc:aed0/64 scope link 
       valid_lft forever preferred_lft forever
6: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br0 state LOWERLAYERDOWN group default qlen 1000
    link/ether 32:82:e7:cc:ae:d0 brd ff:ff:ff:ff:ff:ff
7: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br0 state LOWERLAYERDOWN group default qlen 1000
    link/ether 32:82:e7:cc:ae:d0 brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 32:82:e7:cc:ae:d0 brd ff:ff:ff:ff:ff:ff
9: wan.60@wan: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether 1e:a6:33:e4:2d:41 brd ff:ff:ff:ff:ff:ff
    inet 192.168.60.1/24 brd 192.168.60.255 scope global wan.60
       valid_lft forever preferred_lft forever
10: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 32:82:e7:cc:ae:d0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.40.1/24 brd 192.168.40.255 scope global br0
       valid_lft forever preferred_lft forever

as you see eth0 and eth1 are up, also lan0 but i can’t ping my server, whih is pingable with main-kernel (4.14.18 without the lede patches) and from my client which is connected to the same switch

also tried without the br0 (which was only a test-configuration), same result

any hints??

Sorry for my late response, because we had a long holiday.

The offset of rootfs is passed to kernel from Uboot, if the code of uboot is not updated to latest, you will face this problem, so can you please do below steps to have a try: please don’t change the target/linux/mediatek/image/make_bundle_image.sh, still use ROOTFS_OFFSET=67584 # 67584KB, and then;

  1. make distclean
  2. remove the file /dl/uboot
  3. make -j1 V=s

Yes, I will fix this issue.

Thanks for your information.

This problem has been fixed, please check the commit https://github.com/garywangcn/bpi-r2_lede/commit/f0f934f50f207585aa91172e887d39c703bac727

How can i post an issue for the new mediatek-patches in main openwrt/repo? Issues tab seems to be disabled…

Lan-ports/eth0 not working and i have still no response here :pensive:

Hi Frank

This is an known limitation, only br-lan and wan are available, but we can get the statistics of switch ports from these interface, for example: ethtool -i lan0

i have used these 4.14-patches for my repo to get the second gmac working. i have not bridged lan-ports.

if i map lan0 to eth1 (same as wan) lan0 works…but not with with only the patches…so it seems that eth0 has no traffic

How does one install kmod-wireguard on this baby? Seems like no way to add it…

Here is the error that I get, when doing feeds update && feeds install

Installing package 'luci-app-wireguard' from luci
WARNING: No feed for package 'wireguard-tools' found, maybe it's already part of the standard packages?
WARNING: No feed for package 'kmod-wireguard' found, maybe it's already part of the standard packages?
Installing package 'luci-proto-wireguard' from luci
WARNING: No feed for package 'kmod-wireguard' found, maybe it's already part of the standard packages?
WARNING: No feed for package 'wireguard-tools' found, maybe it's already part of the standard packages?

Any help is highly appreciated.

Thanks!