美文网首页
PX30 AP6212 WIFI-BT模块使用说明

PX30 AP6212 WIFI-BT模块使用说明

作者: Mr_Michael | 来源:发表于2021-04-14 16:22 被阅读0次

一、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

相关文章

网友评论

      本文标题:PX30 AP6212 WIFI-BT模块使用说明

      本文链接:https://www.haomeiwen.com/subject/olqllltx.html