Transplanted wifi (rtl8723d) driver based on Allwinner T133-s3 (Tina Linux)
1.Hardware circuit
2. Software preparation
2.1. Driver code
1) First, we need to obtain the driver, which can generally be obtained from the manufacturer or found on Github Gitee.
2) Check whether there is platform_ARM_SUNxI_sdio.c interface source code in the platform folder.
If not, you need to adapt to the Tina platform. The main modification is to call the functions of power on and off, card scanning, SDIO driver, etc. provided by the Tina platform. If the workload is heavy, it is recommended to ask professionals to perform transplantation.
3) Then copy the driver file into the lichee/linux-5.4/drivers/net/wireless folder, which is actually the path under the kernel directory
2.2. Modify the script
1) Edit lichee/linux-5.4/drivers/net/wireless/rtl8723ds/Makefile, find the Platform Related setting area, turn off all other options, and leave only CONFIG_PLATFORM_ARM_SUNxI = y on.
2) Also find the Interface area and only enable CONFIG_SDIO_HCI
3) Next edit lichee/linux-5.4/drivers/net/wireless/Kconfig and add the index
source "drivers/net/wireless/rtl8723ds/Kconfig"
4) Open lichee/linux-5.4/drivers/net/wireless/rtl8723ds/Kconfig and check the corresponding config symbol. You can see that it is RTL8723DS. 5) You can
add it in lichee/linux-5.4/drivers/net/wireless/Makefile. Compile folder
obj-$(CONFIG_RTL8723DS) += rtl8723ds/
2.3. Add driver
1) After the configuration is completed, you can find this option in make kernel_menuconfig and compile it into a module.
2) Tina adaptation for wifi firmware
The configuration of the kernel driver is completed above, and the next step is to configure the Tina Linux side. Since some Wi-Fi drivers require file system mounting to provide firmware, you need to configure and package the driver module and firmware compiled above in Tina Linux, and also configure a script to automatically load the driver to make the system run normally.
Before that, let's check whether the firmware of RTL8723DS is provided. You can search whether there is firmware of 8723DS in make menuconfig s. If not, add it yourself.
It can be seen that Tina Linux provides the firmware of RTL8723DS, named r8723ds-firmware, you can proceed to the next step.
3) Modify the Tina-Linux/target/allwinner/t113-evb1/modules.mk file (just find the path here according to your own) and add the RTL8723DS kmod option. Note that the firmware name contained in DEPENDS is the name found above.
define KernelPackage/net-rtl8723ds
SUBMENU:=$(WIRELESS_MENU)
TITLE:=RTL8723DS support (staging)
DEPENDS:= +r8723ds-firmware +@IPV6 +@USES_REALTEK
FILES:=$(LINUX_DIR)/drivers/net/wireless/rtl8723ds/8723ds.ko
AUTOLOAD:=$(call AutoProbe,8723ds)
endef
define KernelPackage/net-rtl8723ds/description
Kernel modules for RealTek RTL8723DS support
endef
$(eval $(call KernelPackage,net-rtl8723ds))
4) Now make menuconfig to enter the Tina Linux configuration interface, you can find <*> kmod-net-rtl8723ds… RTL8723DS support (staging) in Kernel modules > Wireless Drivers and check it.
6) Finally, you need to enable the function of automatically loading the driver, located in Tina-Linux/target/allwinner/t113-evb1/busybox-init-base-files/etc/init.d/rc.modules. Don’t forget to comment that it is not required of drive.
2.4. Device tree adaptation
Same as above, pay attention to enable SDC1 node and wlan0 node, configure wlan_busnum, wlan_regon, wlan_hostwake. Since the same development board is used here, I will not explain it again. The following kernel device tree is directly used here.
rfkill: rfkill@0 {
compatible = "allwinner,sunxi-rfkill";
chip_en;
power_en;
pinctrl-0 = <&wlan_pins_a>;
pinctrl-names = "default";
status = "okay";
wlan: wlan@0 {
compatible = "allwinner,sunxi-wlan";
clock-names = "32k-fanout1";
clocks = <&ccu CLK_FANOUT1_OUT>;
wlan_busnum = <0x1>;
wlan_regon = <&pio PG 12 GPIO_ACTIVE_HIGH>;
wlan_hostwake = <&pio PG 10 GPIO_ACTIVE_HIGH>;
/*wlan_power = "VCC-3V3";*/
/*wlan_power_vol = <3300000>;*/
/*interrupt-parent = <&pio>;
interrupts = < PG 10 IRQ_TYPE_LEVEL_HIGH>;*/
wakeup-source;
};
Finally compile and burn.
3. Test wifi
1) Use ifconfig to see wlan0
2) There is a problem that needs to be noted here. Since the wpa_supplicant.conf file does not have our router name and password, we need to add it ourselves. The path is Tina-Linux/package/allwinner/wifimanager/files/wpa_supplicant.conf.
Open wpa_supplicant.conf
ctrl_interface=/etc/wifi/sockets
#disable_scan_offload=1
#update_config=1
#wowlan_triggers=any
#---------------添加这部分,记得把此注释删掉-----------------
ap_scan=1
network={
ssid="xxx"
psk="xxxxxxxxx"
}
3) Just restart, and then after restarting, dynamically allocate IP, use the following command
udhcpc -i wlan0
4) Finally, you can ping the network.
ping www.baidu.com
5) Note that the kernel will print some debug information here. This is turned on in the wifi driver. You can turn it off by yourself in the driver code. I will release it directly here, mainly to change the macro control in the Makefile.
6) If the following situation occurs when using this wifi module, as shown in the figure: If
this problem occurs, just initialize the structure struct cfg80211_chan_def_chdef in the rtw_cfg80211_ch_switch_notify function of os_dep/linux/ioctl_cfg80211.c in the driver code. That's it.