PX30 AP6212 WIFI-BT模块使用说明

一、AP6212模块简介

datasheet

特性

  • 802.11b/g/n single-band radio
  • Bluetooth V4.0(HS)with integrated Class 1.5PAandLow Energy (BLE) support
  • Concurrent Bluetooth, FM (RX) RDS/RBDS, and WLAN operation
  • Simultaneous BT/WLAN receive with single antenna
  • WLAN host interface options:-SDIO v2.0—up to 50 MHz clock rate
  • BT host digital interface:-UART (up to 4 Mbps)
  • FM multiple audio routing options: I2S, PCM, eSCO, A2DP
  • IEEECo-existencetechnologies are integrated die solution
  • ECI —enhanced coexistence support, ability to coordinate BT SCO transmissions around WLAN receivesA simplified block diagram of the module is depicted in the figure below.

硬件框图

2021-04-14 15-39-39 的屏幕截图.png

二、内核修改

1.修改设备树

/ {
    ...
    wireless-bluetooth {
        compatible = "bluetooth-platdata";
        uart_rts_gpios = <&gpio1 RK_PC3 GPIO_ACTIVE_LOW>;
        pinctrl-names = "default","rts_gpio";
        pinctrl-0 = <&uart1_rts>;
        pinctrl-1 = <&uart1_rts_gpio>;
        // BT,reset_gpio    = <&gpio2 RK_PB0 GPIO_ACTIVE_HIGH>;
        // BT,wake_gpio     = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
        BT,power_gpio     = <&gpio2 RK_PB0 GPIO_ACTIVE_HIGH>;   // BT_REG_ON
        BT,wake_host_irq = <&gpio0 RK_PB3 GPIO_ACTIVE_HIGH>; // BT_WAKE_HOST
        status = "okay";
    };

    wireless-wlan {
        compatible = "wlan-platdata";
        rockchip,grf = <&grf>;
        wifi_chip_type = "ap6212";  
        sdio_vref = <1800>;
        WIFI,host_wake_irq = <&gpio0 RK_PB2 GPIO_ACTIVE_HIGH>;  // WIFI_WAKE_HOST
        status = "okay";
    };

    sdio_pwrseq: sdio-pwrseq {
        compatible = "mmc-pwrseq-simple";
        clocks = <&rk809 1>;    // 根据实际电路决定
        clock-names = "ext_clock";
        pinctrl-names = "default";
        pinctrl-0 = <&wifi_enable_h>;

        /*
         * On the module itself this is one of these (depending
         * on the actual card populated):
         * - SDIO_RESET_L_WL_REG_ON
         * - PDN (power down when low)
         */
        reset-gpios = <&gpio0 RK_PA2 GPIO_ACTIVE_LOW>;  //WIFI_REG_ON
    };
    ...
};

&sdio {
    status = "okay";
    clock-frequency = <50000000>;
    clock-freq-min-max = <200000 50000000>;
    bus-width = <4>;
    cap-sd-highspeed;
    cap-sdio-irq;
    disable-wp;
    keep-power-in-suspend;
    mmc-pwrseq = <&sdio_pwrseq>;
    non-removable;
    num-slots = <1>;
    pinctrl-names = "default";
    sd-uhs-sdr104;
    supports-sdio;
};

&pinctrl {
    pinctrl-names = "default";
    pinctrl-0 = <&chip_enable_h &wifi_wake_host >;
    
    sdio-pwrseq {
        wifi_enable_h: wifi-enable-h {
            rockchip,pins = <0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;    //WIFI_REG_ON
        };
        chip_enable_h: chip-enable-h {
            rockchip,pins = <0 RK_PA0 RK_FUNC_GPIO &pcfg_output_high>;
        };
    };

    wireless-wlan {
        wifi_wake_host: wifi-wake-host {
        /* 注意一般Wi-Fi的wake up pin都是高电平触发,所以默认这里要配置为下拉*/
        rockchip,pins = <0 RK_PB2 0 &pcfg_pull_down>;
        };
    };

};

2.修改内核配置

WL_ROCKCHIP=y

2021-04-14 15-55-15 的屏幕截图.png

三、安装驱动并运行

wifi-bt驱动位置为sdk/external/rkwifibt/firmware/

$ tree external/rkwifibt/firmware/ -L 3
external/rkwifibt/firmware/
├── broadcom
│   ├── all
│   │   ├── BT_FIRMWARE
│   │   └── WIFI_FIRMWARE
│   ├── AP6181
│   │   └── wifi
│   ├── AP6212A1
│   │   ├── bt
│   │   └── wifi
│   ├── AP6236
│   │   ├── bt
│   │   └── wifi
│   ├── AP6255
│   │   ├── bt
│   │   └── wifi
│   ├── AP6354
│   │   ├── bt
│   │   └── wifi
│   ├── AW-CM256
│   │   ├── bt
│   │   └── wifi
│   └── AW-NB197
│       ├── bt
│       └── wifi
└── rockchip
    └── WIFI_FIRMWARE
        ├── rk912_fw.bin
        ├── rk912_patch.bin
        └── rk912_patch_cal.bin

在设备烧录新内核后,新建文件夹并安装驱动

$ mkdir -p /system/etc/firmware/
# 安装wifi驱动,实际用的是fw_bcm43438a1.bin
$ scp -r host@ip:/sdkpath/external/rkwifibt/firmware/broadcom/all/WIFI_FIRMWARE/*  /system/etc/firmware/
# 安装bt驱动
$ scp -r host@ip:/sdkpath/external/rkwifibt/firmware/broadcom/all/BT_FIRMWARE/*  /system/etc/firmware/
sync
# 重启设备
$ sync && reboot

驱动日志

[    1.518554] Bluetooth: RFCOMM socket layer initialized
[    1.519067] Bluetooth: RFCOMM ver 1.11
[    1.519494] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    1.520045] Bluetooth: HIDP socket layer initialized
[    1.520624] [WLAN_RFKILL]: Enter rfkill_wlan_init
[    1.521708] [WLAN_RFKILL]: Enter rfkill_wlan_probe
[    1.522191] [WLAN_RFKILL]: wlan_platdata_parse_dt: wifi_chip_type = ap6212
[    1.522890] [WLAN_RFKILL]: wlan_platdata_parse_dt: enable wifi power control.
[    1.523598] [WLAN_RFKILL]: wlan_platdata_parse_dt: wifi power controled by gpio.
[    1.524312] of_get_named_gpiod_flags: can't parse 'WIFI,poweren_gpio' property of node '/wireless-wlan[0]'
[    1.524332] of_get_named_gpiod_flags: can't parse 'WIFI,vbat_gpio' property of node '/wireless-wlan[0]'
[    1.524350] of_get_named_gpiod_flags: can't parse 'WIFI,reset_gpio' property of node '/wireless-wlan[0]'
[    1.524529] of_get_named_gpiod_flags: parsed 'WIFI,host_wake_irq' property of node '/wireless-wlan[0]' - status (0)
[    1.524546] [WLAN_RFKILL]: wlan_platdata_parse_dt: get property: WIFI,host_wake_irq = 10, flags = 0.
[    1.525490] [WLAN_RFKILL]: wlan_platdata_parse_dt: The ref_wifi_clk not found !
[    1.526219] [WLAN_RFKILL]: rfkill_wlan_probe: init gpio
[    1.526767] [WLAN_RFKILL]: Exit rfkill_wlan_probe
[    1.527407] [BT_RFKILL]: Enter rfkill_rk_init
[    1.529191] of_get_named_gpiod_flags: parsed 'uart_rts_gpios' property of node '/wireless-bluetooth[0]' - status (0)
[    1.529212] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: uart_rts_gpios = 51.
[    1.530053] of_get_named_gpiod_flags: parsed 'BT,power_gpio' property of node '/wireless-bluetooth[0]' - status (0)
[    1.530065] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,power_gpio = 72.
[    1.530799] of_get_named_gpiod_flags: can't parse 'BT,reset_gpio' property of node '/wireless-bluetooth[0]'
[    1.530814] of_get_named_gpiod_flags: can't parse 'BT,wake_gpio' property of node '/wireless-bluetooth[0]'
[    1.530853] of_get_named_gpiod_flags: parsed 'BT,wake_host_irq' property of node '/wireless-bluetooth[0]' - status (0)
[    1.530864] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,wake_host_irq = 11.
[    1.531623] [BT_RFKILL]: bluetooth_platdata_parse_dt: clk_get failed!!!.
[    1.532314] [BT_RFKILL]: Request irq for bt wakeup host
[    1.532897] [BT_RFKILL]: ** disable irq
[    1.533530] [BT_RFKILL]: bt_default device registered.

$ dmesg |grep RFKILL
[    1.520624] [WLAN_RFKILL]: Enter rfkill_wlan_init
[    1.521708] [WLAN_RFKILL]: Enter rfkill_wlan_probe
[    1.522191] [WLAN_RFKILL]: wlan_platdata_parse_dt: wifi_chip_type = ap6212
[    1.522890] [WLAN_RFKILL]: wlan_platdata_parse_dt: enable wifi power control.
[    1.523598] [WLAN_RFKILL]: wlan_platdata_parse_dt: wifi power controled by gpio.
[    1.524546] [WLAN_RFKILL]: wlan_platdata_parse_dt: get property: WIFI,host_wake_irq = 10, flags = 0.
[    1.525490] [WLAN_RFKILL]: wlan_platdata_parse_dt: The ref_wifi_clk not found !
[    1.526219] [WLAN_RFKILL]: rfkill_wlan_probe: init gpio
[    1.526767] [WLAN_RFKILL]: Exit rfkill_wlan_probe
[    1.527407] [BT_RFKILL]: Enter rfkill_rk_init
[    1.529212] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: uart_rts_gpios = 51.
[    1.530065] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,power_gpio = 72.
[    1.530864] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,wake_host_irq = 11.
[    1.531623] [BT_RFKILL]: bluetooth_platdata_parse_dt: clk_get failed!!!.
[    1.532314] [BT_RFKILL]: Request irq for bt wakeup host
[    1.532897] [BT_RFKILL]: ** disable irq
[    1.533530] [BT_RFKILL]: bt_default device registered.
[    1.621325] [WLAN_RFKILL]: rockchip_wifi_get_oob_irq: Enter
[    1.623931] [WLAN_RFKILL]: rockchip_wifi_power: 1
[    1.623938] [WLAN_RFKILL]: wifi turn on power. -1
[    2.004318] [WLAN_RFKILL]: rockchip_wifi_power: 0
[    2.005584] [WLAN_RFKILL]: wifi shut off power.
[    4.014704] [BT_RFKILL]: ENABLE UART_RTS
[    4.115496] [BT_RFKILL]: DISABLE UART_RTS
[    4.115586] [BT_RFKILL]: bt turn on power

测试wlan0

$ ls /sys/class/net/
docker0  dummy0  eth0  lo  usb0  wlan0

$ sudo ifconfig wlan0 up

# 搜索附近wifi
sudo iwlist wlan0 scanning
wlan0     Scan completed :
          Cell 01 - Address: F0:92:B4:0B:89:79
                    ESSID:"ChinaNet-Qwyj"
                    Mode:Managed
                    Frequency=2.417 GHz (Channel 2)
                    Quality:2/5  Signal level:-71 dBm  Noise level:0 dBm
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : CCMP TKIP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD180050F204104A00011010440001021049000600372A000120
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : CCMP TKIP
                        Authentication Suites (1) : PSK
                    Encryption key:on
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s
                              11 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                              48 Mb/s; 54 Mb/s

#  显示频道信息
sudo iwlist wlan0 frequen
wlan0     13 channels in total; available frequencies :
          Channel 01 : 2.412 GHz
          Channel 02 : 2.417 GHz
          Channel 03 : 2.422 GHz
          Channel 04 : 2.427 GHz
          Channel 05 : 2.432 GHz
          Channel 06 : 2.437 GHz
          Channel 07 : 2.442 GHz
          Channel 08 : 2.447 GHz
          Channel 09 : 2.452 GHz
          Channel 10 : 2.457 GHz
          Channel 11 : 2.462 GHz
          Channel 12 : 2.467 GHz
          Channel 13 : 2.472 GHz
          Current Channel:1
          
# 连接wifi
sudo vim /etc/wpa_supplicant/wpa_supplicant.conf
    # 填入以下信息
    ctrl_interface=/var/run/wpa_supplicant
    update_config=1
    country=CN

    network={
        ssid="4G-WIFI-A16C"
        psk="12345678"
    }

sudo wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0
Successfully initialized wpa_supplicant

# 动态分配ip
sudo dhclient wlan0

# 断开或停止wifi
sudo killall wpa_supplicant
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,099评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,828评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,540评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,848评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,971评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,132评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,193评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,934评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,376评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,687评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,846评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,537评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,175评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,887评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,134评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,674评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,741评论 2 351

推荐阅读更多精彩内容