[BPI-R2] Kernel Development

kernel 5.4 is now finally released so i have updated my repo and added 5.4-main and uploaded binary-kernels on my gdrive

https://drive.google.com/open?id=1WnmFOaHjXp8oSYinGaL7khKlA4l21Dmc

3 Likes

This kernel version contains a module for wireguard ?

imho only the basic layer for encryption was merged in 5.5, 5.4 needs wireguard manually added

Hi frank, thank you for your very good job for this development.

If I can just add 2 comments. I compiled the 5.4-main kernel and installed it on the debian buster distribution (yours).

First, on the buster debian version, the iptables command returns the following:

root@bpi-r2:~# iptables -nL
iptables: Operation not supported.

On Buster, netfilter uses the new standard module named nftables instead of iptables legacy. To make continuity on all distributions, the iptables command pointed on new nft iptables:

root@bpi-r2:~# update-alternatives --config iptables
There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).

  Selection    Path                       Priority   Status
------------------------------------------------------------
* 0            /usr/sbin/iptables-nft      20        auto mode
  1            /usr/sbin/iptables-legacy   10        manual mode
  2            /usr/sbin/iptables-nft      20        manual mode

Press <enter> to keep the current choice[*], or type selection number:

When you change the alternative to iptables-legacy, iptables command works. When I checked the kernel config, the NF_TABLES config is not available (as module or installed).

I compiled a new kernel with NF_TABLES as module and now, iptables command (based on iptables-nft) works. Since NFT is the new standard for network filtering command, I think that It is good to be activated by default on all new kernels.

Second, I have problem with fixed IP address on lan when I installed the new kernel (deb package) on R2. 9 of 10 times, ping the network gateway doesnā€™t work on the first boot on the kernel. When I reboot, generally the ping to gateway works.

I never have a network lost when the gateway was pinged one time, but one time I have never pinged the gateway after 10 rebootsā€¦

My network configuration file:

root@bpi-r2:~# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
auto lo
iface lo inet loopback

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

auto lan0
iface lan0 inet static
  hwaddress ether 08:00:00:00:00:01 # if you want to set MAC manually
  address 192.168.1.46
  netmask 255.255.255.0
  gateway 192.168.1.254
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

source-directory /etc/network/interfaces.d

Is only CONFIG_NF_TABLES needed? I guessed i had them included in defconfigā€¦seems notā€¦so i will add

For network issueā€¦how old is your 5.4-main kernel? I fixed a wrong dts setting yesterday which may affect lan-ports

yesterday too (in afternoon, CEST timezone). Iā€™ve just pull from your git, I have the following changes:

remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 18 (delta 10), reused 16 (delta 9), pack-reused 0
DƃĀ©paquetage des objets: 100% (18/18), fait.
Depuis https://github.com/frank-w/BPI-R2-4.14
   cef42756642e..09639ebc2ff4  5.4-main   -> origin/5.4-main
Mise ƃ  jour cef42756642e..09639ebc2ff4
Fast-forward
 arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts |  3 +--
 arch/arm/configs/mt7623n_evb_fwu_defconfig    |  1 +
 build.sh                                      | 22 ++++++++++++++++++----
 3 files changed, 20 insertions(+), 6 deletions(-)

I will try with this new version.

I think (I have not tested) that CONFIG_NF_TABLES is the minimum to run nft. Personnaly I have the following configuration (depending of filter utilization):

CONFIG_NF_TABLES=m
CONFIG_NF_TABLES_SET=m
CONFIG_NF_TABLES_INET=y
CONFIG_NF_TABLES_NETDEV=y
CONFIG_NFT_NUMGEN=m
CONFIG_NFT_CT=m
# CONFIG_NFT_FLOW_OFFLOAD is not set
CONFIG_NFT_COUNTER=m
CONFIG_NFT_CONNLIMIT=m
CONFIG_NFT_LOG=m
CONFIG_NFT_LIMIT=m
CONFIG_NFT_MASQ=m
CONFIG_NFT_REDIR=m
CONFIG_NFT_NAT=m
CONFIG_NFT_TUNNEL=m
CONFIG_NFT_OBJREF=m
CONFIG_NFT_QUOTA=m
CONFIG_NFT_REJECT=m
CONFIG_NFT_REJECT_INET=m
CONFIG_NFT_COMPAT=m
CONFIG_NFT_HASH=m
CONFIG_NFT_XFRM=m
CONFIG_NFT_SOCKET=m
CONFIG_NFT_OSF=m
CONFIG_NFT_TPROXY=m
CONFIG_NFT_SYNPROXY=m
CONFIG_NFT_DUP_NETDEV=m
CONFIG_NFT_FWD_NETDEV=m

CONFIG_NF_TABLES_IPV4=y
CONFIG_NFT_REJECT_IPV4=m
# CONFIG_NFT_DUP_IPV4 is not set
# CONFIG_NFT_FIB_IPV4 is not set
# CONFIG_NF_TABLES_ARP is not set

CONFIG_NF_TABLES_IPV6=y
CONFIG_NFT_REJECT_IPV6=m
# CONFIG_NFT_DUP_IPV6 is not set
# CONFIG_NFT_FIB_IPV6 is not set

# CONFIG_NF_TABLES_BRIDGE is not set

but Iā€™m not a kernel specialist ^^

is the dts-change iā€™ve mentioned

git log -1 --oneline -- arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
03705c843af0 arm: dts: fix phy-mode and flowcontrol between gmac0 and port6

defconfig is the add of CONFIG_NF_TABLES

just try it out and tell me, which options are needed :slight_smile:

I have this error on build with the new version :

  YACC    scripts/dtc/dtc-parser.tab.[ch]
  UPD     include/generated/uapi/linux/version.h
"5.4.2-bpi-r2COPYING CREDITS Documentation Kbuild Kconfig LICENSES MAINTAINERS Makefile README README.md arch block build.conf build.sh certs crypto drivers fs include init ipc kernel lib mm net samples scripts security sound tools usr virt 5.4-main" exceeds 64 characters
make: *** [Makefile:1165: include/generated/utsrelease.h] Error 1
make: *** Waiting for unfinished jobs....
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o

Try adding double quotes around $branches here:

No succesā€¦

The error seems to be generated with the commit 81e1222f978e7ddbb3252caa9a33f2a33fc433b0

81e1222f978e7ddbb3252caa9a33f2a33fc433b0
diff --git a/build.sh b/build.sh
index d57d299b773f..503c16c67bdb 100755
--- a/build.sh
+++ b/build.sh
@@ -148,7 +148,18 @@ function get_version()
 {
        echo "generate branch vars..."
        #kernbranch=$(git rev-parse --abbrev-ref HEAD)
-       kernbranch=$(git branch --contains $(git log -n 1 --pretty='%h') | grep -v '(HEAD' | head -1 | sed 's/^..//')
+
+       echo "getting git branch: "
+       #find branches with actual commit and filter out detached head
+       branches=$(git branch --contains $(git log -n 1 --pretty='%h') | grep -v '(HEAD')
+       echo "$branches"
+
+       kernbranch=$(echo $branches | grep '^*') #look for marked branch (local)
+       if [[ "$kernbranch" == "" ]];then #no marked branch (travis)
+               kernbranch=$(echo "$branches" | head -1) #use first one
+       fi
+       #kernbranch=$(git branch --contains $(git log -n 1 --pretty='%h') | grep '^*' | grep -v '(HEAD' | head -1 | sed 's/^..//')
+       kernbranch=${kernbranch//^../}
        kernbranch=${kernbranch//frank-w_/}

        gitbranch=$(echo $kernbranch|sed 's/^[45]\.[0-9]\+//'|sed 's/-rc$//')

Before I think that the content of the include/config/kernel.release was just 5.4-main (from command: git branch --contains $(git log -n 1 --pretty=ā€™%hā€™) | grep -v ā€˜(HEADā€™ | head -1 | sed ā€˜s/^ā€¦//ā€™).

Now, the code ā€˜kernbranch=${kernbranch//^ā€¦/}ā€™ returns:

COPYING CREDITS Documentation Kbuild Kconfig LICENSES MAINTAINERS Makefile Module.symvers README README.md System.map arch block bpi-r2.dtb build.conf build.log build.sh certs crypto debian drivers fs include init ipc kernel lib mm modules.builtin modules.builtin.modinfo modules.order net samples scripts security sound tools uImage uImage_nodt usr virt vmlinux vmlinux.o 5.4-main

which is too long for compilation.

I donā€™t understand what do you want to get from this line to assign it to the variable.

If I uncomment your line 161 and move it after the next line, it is compile.

diff --git a/build.sh b/build.sh
index 503c16c67bdb..9117941ffc4f 100755
--- a/build.sh
+++ b/build.sh
@@ -154,12 +154,12 @@ function get_version()
        branches=$(git branch --contains $(git log -n 1 --pretty='%h') | grep -v '(HEAD')
        echo "$branches"
 
-       kernbranch=$(echo $branches | grep '^*') #look for marked branch (local)
+       kernbranch=$(echo "$branches" | grep '^*') #look for marked branch (local)
        if [[ "$kernbranch" == "" ]];then #no marked branch (travis)
                kernbranch=$(echo "$branches" | head -1) #use first one
        fi
        #kernbranch=$(git branch --contains $(git log -n 1 --pretty='%h') | grep '^*' | grep -v '(HEAD' | head -1 | sed 's/^..//')
-       kernbranch=${kernbranch//^../}
+       kernbranch=$(echo "$kernbranch" | sed 's/^..//')
        kernbranch=${kernbranch//frank-w_/}
 
        gitbranch=$(echo $kernbranch|sed 's/^[45]\.[0-9]\+//'|sed 's/-rc$//')

it is wildcard-handling by bash because actual branch is marked with a *ā€¦seems bash regex-replace cannot replace it (tried also quoting here). the line should remove the *, but fails because * in bash lists files in current directory.

i cherry-picked from another branch, so i had not tested it againā€¦

Have updates branchā€¦local and travis are now clean

I have started work on 5.5 (rc1)ā€¦poweroff is already working in mainline.

Wifi is working in 5.5-wifi branchā€¦i try to reduce modifications to watchdog-driver to bare minimalā€¦have patched out many lines which are added in previous versions. It seems that only the toprgu_reset is neededā€¦without it driver crashes with some timeouts

5.5-hdmi is also ready

tested kernel with wifi-changes (watchdog) on r64 and it works nowā€¦i guess i can use from now same codebase for both boardsā€¦need some changes to build.sh to have a better naming of uImage

have also added merged tree to test all together

1 Like

Hi, Frank! Iā€™ve just tested your latest 5.5-merged branch kernel, and it quite unstable for me: it halts randomly in about 1-3 minutes after start. No ssh, no serial terminal, only ping (over wifi). I didnā€™t yet figured out any action/driver which causes this behavior. My config has additional mt76x2 and sierra usm 4g modem drivers, and it works perfectly whit 5.3-wifi branch. Iā€™ll try to test wifi-only and/or hdmi-only branch in a few days.

Hi

Any messages in log?

You can try change trgmii to rgmii twice in dts. Imho on 5.4-main i have done itā€¦

Regards Frank

No messages while itā€™s working, and i canā€™t check anything after it has halted.

Do you mean these?

gmac0: mac@0 {
        compatible = "mediatek,eth-mac";
        reg = <0>;
        phy-mode = "trgmii";

ā€¦

                            port@6 {
                                    reg = <6>;
                                    label = "cpu";
                                    ethernet = <&gmac0>;
                                    phy-mode = "trgmii";

I can try.

Rightā€¦these 2ā€¦removing ā€œtā€ and recompile/install

Ok, give me 24 hrs. And if it makes sense i donā€™t use Ethernet at all.

Afaik phy-mode from dts is set here

https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/mediatek/mtk_eth_soc.c#L2808

No error appears and trgmii is a valid mode from phymodes array

https://elixir.bootlin.com/linux/latest/source/include/linux/phy.h#L131

Basicly trgmii is same protocol as rgmii (defined as 1000baseX) but with faster clock

https://www.spinics.net/lists/netdev/msg578959.html

  • 1200BaseT/Full for mt7621 only
  • 2000BaseT/Full for mt7623 and mt7683
  • 2600BaseT/Full for mt7623 only

With iperf3 i only reached 940mbit/s with 2 clients on lan-ports.

  • mt7621A: TRGMII 1.2Gbps
  • mt7623N: TRGMII 2Gbps (when connect to external mt7530 switch, the clock will be limited to 2Gbps only)
  • mt7623A: TRGMII 2.6Gbps (add mt7530 switch into mt7623 package)

ps. mt7683 was renamed mt7623

Have you any idea why trgmii is not working properly? I had not even got >940mbit/s over lan-ports and it seems to be unstable for some users. Canā€™t reproduce yet