[BPI-R2] Kernel Development

Imho not…i only booted it up :slight_smile: and i have not loaded mtk_ahci…so this should not be the issue

Likely it was mt76, as i had to reload its driver modules, while internal wifi was functional. I just got this message one, and can’t reproduce it.

SATA seems to be working fine now on 5.4.2 after a new build. I guess something went wrong when I did my original config merging. For the first time I am seeing clean network traffic out the lanX ports no loss no re-transmits. I can actually get the sort of throughput I would expect on gigE!

My other hardware works too, so this is a big improvement over running on the 4.14 branch.

The only thing that isn’t working is the wan port. I really only need four ports so I was able to just stick udev rule into rename wan to dne, and then rename lan3 to wan, which lets all my firewall configs work without modification and keeps the interface names sensible. Basically everything is working now pretty much the way I would want. - THANK YOU SO MUCH frank-w for all the hard work and help on this.

I suppose if hnat ever gets into the 5.4.x kernels I won’t be able to use it with this configuration but my internet service is only about 4Mbps anyway so NAT in software isn’t really a bottleneck.

I am of course curious about what is going on with the nominal wan interface under 5.4.2. So far I have been tinkering with this as best I can without pulling it out of the closet. I’ll put a laptop on the other end of it this weekend to see what wireshark can tell me. It curious because if try a ping I see the counters increase. I did an “arp-ping” to the assigned MAC the other day when I tried patching it into my switch and that also made the counters increase. Did not tcp dump at the time unfortunately.

One thing I do see in the early dmesg output is:

[    8.137923] mt7530 mdio-bus:1f lan0 (uninitialized): PHY [dsa-0.0:01] driver [Generic PHY]
[    8.138837] mt7530 mdio-bus:1f lan1 (uninitialized): PHY [dsa-0.0:02] driver [Generic PHY]   
[    8.139642] mt7530 mdio-bus:1f lan2 (uninitialized): PHY [dsa-0.0:03] driver [Generic PHY]
[    8.140409] mt7530 mdio-bus:1f lan3 (uninitialized): PHY [dsa-0.0:04] driver [Generic PHY]

but nothing for wan interface so there may be clue there. However I do see the line protocol go up and down when there link so I don’t think its like the transceiver isn’t being turned on…

I am where I need to be at the moment but if I make any useful discoveries I’ll share here in case they can help anyone else.

currently i do not know whats wrong with wan-port…you can try to revert my modification so that it works over gmac0

I can do that. I’ll probably hold off until Sunday (US-Eastern) to tinker more. I do want grab some packet captures and stuff first, so I know what that port is doing on the wire rather than speculating and see if anything like manually assinging vlan0 or similar puts it into working state.

Do I need to rebuild the kernel again? Or can I use dtc to compile the DTS and just append it to the existing zImage, then make a new uImage from that?

if you have not made make clean most should be compiled a o-file and only linking happens…i also use ccache in my build.sh which speeds up compilation-process

if you still have your zImage you can compile dts (not that easy) and append it again with mkimage

Regarding your dmesg…it lists dsa-ports. In y repo wan is taken off mdio-bus because it’s basicly gmac1 renamed no dsa port

Hello everybody,

even if I’m not an expert about Kernel development, I’m passionate about Home Automation and I purchased the BPI-R2 with the idea to design and build a Home Automation hub (data + HA network).

I must say that it is not an easy endevour. I expected more support from the chinese manifacturer, instead everything relies on the effort of you people: thanks a lot.

After several silent tests (Debian, OpenWRT, OpenMPTCPRouter, Offcial and non-official, etc.), I’ve come to the conclusion that my final target will be OpenWRT, but the official SW is not yet mature. So I’m currently testing everything in Debian with Franck’s kernels.

As I have purchased the PCIe MT7615e for Wifi coverage, I’m currently testing the 5.4-Main branch, where the Wifi device driver is mainstream.(I will post some comments in the dedicated forum article).

Related to the Kernel (5.4-Main), I have the problem about the 2nd GMAC: eth1 interface is not recognized. I had to redo the network and firewall configuration compared to the previous kernel version (4.14, 4.19)

A part from this, I must say that I’m impressed by the level of maturity and stability of the kernel 5.4.

I do not want to waste your time reading my post; just want to let you know that I’m an availble tester and if you want to “use” me, do not hesitate; please be precise and patient as I am not a big expert…

Andrea.

i disabled second gmac because some users reported it to be broken…but this should not disturb you…wan is routed over 1st gmac and your firewall should be based on dsa-interfaces (wan,lanX) or virtual interfaces (bridges, vlans, …).

i found out that all ports working over additional switch, but not if pc is connected directly to r2 with 5.4

In the end I managed to configure all routing and firewall and everything is working as expected

In my case it is working even connecting the PC directly to LAN ports.

How have you configured lan-ports/gmac?

Using my 5.4-main?

This is the network configuration file:

etc-network-interfaces.txt (1,3 Ko)

And yes it is based on your 5.4-main re-compiled to get the mt7615e module (no other changes to the config).

Ok,currently i see only bridge of lan-ports as difference…need to test it on my device with pc directly connected

it seems that creating a software-bridge solves the direct-connect issue on 5.4+ (testing on lan2)

brctl addbr br0
brctl addif br0 lan1
brctl addif br0 lan2
ip addr add 192.168.40.1/24 dev br0
ip link set br0 up
ip link set lan2 up

and got no “NO-CARRIER” on the other side…ping works. to verify it is no other cause i simply moved IP and cable to lan3, not changing anything on pc-side

root@bpi-r2:~# ip addr del 192.168.40.1/24 dev br0                              
root@bpi-r2:~# ip addr add 192.168.40.1/24 dev lan3        
root@bpi-r2:~# ip link set lan3 up

now on the other side:

5: enx3c18a003c3a4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether 3c:18:a0:03:c3:a4 brd ff:ff:ff:ff:ff:ff
frank@frank-G5:~$ ethtool enx3c18a003c3a4
Settings for enx3c18a003c3a4:
	Supported ports: [ TP MII ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Half 1000baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: Symmetric Receive-only
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Link partner advertised link modes:  10baseT/Half 10baseT/Full 
	                                     100baseT/Half 100baseT/Full 
	                                     1000baseT/Full 
	Link partner advertised pause frame use: Symmetric Receive-only
	Link partner advertised auto-negotiation: Yes
	Link partner advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Port: MII
	PHYAD: 32
	Transceiver: internal
	Auto-negotiation: on
Cannot get wake-on-lan settings: Operation not permitted
	Current message level: 0x00007fff (32767)
			       drv probe link timer ifdown ifup rx_err tx_err tx_queued intr tx_done rx_status pktdata hw wol
	Link detected: no
frank@frank-G5:~$

Hello,

I’ve worked on the 5.4-main kernel to add and validate the following features: VLAN, NAT, netfilter (iptables, nftables).

The config file in attachment is based on netfilter configuration section from official debian kernel 5.3.

You can get my tests below to validate all fonctionnality:

Tests

Vlan:

—> WAN

BPI-R2:

ip link add link wan name wan.200 type vlan id 200
ip addr add 192.168.200.254/24 dev wan.200
ip link set wan up
ip link set wan.200 up

Remote direct linked machine:

ip link add link enp0s25 name enp0s25.200 type vlan id 200
ip addr add 192.168.200.50/24 dev enp0s25.200
ip link set enp0s25 up
ip link set enp0s25.200 up

ping 192.168.100.254 —> OK

—> LAN
BPI-R2:

ip link add link lan2 name lan2.100 type vlan id 100
ip addr add 192.168.100.254/24 dev lan2.100
ip link set lan2 up
ip link set lan2.100 up

Remote switched linked machine:

ip link add link br1 name br1.100 type vlan id 100
ip addr add 192.168.100.10/24 dev br1.100
ip link set br1 up
ip link set br1.100 up

ping 192.168.100.254 —> OK

NAT: wan to lan (DNAT)

NAT backend:

ip addr add 192.168.200.10/24 dev br1
ip link set br1 up
ip route add 10.0.0.10/32 gw 192.168.200.254 dev br1 (default route is on br0 bridge)

BPI-R2:

ip addr add 192.168.200.254/24 dev lan3
ip link set lan3 up

ping 192.168.200.10 —> OK

ip addr add 10.0.0.254/24 dev wan
ip link set wan up

sysctl -w net.ipv4.ip_forward="1" --> "Active forward between interfaces (lan <--> lan and lan <--> wan
iptables -t nat -A PREROUTING -p tcp --dport 22 -i wan -j DNAT --to 192.168.200.10:22 --> Destination NAT
    or
nft add table nat
nft add chain nat prerouting '{ type nat hook prerouting priority 0 ; }'
nft add chain nat postrouting '{ type nat hook postrouting priority 0 ; }'
nft add rule nat prerouting iif wan tcp dport 22 dnat 192.168.200.10

NAT frontend:

ip addr add 10.0.0.10/24 dev enp0s25
ip link set enp0s25 up

ssh 10.0.0.254 —> OK

NAT: wan to lan (DNAT) + VLAN LAN + VLAN WAN

Reproduce the VLAN configuration on LAN and WAN (see above)

On NAT backend:

route add -net 192.168.200.0/24 gw 192.168.100.254 dev br1.100

BPI-R2:

sysctl -w net.ipv4.ip_forward="1" --> "Active forward between interfaces (lan <--> lan and lan <--> wan

nft add chain nat prerouting '{ type nat hook prerouting priority 0 ; }'
nft add chain nat postrouting '{ type nat hook postrouting priority 0 ; }'
nft add rule nat prerouting iif wan.200 tcp dport 22 dnat 192.168.100.10

ssh 192.168.200.254 —> OK

NFTables: based on Vlan configuration

nft add table inet filter

Input:
From NAT backend: ssh 192.168.100.254 —> OK

nft add chain inet filter input '{ type filter hook input priority 0 ; }'
nft add rule inet filter input ct state established accept ---> permit my ssh connection on lan0
nft add chain inet filter input '{ type filter hook input priority 0 ; policy drop; }'

From NAT backend: ssh 192.168.100.254 —> BLOCKED

nft add rule inet filter input ip saddr 192.168.100.10 accept

From NAT backend: ssh 192.168.100.254 —> OK

Output:
From BPI-R2: ssh 192.168.100.10 —> OK

nft add chain inet filter output '{ type filter hook output priority 0 ; }'
nft add rule inet filter output ct state established accept  ---> permit my ssh connection on lan0
nft add chain inet filter output '{ type filter hook output priority 0 ; policy drop ; }'

From BPI-R2: ssh 192.168.100.10 —> BLOCKED

nft add rule inet filter output ip saddr 192.168.100.254 accept

From BPI-R2: ssh 192.168.100.10 —> OK

Forward chain:
From NAT frontend: ssh 192.168.200.254 —> OK (acces to backend)

nft add chain inet filter forward '{type filter hook forward priority 0 ; policy drop ; }'

From NAT frontend: ssh 192.168.200.254 —> BLOCKED

nft add rule inet filter forward iifname "lan2.100" oifname "wan.200" accept
nft add rule inet filter ip saddr 192.168.200.50 accept

From NAT frontend: ssh 192.168.200.254 —> OK (acces to backend)

Iptables: based on Vlan configuration

Input:
From NAT backend: ssh 192.168.100.254 —> OK

iptables -A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT ---> permit my ssh connection on lan0
iptables -P INPUT DROP

From NAT backend: ssh 192.168.100.254 —> BLOCKED

iptables -A INPUT -p tcp --source 192.168.100.10 --dport 22 -j ACCEPT

From NAT backend: ssh 192.168.100.254 —> OK

Output:
From BPI-R2: ssh 192.168.100.10 —> OK

iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT ---> permit my ssh connection on lan0
iptables -P OUTPUT DROP

From BPI-R2: ssh 192.168.100.10 —> BLOCKED

iptables -A OUTPUT -p tcp --source 192.168.100.254 --dport 22 -j ACCEPT

From BPI-R2: ssh 192.168.100.10 —> OK

Forward chain:
From NAT frontend: ssh 192.168.200.254 —> OK (acces to backend)

iptables -P FORWARD DROP

From NAT frontend: ssh 192.168.200.254 —> BLOCKED

iptables -A FORWARD -i lan3.100 -o wan.200 -j ACCEPT
iptables -A FORWARD -p tcp --source  192.168.200.50 -j ACCEPT

From NAT frontend: ssh 192.168.200.254 —> OK (acces to backend)

Don’t hesitate if you want that I test other configuration(s).

config (144,1 Ko)

1 Like

Hi,thank you for tests,so all is working as expected? Nok looks like intended (lile forwarding block,missing+related in iptables ct)

Hi

All posted tests work fine. NOK don’t mean that test is not good but traffic is blocked as expected. I can replace it by “Blocked” if you want (and if you find it more readable) --> replaced on my post

Related is deprecated for security reason on protocol that don’t need it (https://gist.github.com/azlux/6a70bd38bb7c525ab26efe7e3a7ea8ac). I forgot to remove it on nftables command.

Hello @frank-w is it posible to get your 4.19 (main?) mali patches?

Or need to get 4.20-mali?

btw I like to test 5.4 but: :~/src/frank$ git clone https://github.com/frank-w/BPI-R2-4.14/tree/5.4-main Cloning into ‘5.4-main’… fatal: repository ‘https://github.com/frank-w/BPI-R2-4.14/tree/5.4-main/’ not found

Something missing?

In 4.19 I have to say: echo 0 > /sys/class/graphics/fb0/blank To enable HDMI console. Is there some fbconsole boot arguments to put kernel command line to directly activate HDMI signal? There is also /sys/module/kernel/parameters/consoleblank parameter 0, default should be 600 (boot argument consoleblank=600 fix it)

Also is it posible to put “boot” button (in three button row) to do board booting/halt so it is posible to solder orginal powerbutton on position…? (Router should default to on from power shortages)

Is there any information about board battery management chip. So where I should solder lithium battery and how to implement upsd to listen to management chip? Or should I put 12v car battery and put some I2C circuit to monitor battery voltage and use i2cupsd?

Any information how overclock mt7623? New DTS? I use gentoo and compile stuff in R2 board so some more clock speed may help. (I have heatsink to glue on chip) (infact board compile stuff guite well, but faster is better). I working to get gentoo image to publish included mali powered X(or wayland) etc.

hi all,

i have rebased 5.4-main to include r64-code so i need to update only one branch for both boards

just edit build.conf and change board to bpi-r64 if you want to build for this one. after that follow the known way with ./build.sh (importconfig, config, without param)

@eros Your error with 5.4-main may be caused by my rework of this branch…just do a fetch and reset to origin/5.4-main

Mali should be included in 5.4 but i do not have any information what is missing…i did a mali-branch for 4.20 or later where i added what i have (only dts nodes and config-option)

Battery-chip was reported by garywang as not working and is removed with v1.1

Hdmi is working on my tests also with framebuffer…i set only resolution in cmdline

I have no info for overclocking and have not tried yet

It is still same: git clone https://github.com/frank-w/BPI-R2-4.14/tree/4.20-mali Cloning into ‘4.20-mali’… fatal: repository ‘https://github.com/frank-w/BPI-R2-4.14/tree/4.20-mali/’ not found git clone https://github.com/frank-w/BPI-R2-4.14/tree/4.20-lima Cloning into ‘4.20-lima’… fatal: repository ‘https://github.com/frank-w/BPI-R2-4.14/tree/4.20-lima/’ not found git clone https://github.com/frank-w/BPI-R2-4.14/tree/5.4-main Cloning into ‘5.4-main’… fatal: repository ‘https://github.com/frank-w/BPI-R2-4.14/tree/5.4-main/’ not found git clone https://github.com/frank-w/BPI-R2-4.14/orgin/5.4-main Cloning into ‘5.4-main’… remote: Not Found fatal: repository ‘https://github.com/frank-w/BPI-R2-4.14/orgin/5.4-main/’ not found etc…

Yes I’ll test when get it out… In your 4.19 there is mali but for 500 + not 450 which is in board. (compiled by your default config)

HDMI is working but it is default off. (ubuntu/debian/etc turn it on in boot, somewhere in initrd etc. but gentoo don’t do it by default) It take lot of search to find out why my monitor keep off… You can notice it monitor come on after kernel is up, but correct bootparam it can turn on during kernel booting.

Overclocking is somwere in dts ot bootloader dts equivalent. Maybe doable. I glued heatsink just on to mt7623 and temp shows 42C. But when put acrylic case closed cputemp jumps 49C. Case is idiotick it have bottom holes to take air in but no upper holes to remove hot air. Need maybe drill some holes to cover plate…
(cat /sys/class/thermal/thermal_zone0/temp if not common knowhow…) I run it whith “performance” governor. Need some kernel sources to compile and check temp then…

Correct command to clone is: git clone https://github.com/frank-w/BPI-R2-4.14/ orgin/5.4-main

It needs only one space… Edit: No it clone whole repo aarhg…

Downloading from web button .zip archive seems to works but how to do it with git??

git clone --depth=10 --single-branch --branch=5.4-main https://github.com/frank-w/BPI-R2-4.14
git checkout 5.4-main

This uses kernel driver instead of external lima driver.

https://github.com/frank-w/BPI-R2-4.14/commits/5.3-lima

Imho more changes are needed to mesa and maybe other