Porting openwrt(kernel 5.4) for bpi-r2 status report

I want to use my bpi-r2 as a router/movie player/bluetooth Audio player. but the current status of openwrt support for bpi-r2 is limited. so I try to do it myself. I port some patches from @frank-w, @leXa2, @abbradar. and have uploaded those patches to

https://github.com/smaller09/openwrt-bpi-r2.

current status

RTC: ok Poweroff: ok ethernet: seems ok

Wifi interface: got this error

[WMT-STP-EXP][E]mtk_wcn_wmt_msgcb_reg(384):ERROR! mtk_wcn_wmt_msgcb_reg_f cb is null

but wifi seems ok, and luci wifi support need some tweaks.(maybe mac80211.sh and wifi.sh)

Bluetooth broken. got this:

[STP] stp_process_packet:[E] mtk_wcn_sys_if_rx is NULL

mtk_bt_hci_flush: todo

Can’t init device hci0: Operation timed out (110)

filesystem partly works, rootfs mount as ext4, but need to port to squashfs/overlay.

drm/lima: not test yet. lima support seems broken.

Any test / help would be appreciate.

3 Likes

Thank you for working on openwrt-support, as i cannot help here much…which version of openwrt do you use? as for current kernel, i guess you are close to upstream

I’m not sure i tested bluetooth on 5.4,but it is marked in table as working…have you build as module and loaded after running wifi.sh (imho needs blacklisting to not be loaded on bootup)?

seems these options are disabled in my 5.4-main defconfig

CONFIG_MTK_COMBO_BT=m
CONFIG_MTK_COMBO_BT_HCI=y

currently compiling, then i test it like here

  • first call wifi.sh (or at least call wmt_loader + stp-uart-launcher)
  • then load BT-module “modprobe stp_chrdev_bt”

mhm…still no chrdev-module…

drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/stp_chrdev_bt.o is compiled, but not the *.ko

made mrproper, and compile again, still no ko-file for bluetooth :thinking:

needed to change makefile from obj-y to obj-m (or obj-$(CONFIG_MTK_COMBO_BT)) like it’s done here:

https://github.com/frank-w/BPI-R2-4.14/blob/4.19-bt/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/Makefile

after that i get BT working (running wifi.sh and the modprobe for bt-module)…have successfully paired my smartphone

apt install bluez
root@bpi-r2:~# bluetoothctl
Agent registered
[bluetooth]# agent on
Agent is already registered
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# discoverable yes
Changing discoverable on succeeded
[CHG] Controller 00:00:46:85:90:01 Discoverable: yes
[bluetooth]# scan on
Discovery started
...
[CHG] Controller 00:00:46:85:90:01 Discoverable: yes                            
[CHG] Device 04:B4:XX:XX:XX:XX RSSI: -29                                        
[CHG] Device 04:B4:XX:XX:XX:XX RSSI: -48                                        
[CHG] Device 04:B4:XX:XX:XX:XX Connected: yes
1 Like

I am using openwrt master as code base, as it support linux-5.4 as a test kernel. I compile bluetooth builded in and not as a module. but I think the problem was not because of that.

dmesg.txt (6.7 KB)

I got error when wlan_gen2.ko was loaded:

[WMT-STP-EXP][E]mtk_wcn_wmt_msgcb_reg(384):ERROR! mtk_wcn_wmt_msgcb_reg_f cb is null

But Debian with your 5.4 kernel don’t have that error. On my own build, hciconfig -a do find the bluetooth device. but just can’t bring it up.

hci0:   Type: Primary  Bus: SDIO
        BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
        DOWN
        RX bytes:0 acl:0 sco:0 events:0 errors:0
        TX bytes:0 acl:0 sco:0 commands:0 errors:0
        Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        Packet type: DM1 DH1 HV1
        Link policy:
        Link mode: SLAVE ACCEPT

root@OpenWrt:/# hciconfig hci0 up

[ 1180.904660] [STP] stp_process_packet:[E] mtk_wcn_sys_if_rx is NULL

[ 1191.517407] mtk_bt_hci_flush: todo

Can’t init device hci0: Operation timed out (110)

I am not a coder.:sleepy: but maybe I need some EXPORT_SYMBOL for mtk_wcn_sys_if_rx and mtk_wcn_wmt_msgcb_reg_f.:stuck_out_tongue:

And now I prepare to use you code source instead of the mainline kernel source to try again.

1 Like

wmt_loader and stp_uart_launcher need to be called before bluetooth-init, so the trick with bluetooth module-load after the other 2 commands are called…

you should add my patches from 5.4 (and you may need additional changes because of updates from openwrt to mainline = 5.6)

1 Like

i see that this is no full openwrt-tree, can you provide a readme how to use (compile/burn) your repo? or just create a script that fetches openwrt (maybe specific commit) and compiles it

i can compile openwrt for r2 with kernel 5.4, but have not found yet how to get the image itself…i see compiled kernel (with debug), initramfs, root.ext4, but no bin except bpi_bananapi-r2-kernel.bin which is only ~3MB

@smaller09 i see you have a commit for adding BT support, is it now working? can you guide me how to get a flashable openwrt-img for sd/emmc with your patches? currently i have compiled only upstream openwrt and have only a *kernel.bin

these are the files i have in output-directory:

$ ls -sh ./build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-mediatek_mt7623/ 
insgesamt 187M
4,0K base-files                                    4,0K ppp-default
2,9M bpi_bananapi-r2-kernel.bin                    7,9M root.ext4
4,0K gpio-button-hotplug                           1,3M root.squashfs
8,2M Image                                         4,0K tmp
 12M Image-initramfs                               8,2M vmlinux
 28K image-mt7623a-unielec-u7623-02-emmc-512m.dtb   52M vmlinux.debug
 28K image-mt7623n-bananapi-bpi-r2.dtb             8,3M vmlinux.elf
4,0K iptables-1.8.4                                 12M vmlinux-initramfs
4,0K linux-5.4.28                                   56M vmlinux-initramfs.debug
4,0K linux-atm-2.5.2                                12M vmlinux-initramfs.elf
4,0K mtd                                           2,9M zImage
4,0K opkg-2020-01-25-c09fe209                      4,0M zImage-initramfs
4,0K packages

have only changed this in menuconfig:

Target System (MediaTek Ralink ARM)  --->
Subtarget (MT7623)  --->
Target Profile (Bpi Banana Pi R2)  --->

and in “Target Images” i see only this:

[*] ramdisk  --->
    *** Root filesystem archives ***
[ ] cpio.gz
[ ] tar.gz
    *** Root filesystem images ***
[*] ext4  --->
[*] squashfs  --->
[*] GZip images
    *** Image Options ***
(1024) Root filesystem partition size (in MB)
  1. BT was not working. it can scan/pair,but can’t connect in bluetoothctl. it also not working in debian with your newest kernel. same there.
  2. As for openwrt flashing. I use tar.gz for flashing. just untar the file to the root partition. and copy the kernel and the dtb. you can also use root.ext4 . that’s what i said it’s partly works.
  3. to use my patch. just copy all the files to the root of you original openwrt source tree. what I had done was jus trim others commits and put it together. it only add some kernel patches and kmod-wlan-gen2 and kmod-stp-bt and wmt packages.
  1. can you show me the commands not working in bluetoothctl? i have not done much with it…
  2. ok, for me this way sounds better, so i can do dualboot :slight_smile: will try it

as for wiifi module, you still need to make kernel_menuconfig and enable the kernel cfg80211 and it’s testmode as module. my patehes has long distance to perfect.

by the way. I use uboot’s extlinux to boot the kernel. so it can easily chang the root partition. as a result .it must use nodtb kernel.

I found you didn’t enable the test kernel. to use kernel 5.4 you must enable the test kernel setting.

i patched makefile to use 5.4 :slight_smile: but had tested without your patches (upstream openwrt)…need to find some time to test again

how do i get the tar.gz file?

i changed added this in “target images”:

[*] tar.gz

and did “make -j8” again, expected a tar.gz-file in ./build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-mediatek_mt7623/ but there is none. did i something wrong?

found it here: ./bin/targets/mediatek/mt7623/openwrt-mediatek-mt7623-bpi_bananapi-r2-rootfs.tar.gz

unpacked to other partition

sudo tar -xzf ./bin/targets/mediatek/mt7623/openwrt-mediatek-mt7623-bpi_bananapi-r2-rootfs.tar.gz -C /mnt/openwrt

and changed root-variable in uboot which is passed by bootargs, but it seems that openwrt does not get loaded…it prints some messages (no fatal i think) and then stops…

[    7.107339] Run /sbin/init as init process                                                                                    
[    7.215080] init: Console is alive                                                                                            
[    7.219450] init: - watchdog -                                                                                                
[    7.233738] kmodloader: no module folders for kernel version 5.6.0-bpi-r2-main found                                          
[    7.250618] init: - preinit -                                                                                                 
[    7.369754] mtk_soc_eth 1b100000.ethernet eth0: configuring for fixed/trgmii link mode                                        
[    7.384665] mtk_soc_eth 1b100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx                                  
[    7.400191] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready                                                           
[    7.414086] mt7530 mdio-bus:00 lan1: configuring for phy/gmii link mode                                                       
[    7.427703] 8021q: adding VLAN 0 to HW filter on device lan1                                                                  
Press the [f] key and hit [enter] to enter failsafe mode                                                                         
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level                                                     
[   11.528719] mount_root: mounting /dev/root                                                                                    
[   11.541037] EXT4-fs (mmcblk0p3): re-mounted. Opts: (null)                                                                     
[   11.557581] insmod: no module folders for kernel version 5.6.0-bpi-r2-main found                                              
Failed to find the folder holding the modules                                                                                    
[   11.575017] insmod: no module folders for kernel version 5.6.0-bpi-r2-main found                                              
Failed to find the folder holding the modules                                                                                    
[   11.593149] insmod: no module folders for kernel version 5.6.0-bpi-r2-main found                                              
Failed to find the folder holding the modules                                                                                    
[   11.611223] insmod: no module folders for kernel version 5.6.0-bpi-r2-main found                                              
Failed to find the folder holding the modules                                                                                    
[   11.648217] FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.                 
[   11.670383] urandom-seed: Seed file not found (/etc/urandom.seed)                                                             
[   11.707603] procd: - early -                                                                                                  
[   11.716952] procd: - watchdog -                                                                                               
[   12.400036] procd: - watchdog -                                                                                               
[   12.410316] procd: - ubus -                                                                                                   
[   12.471127] procd: - init -                                                                                                   
[   12.620073] kmodloader: no module folders for kernel version 5.6.0-bpi-r2-main found                                          
[   12.643780] urngd: v1.0.2 started.                                                                                            

does openwrt need the module-folder?? if i boot from tftp i have also no module-folder for the loaded kernel…debian has no problem with if…on using f,1,2,3,4 and enter, i did not get any console/login

i saw, that /etc/fstab is empty…do openwrt need a entry for rootfs there? or do i need to use a initrd or similar?

mhm, i operate on serial console but have hdmi connected…saw a message on hdmi-screen “Please press enter to activate this console”…if i do so, i see openwrt-banner and prompt…but why not on serial?? I passed 2 console in cmdline…it looks like only the first one is activated…does openwrt only support 1 console or can i add another anywhere?

i swapped ttyS0 (serial) and tty1 (hdmi) and have now access to r2 via serial console…but can i enable 2 VT?

@smaller09 can you say how i can add a second VT? btw. why are you removing some commits with the second commit? i created a openwrt-fork to include your Patches, but i cannot apply commits because these files are existing already. currently build failed on

Patch failed!  Please fix /media/data_nvme/git/openwrt/target/linux/mediatek/patches-5.4/0102-dsa-mt7530-Extend-device-data.patch!

hi frank can i have question ? I have wifi card (Intel Corporation WiFi Link 5100). and it uses driver Iwlwifi-5000-5.ucode i looked inside your kernel and there is just 5000 and 5150. i am using kernel 5.4.24-bpi-r2-main

i don’t know each card and the corresponsing driver…just compile both as module and lok which one is loaded…

do a liitle google and you find this site from intel and it says it is the 5000-driver:

@smaller09 can you guide me how to fix

Hunk #6 FAILED at 1703.
Hunk #7 succeeded at 1813 (offset 63 lines).
1 out of 7 hunks FAILED -- saving rejects to file drivers/net/dsa/mt7530.c.rej
Patch failed!  Please fix /media/data_nvme/git/openwrt/target/linux/mediatek/patches-5.4/0102-dsa-mt7530-Extend-device-data.patch

based on what i’ve found in the rej-file, it seems to be changes for mt7531

./build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-mediatek_mt7623/linux-5.4.28/drivers/net/dsa/mt7530.c.rej                   

 1 --- drivers/net/dsa/mt7530.c
 2 +++ drivers/net/dsa/mt7530.c
 3 @@ -1703,16 +1790,37 @@ static const struct dsa_switch_ops mt7530_switch_ops = {
 4         .port_vlan_prepare      = mt7530_port_vlan_prepare,
 5         .port_vlan_add          = mt7530_port_vlan_add,
 6         .port_vlan_del          = mt7530_port_vlan_del,
 7 -       .phylink_validate       = mt7530_phylink_validate,
 8 +       .phylink_validate       = mt753x_phylink_validate,
 9         .phylink_mac_link_state = mt7530_phylink_mac_link_state,
10 -       .phylink_mac_config     = mt7530_phylink_mac_config,
11 +       .phylink_mac_config     = mt753x_phylink_mac_config,
12         .phylink_mac_link_down  = mt7530_phylink_mac_link_down,
13         .phylink_mac_link_up    = mt7530_phylink_mac_link_up,
14  };
15
16 +static const struct mt753x_info mt753x_table[] = {
17 +       [ID_MT7621] = {
18 +               .id = ID_MT7621,
19 +               .setup = mt7530_setup,
...
37  static const struct of_device_id mt7530_of_match[] = {
38 -       { .compatible = "mediatek,mt7621", .data = (void *)ID_MT7621, },
39 -       { .compatible = "mediatek,mt7530", .data = (void *)ID_MT7530, },
40 +       { .compatible = "mediatek,mt7621", .data = &mt753x_table[ID_MT7621], },
41 +       { .compatible = "mediatek,mt7530", .data = &mt753x_table[ID_MT7530], },
42         { /* sentinel */ },
43  };
44  MODULE_DEVICE_TABLE(of, mt7530_of_match);
45

have patched manually, it failes because there are 2 additional lines between .port_vlan_del and .phylink_validate

1765         .port_vlan_add          = mt7530_port_vlan_add,
1766         .port_vlan_del          = mt7530_port_vlan_del,
1767         .port_mirror_add        = mt7530_port_mirror_add,
1768         .port_mirror_del        = mt7530_port_mirror_del,
1769         .phylink_validate       = mt753x_phylink_validate,
1770         .phylink_mac_link_state = mt7530_phylink_mac_link_state,

how can i update the Patch? and how to get further?

managed it using quilt https://openwrt.org/docs/guide-developer/build-system/use-patches-with-buildsystem

the mt7530.c has changed since kernel 5.4.24. so I patched the 0102-dsa-mt7530-Extend-device-data.patch as what you have done.

I had updated my repo, and also attached the kernel config to make things work.

give a try.

As i currently using my “debian-kernel” the main problem is the console…can i activate a second one to use hdmi also for input? For mt6625 driver…can the patches be merged (e.g. driver-folder and outside of it like i did as first step on new kernel-versions). That makes it easier for maintaining. Did you need to change anything in my code for openwrt? Maybe you can use 5.6 version where i fixed also the timekeeping functions

as I using the mainline kernel for the cord base. the console is on ttyS2. just change the extlinux.conf.

As for mt6625. I did not change your code. just put some patches together.

I will try using your patches from 5.6-wifi version again. I had tried before, but can merge because of some conflict. I will try later.

My kernel maps debuguart as ttyS0 (uart2 is first in dtsi), but ttyS0 needs to be first console definition in uboot else i see output,but input is disabled

Hello, I have the R2 laying around. IDK if it still works. I can try some test if needed.

@smaller09 please let me know what you want me to test and how can I get an img to run openwrt which is build/patches by you.

Thanks