AP6212A - BT not working on Orange Pi Zero Plus2 H3


Go to solution Solved by jock,

Recommended Posts

Hi everybody,

I'm using the Armbian Buster mainline based kernel 5.10.y image on https://www.armbian.com/orange-pi-zero-plus-2-h3/ but I also tried the Focal one.
I searched the forum deeply and I saw that someone in the past (forum post closed, otherwise I would have continued there) managed to have BT working by "faking" the /lib/firmware/brcm/brcmfmac43430-sdio.bin, that boot tries to load having error -2, copying the ap6212/fw_bcm43438a1.bin in its place.
But it seems that it only works with legacy images, infact, with my mainline image I keep failing.

 

Which legacy image should I look for? I was thinking that https://www.armbian.com/orange-pi-zero-plus-2-h3 already lists customized images, but I think I completely misunderstood.
Thank you for any help

Link to post
Share on other sites

Donate and support the project!

Hi
I'm adding details to my question, if somebody can help it would be very appreciated.
To resume, my problem is that I have a Orange Pi Zero Plus2 H3 with Armbian Buster mainline based kernel 5.10.y, and Bluetooth is not working (hciconfig -a does not report any controller);
I also have a Orange Pi Zero Plus2 H5 (64bit) with Linux orangepizeroplus2 4.17.2-sunxi64: here Bluetooth is working correctly, with hciconfig -a reporting a controller with its parameters.

Here is the H5 dmesg output for the part related to bluetooth:


 

[...]

[    4.789119] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    4.797546] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    4.851379] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[    4.879043] EXT4-fs (mmcblk0p1): re-mounted. Opts: commit=600,errors=remount-ro
[    4.982040] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[    4.982127] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.clm_blob failed with error -2
[    4.982135] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
[    4.982808] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Mar 30 2016 11:30:56 version 7.45.77.h8.4 FWID 01-ee8a6268
[    9.044878] systemd-journald[519]: Received request to flush runtime journal from PID 1
[...]
[    9.058327] systemd-journald[519]: Failed to open system journal: No space left on device
[    9.058534] systemd-journald[519]: File /var/log/journal/40ce618d730f448b85f3daed6c5b8022/system.journal corrupted or uncleanly shut down, renaming and replacing.
[   10.593343] random: crng init done
[   10.593356] random: 7 urandom warning(s) missed due to ratelimiting
[...]
[   14.253974] systemd-journald[519]: Failed to open system journal: No space left on device
[   14.551745] Bluetooth: Core ver 2.22
[   14.551831] NET: Registered protocol family 31
[   14.551835] Bluetooth: HCI device and connection manager initialized
[   14.551855] Bluetooth: HCI socket layer initialized
[   14.551864] Bluetooth: L2CAP socket layer initialized
[   14.551890] Bluetooth: SCO socket layer initialized
[   15.727058] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[   15.766873] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[   16.021134] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[   17.221116] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   17.684839] Mass Storage Function, version: 2009/09/11
[   17.684856] LUN: removable file: (no medium)
[   18.094789] configfs-gadget gadget: high-speed config #1: c
[   18.137450] Bluetooth: HCI UART driver ver 2.3
[   18.137461] Bluetooth: HCI UART protocol H4 registered
[   18.137464] Bluetooth: HCI UART protocol BCSP registered
[   18.137467] Bluetooth: HCI UART protocol ATH3K registered
[   18.137470] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   18.137621] Bluetooth: HCI UART protocol Intel registered
[   18.137625] Bluetooth: HCI UART protocol QCA registered
[   18.137628] Bluetooth: HCI UART protocol AG6XX registered
[   18.137630] Bluetooth: HCI UART protocol Marvell registered
[   18.379092] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   18.379101] Bluetooth: BNEP filters: protocol multicast
[   18.379120] Bluetooth: BNEP socket layer initialized


Here is the H3 dmesg:

 

[...]

[    7.549941] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    7.645538] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    7.663242] zram: Added device: zram0
[    7.677707] zram: Added device: zram1
[    7.682907] zram: Added device: zram2
[    7.709055] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[    7.731474] brcmfmac mmc2:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.xunlong,orangepi-zero-plus2-h3.txt failed with error -2
[    7.731492] brcmfmac mmc2:0001:1: Falling back to sysfs fallback for: brcm/brcmfmac43430-sdio.xunlong,orangepi-zero-plus2-h3.txt
[    7.791392] asoc-simple-card sound: i2s-hifi <-> 1c22800.i2s mapping ok
[    7.805223] zram1: detected capacity change from 0 to 241106944
[    7.947163] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[    7.949352] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-11), device may have limited channels available
[    7.950344] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Oct  8 2016 15:31:47 version 7.46.57.4.ap.r4 (A1 Station/P2P) FWID 01-3621395e es6.c5.n4.a3
[    8.918383] Adding 235452k swap on /dev/zram1.  Priority:5 extents:1 across:235452k SSFS
[    9.040297] zram0: detected capacity change from 0 to 52428800
[   11.240959] EXT4-fs (zram0): mounted filesystem without journal. Opts: discard
[   11.241006] ext4 filesystem being mounted at /var/log supports timestamps until 2038 (0x7fffffff)
[   13.191644] random: crng init done
[   13.191661] random: 7 urandom warning(s) missed due to ratelimiting
[   17.097053] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready

 

NB: Here the dmesg outputs stops. There is no hci module loading. But even if I make it by hand:
 

modprobe -v hci_uart


I have this output:

 

insmod /lib/modules/5.4.35-sunxi/kernel/crypto/ecc.ko 
insmod /lib/modules/5.4.35-sunxi/kernel/crypto/ecdh_generic.ko 
insmod /lib/modules/5.4.35-sunxi/kernel/net/bluetooth/bluetooth.ko 
insmod /lib/modules/5.4.35-sunxi/kernel/drivers/bluetooth/btbcm.ko 
insmod /lib/modules/5.4.35-sunxi/kernel/drivers/bluetooth/btrtl.ko 
insmod /lib/modules/5.4.35-sunxi/kernel/drivers/bluetooth/hci_uart.ko 



and dmesg shows appended to the previous output:

[  153.461277] Bluetooth: Core ver 2.22
[  153.461478] NET: Registered protocol family 31
[  153.461486] Bluetooth: HCI device and connection manager initialized
[  153.461527] Bluetooth: HCI socket layer initialized
[  153.461546] Bluetooth: L2CAP socket layer initialized
[  153.461591] Bluetooth: SCO socket layer initialized
[  153.488789] Bluetooth: HCI UART driver ver 2.3
[  153.488812] Bluetooth: HCI UART protocol H4 registered
[  153.488820] Bluetooth: HCI UART protocol BCSP registered
[  153.488945] Bluetooth: HCI UART protocol LL registered
[  153.488954] Bluetooth: HCI UART protocol ATH3K registered
[  153.489224] Bluetooth: HCI UART protocol Three-wire (H5) registered
[  153.489685] Bluetooth: HCI UART protocol Broadcom registered


 

but hciconfig -a still does not show any controller.

Can somebody help or has some hint?
Thank you in advance

 

Link to post
Share on other sites

  • Solution

Hello, I neither have the boards you have nor the AP6212 wifi chip in any of my boards, but I can tell you that bluetooth is generally quite a beast.

I have had experience with AP6330 and AP6334 (a clone, actually) and spent countless hours trying to sort things out.

 

First of all, the bluetooth adapter on the same chip of the wifi, but is actually a separate device. The wifi part is connected to the system via SDIO bus, but the bluetooth is connected via a simpler UART serial port.

The dmesg logs you provided are not showing anything related to the bluetooth hardware part, but just some software modules/components, you should provide the complete dmesg log (please put them in a spoiler section), because things happen in out-of-order fashion when device are initialized.

 

Anyway, if you are very very lucky, running hciattach is everything you need:

/usr/bin/hciattach /dev/ttyS0 bcm43xx 1500000

the program will not put itself in background, and you need to keep it running if you want to access bluetooth device. In case it works, you may want to create a systemd service or a script that runs at boot.

Change ttyS0 with the serial port your bluetooth adapter is internally connected.

You may need to put the right firmware file in /lib/firmware/brcm, I don't know which one is required so you have to discover it by yourself. Maybe it is already there.

 

In case this does not work, debugging may take ten minutes to several hours/days and unfortunately requires quite a knownledge to deal with.

Link to post
Share on other sites

Posted (edited)

Thank you very much jock,

I still don't have all needed knowledge, but I am lucky to have the H5 working, so before reading your answer I tried two script that are in my H5 and not in the H3 image, such as /etc/default/ap6212 and /etc/init.d/ap6212-bluetooth. Especially the last is invoking, among the other things, just the hciattach you were mentioning, and also devmem2* and rfkill that were missing in the h3 environment (very strange the rfkill missing!)
Now, invoking ap6212-bluetooth by hand, I finally had the bluetooth working, but wifi stopped working and I had to relaunch it via armbian-config (deactivate/reactivate with my wifi ESSID).

 

Now the last missing piece of the puzzle is: who and when should launch /etc/init.d/ap6212-bluetooth at startup, especially in order not to mess up bluetooth and wifi?**
I'm continuing to investigate, anyway thanks a lot for the very useful overview

 

*: I took it from here https://github.com/henla464/WiRoc-StartupScripts/blob/master/devmem2 , thanks to Henrik Larsson

**: UPDATE: I found how it works and used 
sudo update-rc.d ap6212-bluetooth defaults

that makes the correct links for the boot execution levels described in the script header.
Now everything works, bluetooth+wifi.
Thank you for having triggered the right path of searching!

ap6212 ap6212-bluetooth

Edited by msabatini
add missing script files, maybe useful to others
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

2 2