平台:RK3588 & Android12
模块:RTL8852BE
接口:PCIE
内容:调试RTL8852BE模块的WiFi功能
=================================================================
一、内核
1.1 dts配置
首先是配置PCIE,查看原理图,看一下模块用的哪一个PCIE
--------------------------------------------------------------------------------------------------------------------------------
很明显,这里接到了Mux1上,Mux1的 PHY(combphy1_ps)配合PCIe30x1_0(dts命名为pcie2x1l0),所以配置如下:
vcc3v3_pcie20_wifi: vcc3v3-pcie20-wifi {
compatible = "regulator-fixed";
regulator-name = "vcc3v3_pcie20_wifi";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
enable-active-high;
/*
* wifi_reg_on 是在vbat、vddio稳定后才使能,在reset-gpios前拉高,所以
* 放到PCIe的电源节点中才满足模块时序。
*/
gpios = <&gpio0 RK_PC4 GPIO_ACTIVE_HIGH>;
startup-delay-us = <5000>;
vin-supply = <&vcc12v_dcin>;
};
&combphy1_ps {
status = "okay";
};
&pcie2x1l0 {
reset-gpios = <&gpio1 RK_PB2 GPIO_ACTIVE_HIGH>;
rockchip,skip-scan-in-resume;
status = "okay";
};
然后配置WiFi:
wireless_wlan: wireless-wlan {
compatible = "wlan-platdata";
wifi_chip_type = "rtl8852be";
pinctrl-names = "default";
pinctrl-0 = <&wifi_host_wake_irq>, <&wifi_poweren_gpio>;
WIFI,host_wake_irq = <&gpio0 RK_PB2 GPIO_ACTIVE_HIGH>;
/* 不能这里控制wifi_reg_on管脚,请挪到vcc3v3_pcie20_wifi */
//WIFI,poweren_gpio = <&gpio0 RK_PC4 GPIO_ACTIVE_HIGH>;
status = "okay";
};
&pinctrl添加:
wireless-wlan {
wifi_host_wake_irq: wifi-host-wake-irq {
rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_down>;
};
wifi_poweren_gpio: wifi-poweren-gpio {
rockchip,pins = <0 RK_PC4 RK_FUNC_GPIO &pcfg_pull_up>;
};
配好这些模块应该就挂到pcie上了:
2.1 驱动
RK3588似乎并没有兼容RTL8852BE这个模块,驱动需要问供应商要,存放路径
SDK\kernel-5.10\drivers\net\wireless\rockchip_wlan
二、系统层
由于SDK没有兼容RTL8852BE,所以要修改一些文件,让系统自动加载对应的ko文件
SDK\frameworks\opt\net\wifi\libwifi_hal\rk_wifi_ctrl.cpp
++ #define RTL8852BE_DRIVER_MODULE_PATH WIFI_MODULE_PATH"8852be.ko"
++ #define RTL8852BE_DRIVER_MODULE_NAME "8852be"
static wifi_device supported_wifi_devices[] = {
++ {"RTL8852BE", "10ec:b852"},
...
const wifi_file_name module_list[] = {
++ {"RTL8852BE", RTL8852BE_DRIVER_MODULE_NAME, RTL8852BE_DRIVER_MODULE_PATH, UNKOWN_DRIVER_MODULE_ARG, REALTEK_WIFI_HAL},
...
其实就是照葫芦画瓢,对着兼容的模块的写法去写。
三、遇到的问题
3.1 驱动报错
1)报错信息:
drivers/net/wireless/rockchip_wlan/rtl8852be/Kconfig:5: syntax error
drivers/net/wireless/rockchip_wlan/rtl8852be/Kconfig:4: unknown statement "---help---"
drivers/net/wireless/rockchip_wlan/rtl8852be/Kconfig:5: unknown statement "Help"
Kconfig语法有错,---help---改成help即可
2)报错信息:
error: "Must be LITTLE/BIG Endian Host"
error: declaration of 'struct cfg80211_csa_settings' will not be visible outside of this function [-Werror,-Wvisibility]
没有选择对应的平台
修改Makefile:
-- CONFIG_PLATFORM_I386_PC = y
++ CONFIG_PLATFORM_I386_PC = n
-- CONFIG_PLATFORM_ARM_ROCKCHIP = n
++ CONFIG_PLATFORM_ARM_ROCKCHIP = y
# Import platform assigned KSRC and CROSS_COMPILE
-- include $(wildcard $(DRV_PATH)/platform/*.mk)
++ include $(src)/platform/arm_rk.mk
需要查看驱动 platform 目录下的相关文件,看包含哪个。
3)报错信息:
drivers/net/wireless/rockchip_wlan/rtl8852be/core/rtw_mlme.c:5359:27: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
if ((pregpriv->wifi_spec == 1))
drivers/net/wireless/rockchip_wlan/rtl8852be/phl/hal_g6/mac/mac_ax/trxcfg.c:1253:9: error: explicitly assigning value of variable of type 'u32' (aka 'unsigned int') to itself [-Werror,-Wself-assign]
val32 = val32;
报类似上面的错误,改了一个又出来另一个,直接修改 Makefile 禁止此类报错
EXTRA_CFLAGS += -Wno-tautological-overlap-compare
EXTRA_CFLAGS += -Wno-pointer-bool-conversion
++ EXTRA_CFLAGS += -Wno-parentheses-equality
++ EXTRA_CFLAGS += -Wno-self-assign
加的编译选项其实和报错信息差不多,其它类似报错照葫芦画瓢,大概用途:
-Wno-uninitialized:禁止未初始化变量的警告
-Wno-enum-conversion:禁止枚举类型转换警告
-Wno-fortify-source:禁止源码加固警告
-Wno-invalid-source-encoding:禁止无效的源码编码警告
-Wno-tautological-pointer-compare:禁止指针比较警告
-Wno-tautological-overlap-compare:禁止重叠比较警告
-Wno-pointer-bool-conversion:禁止指针转布尔型警告
-Wno-parentheses-equality:禁止多余括号的比较警告
-Wno-self-assign:禁止变量自赋值警告
-Wno-header-guard:禁止头文件守卫重复定义警告
4)报错信息:
ERROR: modpost: module 8852be uses symbol kernel_write from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it.
ERROR: modpost: module 8852be uses symbol kernel_read from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it.
ERROR: modpost: module 8852be uses symbol filp_open from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it.
缺少相关命名空间,查找引用了 kernel_write 的文件,加入命名空间:
MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
四、参考文章
高版本linux内核编译驱动报错记录_uses symbol kernel_write from namespace vfs_intern-CSDN博客
RK3568-B2-ANDROID11-WIFI-RTL8821CU_rk平台rtl8821cu调试-CSDN博客
五、资料包
内含改好编好的驱动以及相关参考文档
链接:https://pan.baidu.com/s/1xU_dgcywp86gLfZOceabFA
提取码:zesv
--来自百度网盘超级会员V1的分享