build icon indicating copy to clipboard operation
build copied to clipboard

rfkill is not used correctly when setup bluetooth with ap6212

Open xiongyihui opened this issue 5 years ago • 9 comments

In ap6212-bluetooth, rfkill is not used correctly.

        rfkill unblock all
        echo "0" > /sys/class/rfkill/rfkill0/state
        echo "1" > /sys/class/rfkill/rfkill0/state

for Nanopi Neo Air and Orangepi Zero Plus2 H5, rfkill0 is Wi-Fi in the default settings of armbian

pi@nanopiair:~$ rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no

For Nanopi Neo Air, I tried to add bluetooth reset to rfkill using a dts file, but failed. The dts is:

/dts-v1/;
/plugin/;

/ {
    compatible = "allwinner,sun8i-h3";

    fragment@0 {
        target = <&pio>;
        __overlay__ {
            bt_pwr_pin: bt_pwr_pin@0 {
                pins = "PG13";
                function = "gpio_out";
            };
        };
    };

    fragment@1 {
        target-path = "/";
        __overlay__ {
            rfkill_bt {
                compatible = "rfkill-gpio";
                pinctrl-names = "default";
                pinctrl-0 = <&bt_pwr_pin>;
                reset-gpios = <&pio 6 13 1>;
                clocks = <&osc32k>;
                clock-frequency = <32768>;
                rfkill-name = "sunxi-bt";
                rfkill-type = "bluetooth";
            };
        };
    };
};

The command rfkill list doesn't have "sunxi-bt". Something should be missing in the dts file. Any idea?

xiongyihui avatar Apr 19 '19 04:04 xiongyihui

Bluetooth is in a bad shape in general so yes, its possible that things are missing. For me it's low priority ... but I guess once this should be sorted out. At least for AP6212, which is most common.

igorpecovnik avatar Apr 19 '19 16:04 igorpecovnik

It seems that we need a patch for rfkill-gpio to add bluetooth reset pin to rfkill-gpio

xiongyihui avatar Apr 20 '19 13:04 xiongyihui

Some progress:

|  \| |/ _` | '_ \ / _ \| |_) | | | |_) | |
| |\  | (_| | | | | (_) |  __/| | |  _ <| |
|_| \_|\__,_|_| |_|\___/|_|   |_| |_| \_\_|
                                           

Welcome to ARMBIAN 5.82 user-built Ubuntu 18.04.2 LTS 4.19.36-sunxi   
System load:   0.00 0.00 0.00  	Up time:       31 min		
Memory usage:  8 % of 999MB  	IP:            
CPU temp:      33°C           	
Usage of /:    3% of 30G    	

Last login: Mon Apr 22 11:24:25 2019 from 10.0.10.42

root@nanopi:~# rfkill list
0: sunxi-bt: Bluetooth
	Soft blocked: no
	Hard blocked: no
1: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no

igorpecovnik avatar Apr 22 '19 11:04 igorpecovnik

In Armbian Focal (mainline based kernel 5.10.y) the problem still persists. Bluetooth not working. Maybe something broken up and the question is what and where?

konkhra avatar Apr 02 '21 13:04 konkhra

Some progress:

|  \| |/ _` | '_ \ / _ \| |_) | | | |_) | |
| |\  | (_| | | | | (_) |  __/| | |  _ <| |
|_| \_|\__,_|_| |_|\___/|_|   |_| |_| \_\_|
                                           

Welcome to ARMBIAN 5.82 user-built Ubuntu 18.04.2 LTS 4.19.36-sunxi   
System load:   0.00 0.00 0.00  	Up time:       31 min		
Memory usage:  8 % of 999MB  	IP:            
CPU temp:      33°C           	
Usage of /:    3% of 30G    	

Last login: Mon Apr 22 11:24:25 2019 from 10.0.10.42

root@nanopi:~# rfkill list
0: sunxi-bt: Bluetooth
	Soft blocked: no
	Hard blocked: no
1: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no

Hi, I took from https://www.armbian.com/orange-pi-zero-plus-2-h3/ the Buster image, and bluetooth is not working; is this patch supposed to be included in a new release?

msabatini-met avatar May 11 '21 13:05 msabatini-met

is this patch supposed to be included in a new release?

If not in the release documents and if issue not closed with a commit, unlikely: https://docs.armbian.com/Release_Changelog/

igorpecovnik avatar May 11 '21 17:05 igorpecovnik

Could we have a workaround in the while to make BLE work on a NanoPi NEO Air on Armbian 21.05.1 Focal with Linux 5.10.34-sunxi ? Thanyou!

walterjj avatar May 15 '21 22:05 walterjj

Give a look here to see how I found a solution: https://forum.armbian.com/topic/18100-ap6212a-bt-not-working-on-orange-pi-zero-plus2-h3/ edit the ap6212-bluetooth script if needed for your platform.

msabatini-met avatar May 18 '21 08:05 msabatini-met

To get this working on the NanoPi NEO Plus2, I created said patches: dts patch and rfkill-gpio patch

Compiled: brcm_patchram_plus Added the following: firmware Created said script: nanopi-bthelper

Followed by systemd service:

[Unit]
Description=Bluetooth Helper
Before=bluetooth.service

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/nanopi-bthelper -s
ExecStop=/usr/local/sbin/nanopi-bthelper -k
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

rfkill list

0: sunxi-bt: Bluetooth
	Soft blocked: no
	Hard blocked: no
1: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no
3: hci0: Bluetooth
	Soft blocked: no
	Hard blocked: no

bluetoothctl

Agent registered
[CHG] Controller 6C:0E:3E:BA:9A:56 Pairable: yes

This has been tested on Linux 5.14.14

pyavitz avatar Oct 26 '21 15:10 pyavitz