一、簡(jiǎn)介
專欄總目錄AP6256是正基科技推出的一款低成本,低功耗的雙模模塊。是一款SDIO接口單通道802.11ac雙頻支持BT5.0 藍(lán)牙WiFi二合一模塊。Model:AP6256:SDIO WIFI + UARTBTChip:BCM43456WiFi:2.4G&5GBT:5.0WIFI Throughput:up:196 Mbits/sec down: 187 Mbits/sec二、DTS配置
2.1 配置SDIO
/* SDIO接口Wi-Fi專用配置:SDIO接口節(jié)點(diǎn) */&sdio {max-frequency = < 150000000 >; /* sdio接口的最大頻率,可調(diào)整 */supports-sdio;bus-width = < 4 >; /* 4線模式,可調(diào)整1線模式 */disable-wp;cap-sd-highspeed;cap-sdio-irq;keep-power-in-suspend;mmc-pwrseq = < &sdio_pwrseq >;non-removable;num-slots = < 1 >;pinctrl-names = "default";pinctrl-0 = < &sdiom0_pins >;sd-uhs-sdr104; /* 支持SDIO3.0 */status = "okay";};
2.2 WIFI的配置
WIFI_REG_ON: Wi-Fi的電源使能PIN腳配置 ( 控制WIFI模塊電源的GPIO )WL_REG_ON由sdio_pwrseq節(jié)點(diǎn)進(jìn)行管理控制,不需要在wireless-wlan節(jié)點(diǎn)下面重復(fù)添加WIFI,poweren_gpio配置;/* SDIO接口Wi-Fi專用配置: WIFI_REG_ON: Wi-Fi的電源使能PIN腳 */sdio_pwrseq: sdio-pwrseq {compatible = "mmc-pwrseq-simple";clocks = < &hym8563 >;clock-names = "ext_clock";pinctrl-names = "default";pinctrl-0 = < &wifi_enable_h >;reset-gpios = < &gpio0 RK_PC4 GPIO_ACTIVE_LOW >; /*跟電源使能狀態(tài)恰好相反:高有效為L(zhǎng)OW,低有效則為HIGH。切記:這個(gè)配置跟下面的WIFI,poweren_gpio是互斥的,不能同時(shí)配置?。?!*/ /*特別注意:reset-gpios的GPIO_ACTIVE 配置跟poweren_gpio配置的電源使能狀態(tài)恰好是相反的*/};/* SDIO接口Wi-Fi專用配置:WIFI_REG_ON腳的pinctrl的配置 */&pinctrl {sdio-pwrseq {wifi_enable_h: wifi-enable-h {rockchip,pins = < 0 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none >; /* 對(duì)應(yīng)上面的WIFI_REG_ON,關(guān)掉上下拉,防止不能拉高或拉低 */};};}
WIFI節(jié)點(diǎn)配置/* Wi-Fi節(jié)點(diǎn) */wireless_wlan: wireless-wlan {compatible = "wlan-platdata";wifi_chip_type = "ap6256"; //模塊名稱pinctrl-names = "default";pinctrl-0 = < &wifi_host_wake_irq >;WIFI,host_wake_irq = < &gpio0 RK_PB2 GPIO_ACTIVE_HIGH >; //WIFI模塊喚醒CPU的//WIFI,poweren_gpio = < &gpio0 RK_PC4 GPIO_ACTIVE_HIGH >; //控制WIFI模塊電源的GPIO,配置了sdio_pwrseq就不需要再配置poweren_gpio status = "okay";};
WIFI,host_wake_irq的配置說(shuō)明:WIFI,host_wake_irq = < &gpio0 RK_PB2 GPIO_ACTIVE_HIGH >; /* WIFI_WAKE_HOST: Wi-Fi中斷通知主控的PIN腳。* 特別注意:確認(rèn)下這個(gè)Wi-Fi pin腳跟主控的pin的硬件連接關(guān)系,直連的話就是GPIO_ACTIVE_HIGH;* 如果中間加了一個(gè)反向管就要改成低電平GPIO_ACTIVE_LOW觸發(fā)*/
WIFI_WAKE_HOST腳的pinctrl的配置:&pinctrl {wireless-wlan {wifi_host_wake_irq: wifi-host-wake-irq {rockchip,pins = < 0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_down >;};};}/* 注意一般Wi-Fi的wake host pin都是高電平觸發(fā),* 所以默認(rèn)這里要配置為下拉; 如果客戶的硬件設(shè)計(jì)* 是反向的則要改為上拉,總之要初始化為與觸發(fā)電平* 相反的狀態(tài)*/
2.3 藍(lán)牙的配置
以下UART相關(guān)的都要配置為實(shí)際使用的UART口的所對(duì)應(yīng)PIN,注意RTS/CTS pin一定要按照SDK設(shè)計(jì)
(相關(guān)資料圖)
接(具體接法參考7.3章節(jié)的UART描述),很多客戶反饋的異常都是因?yàn)檫@兩個(gè)PIN腳沒(méi)有接導(dǎo)致初始化
異常,下面假設(shè)藍(lán)牙使用UART4:
bt_uart6: wireless_bluetooth: wireless-bluetooth {compatible = "bluetooth-platdata";clocks = < &hym8563 >; //外部時(shí)鐘clock-names = "ext_clock"; uart_rts_gpios = < &gpio1 RK_PA2 GPIO_ACTIVE_LOW >; //uart的rts腳pinctrl-names = "default", "rts_gpio";pinctrl-0 = < &uart6m1_rtsn >;pinctrl-1 = < &uart6_gpios >;BT,reset_gpio = < &gpio3 RK_PA6 GPIO_ACTIVE_HIGH >; //藍(lán)牙的復(fù)位腳BT,wake_host_irq = < &gpio0 RK_PC5 GPIO_ACTIVE_HIGH >; //藍(lán)牙模塊喚醒CPU的GPIOstatus = "okay";};&pinctrl {wireless-bluetooth {uart6_gpios: uart6-gpios {rockchip,pins = < 1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none >;};};}
藍(lán)牙對(duì)應(yīng)的uart6配置/* 打開(kāi)對(duì)應(yīng)的UART配置 */&uart6 {pinctrl-names = "default";/* 這里配置對(duì)應(yīng)主控UART的TX/RX/CTS PIN ,不要配置RTS PIN*/pinctrl-0 = < &uart6m1_xfer &uart6m1_ctsn >;status = "okay";};
三 、內(nèi)核配置
3.1 WIFI配置:kernel配置defconfig
MK文件中定義的Kernel defconfig:kernel的defconfig對(duì)應(yīng)到這個(gè)文件: "kernel\\arch\\arm64\\configs\\rockchip_linux_defconfig"# Kernel defconfigexport RK_KERNEL_DEFCONFIG=rockchip_linux_defconfig
cd kernelmake ARCH=arm64 menuconfigmake savedefconfig
選擇:Device Drivers ---> Network device support ---> Wireless LAN ---> Rockchip Wireless LAN support
Wi-Fi驅(qū)動(dòng)可編譯到內(nèi)核或者ko方式, 切記下面兩個(gè)配置必須二選一,否則Wi-Fi無(wú)法加載!
KO 配置:[* ] build wifi ko modules
CONFIG_WIFI_BUILD_MODULE=y# CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP is not set
buildin 配置:[* ] Wifi load driver when kernel bootup
CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP=y# CONFIG_WIFI_BUILD_MODULE is not set
buildin 只能選擇一個(gè)型號(hào),realtek 模組和 ap6xxx 模組不能同時(shí)選擇為y,且realtek的也只能選擇其
中一個(gè);
ap6xxx 和 cypress也是互斥的,只能選擇一個(gè)且如果選擇ap6xxx,cypress的配置自動(dòng)消失,去掉ap
配置,cypress自動(dòng)出現(xiàn);
ko方式則可以選擇多個(gè)Wi-Fi
3.2 藍(lán)牙配置:kernel配置defconfig
正基和海華的模塊使用內(nèi)核的默認(rèn)CONFIG_BT_HCIUART 驅(qū)動(dòng):cd kernelmake ARCH=arm64 menuconfigmake savedefconfig
選擇: Networking support ---> Bluetooth subsystem support ---> Bluetooth device drivers
注意:配置完成后要保存到對(duì)應(yīng)的defconfig
四、Wi-Fi/BT的文件及更新及編譯說(shuō)明
4.1 查看板上生成的ko文件和firmware / nvram文件
正基/海華模組以AP6256為例:對(duì)應(yīng)的Wi-Fi/BT的firmware在SDK中的位置:external/rkwifibt/firmware/broadcom/AP6256/├── bt│ └── BCM4345C5.hcd└── wifi├── fw_bcm43456c5_ag.bin├── fw_bcm43456c5_ag_mfg.bin└── nvram_ap6256.txt
經(jīng)過(guò)編譯規(guī)則編譯后,對(duì)應(yīng)的文件被拷貝到工程的output目錄:(kernel4.19內(nèi)核由system變更為vendor目錄)buildroot/output/rockchip_rk3xxxx/target//system(vendor)/lib/modules/bcmdhd.ko #驅(qū)動(dòng)ko(如果是ko編譯的話)/system(vendor)/etc/firmware/fw_bcm43456c5_ag.bin #驅(qū)動(dòng)firmware文件存放位置/system(vendor)/etc/firmware/fw_bcm43456c5_ag_mfg.bin #驅(qū)動(dòng)firmware文件存放位置/system(vendor)/etc/firmware/nvram_ap6256.txt #驅(qū)動(dòng)nvram文件存放位置/system(vendor)/etc/firmware/BCM4345C5.hcd #藍(lán)牙firmware文件(如果有藍(lán)牙功能)
最終燒錄到機(jī)器中后,Wi-Fi運(yùn)行時(shí)所需的文件及存放位置:/system(vendor)/lib/modules/bcmdhd.ko #驅(qū)動(dòng)ko(如果是ko編譯的話)/system(vendor)/etc/firmware/fw_bcm43456c5_ag.bin #驅(qū)動(dòng)firmware文件存放位置/system(vendor)/etc/firmware/fw_bcm43456c5_ag_mfg.bin #驅(qū)動(dòng)firmware文件存放位置/system(vendor)/etc/firmware/nvram_ap6256.txt #驅(qū)動(dòng)nvram文件存放位置/system(vendor)/etc/firmware/BCM4345C5.hcd #藍(lán)牙firmware文件(如果有藍(lán)牙功能)
4.2 編譯配置說(shuō)明
mk文件配置路徑:3588_linux5.10_v1.0.5/device/rockchip/rk3588/BoardConfig-rk3588-pi5.mk兼容正基和RealtekRK_WIFIBT_TTY這個(gè)參數(shù)根據(jù)藍(lán)牙對(duì)應(yīng)的串口來(lái)配置,此處藍(lán)牙對(duì)應(yīng)的是uart6# Define WiFi BT chip# Compatible with Realtek and AP6XXX WiFi : RK_WIFIBT_CHIP=ALL_AP# Compatible with Realtek and CYWXXX WiFi : RK_WIFIBT_CHIP=ALL_CY# Single WiFi configuration: AP6256 or CYW43455: RK_WIFIBT_CHIP=AP6256export RK_WIFIBT_CHIP=ALL_AP# Define BT ttySXexport RK_WIFIBT_TTY=ttyS6
審核編輯:湯梓紅