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