f1c100s tina usb 接口 rtl8723du模组移植调试

一、调试流程总结

1,硬件

复制代码
	根据原理图和模组接口确保各路电压值正常,符合规格书要求,这是调试驱动的第一步。

2,软件

复制代码
	在硬件各路电源都正确的情况下,再去调试软件,一般模组厂会给驱动源码,自己移植就好

二、调试

1,内核配置

复制代码
	在tina的sdk根目录配置:
     	make kernel_menuconfig 
     	打开下述配置项
     	
	   usb_host模式
		CONFIG_CFG80211=y
		CONFIG_CFG80211_DEFAULT_PS=y
		CONFIG_USB = y
		CONFIG_USB_EHCI_HCD
		CONFIG_USB_SUNXI_HCD
		CONFIG_USB_SUNXI_HCD0
		CONFIG_USB_SUNXI_HCI
		CONFIG_USB_SUNXI_EHCI0

2,添加驱动源码

1.wifi驱动源码见附件
2.wifi驱动源码修改移植
c 复制代码
		a.更改平台配置选项
		rtl8723DU_WiFi_linux_v5.6.5.3_35502.20191025_COEX20181130-2e2e\Makefile
			CONFIG_PLATFORM_I386_PC = n	 ==》	CONFIG_PLATFORM_I386_PC = n
			CONFIG_PLATFORM_ARM_SUNxI = y  ==》	CONFIG_PLATFORM_ARM_SUNxI = y
			
		b.修改函数定义
			driver\rtl8723DU_WiFi_linux_v5.6.5.3_35502.20191025_COEX20181130-2e2e\include\ieee80211.h
			
			#ifdef PLATFORM_FREEBSD /* Baron change func to macro */
			#define is_multicast_mac_addr(Addr) ((((Addr[0]) & 0x01) == 0x01) && ((Addr[0]) != 0xff))
			#define is_broadcast_mac_addr(Addr) ((((Addr[0]) & 0xff) == 0xff) && (((Addr[1]) & 0xff) == 0xff) && \
				(((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \
								 (((Addr[5]) & 0xff) == 0xff))
			#else
			static __inline int is_multicast_mac_addr(const u8 *addr)					/*extern -》 static*/
			{
					return ((addr[0] != 0xff) && (0x01 & addr[0]));
			}

			static __inline int is_broadcast_mac_addr(const u8 *addr)					/*extern -》 static*/
			{
				return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&   \
					(addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
			}

			static __inline int is_zero_mac_addr(const u8 *addr)						/*extern -》 static*/
			{	
				return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) &&   \
					(addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00));
			}
			#end
			
		c,usb接口替换
			找到sdk自带的platform_ARM_SUNxI_usb.c进行替换;
			driver\rtl8723DU_WiFi_linux_v5.6.5.3_35502.20191025_COEX20181130-2e2e\platform\platform_ARM_SUNxI_usb.c
			替换
			f1c100s\tina\lichee\linux-3.10\drivers\net\wireless\rtl8188eu\platform\platform_ARM_SUNxI_usb.c
			
			文档内容:
			
				#include <drv_types.h>
				#include <linux/sys_config.h>

				#ifdef CONFIG_PLATFORM_ARM_SUNxI
				extern int sunxi_usb_disable_hcd(__u32 usbc_no);
				extern int sunxi_usb_enable_hcd(__u32 usbc_no);
				/*extern void wifi_pm_power(int on);*/
				extern void sunxi_wlan_set_power(bool on_off);
				extern int sunxi_wlan_get_bus_index(void);
				//static script_item_u item;
				static int busnum_retval= -1;
				#endif
				
				int platform_wifi_power_on(void)
				{
					  int ret = 0;

				#if defined(CONFIG_PLATFORM_ARM_SUNxI)
					{
						/*script_item_value_type_e type;

						type = script_get_item("wifi_para", "wifi_usbc_id", &item);
						if(SCIRPT_ITEM_VALUE_TYPE_INT != type){
							printk("ERR: script_get_item wifi_usbc_id failed\n");
							ret = -ENOMEM;
							goto exit;
						}*/

						busnum_retval=sunxi_wlan_get_bus_index( );
						if (busnum_retval<0 && busnum_retval>2)
						{
							printk("unsupported wlan_busnum (%u)\n", busnum_retval);
							ret = -ENOMEM;
							goto exit;
						}
						printk("sw_usb_enable_hcd: usbc_num = %d\n", busnum_retval);

						/*printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);
						wifi_pm_power(1);*/
						sunxi_wlan_set_power(1);
						mdelay(10);

						#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
						/*sunxi_usb_enable_hcd(item.val);*/
						sunxi_usb_enable_hcd(busnum_retval);
						#endif
					}
				#endif //CONFIG_PLATFORM_ARM_SUNxI

				exit:
					return ret;
				}
			
			void platform_wifi_power_off(void)
			{
			#if defined(CONFIG_PLATFORM_ARM_SUNxI)
				#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
				/*sunxi_usb_disable_hcd(item.val);*/
				sunxi_usb_disable_hcd(busnum_retval);
				#endif
				//wifi_pm_power(0);
				sunxi_wlan_set_power(0);
			#endif //defined(CONFIG_PLATFORM_ARM_SUNxI)

			}
	d.修改配置文件:
			lichee/linux-3.10/drivers/net/wireless/Kconfig
				diff --git a/tina/lichee/linux-3.10/drivers/net/wireless/Kconfig b/tina/lichee/linux-3.10/drivers/net/wireless/Kconfig
				index ece2c6d..1866748 100755
				--- a/tina/lichee/linux-3.10/drivers/net/wireless/Kconfig
				+++ b/tina/lichee/linux-3.10/drivers/net/wireless/Kconfig
				@@ -288,6 +288,7 @@ source "drivers/net/wireless/zd1211rw/Kconfig"
				 source "drivers/net/wireless/mwifiex/Kconfig"
				 source "drivers/net/wireless/rtl8188eu/Kconfig"
				 source "drivers/net/wireless/rtl8723bs/Kconfig"
				+source "drivers/net/wireless/rtl8723du/Kconfig"
				 source "drivers/net/wireless/xradio/Kconfig"
				 source "drivers/net/wireless/rtl8821cs/Kconfig"
				 endif # WLAN
			
			lichee/linux-3.10/drivers/net/wireless/Makefile
				diff --git a/tina/lichee/linux-3.10/drivers/net/wireless/Makefile b/tina/lichee/linux-3.10/drivers/net/wireless/Makefile
				index bad2151..870ee8c 100755
				--- a/tina/lichee/linux-3.10/drivers/net/wireless/Makefile
				+++ b/tina/lichee/linux-3.10/drivers/net/wireless/Makefile
				@@ -26,6 +26,7 @@ obj-$(CONFIG_RTL8180)         += rtl818x/
				 obj-$(CONFIG_RTL8187)          += rtl818x/
				 obj-$(CONFIG_RTLWIFI)          += rtlwifi/
				 obj-$(CONFIG_RTL8723BS)        += rtl8723bs/
				+obj-$(CONFIG_RTL8723DU)        += rtl8723du/
				 obj-$(CONFIG_RTL8723BS_VQ0)    += rtl8723bs_vq0/
				 obj-$(CONFIG_RTL8189FS)        += rtl8189fs/
				 obj-$(CONFIG_RTL8723CS)        += rtl8723cs/
	
3.蓝牙源码见附件
4.蓝牙源码修改移植
复制代码
	a,内核配置:	
	.config - Linux/arm 3.10.65 Kernel Configuration
	 > Networking support > Bluetooth subsystem support ---------------------------------------------------------------------------------
	  +------------------------------------------------- Bluetooth subsystem support -------------------------------------------------+
	  |  Arrow keys navigate the menu.  <Enter> selects submenus --->.  Highlighted letters are hotkeys.  Pressing <Y> includes, <N>  |
	  |  excludes, <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help, </> for Search.  Legend: [*] built-in  [ ]      |
	  |  excluded  <M> module  < > module capable                                                                                     |
	  |                                                                                                                               |
	  | +---------------------------------------------------------------------------------------------------------------------------+ |
	  | |                          --- Bluetooth subsystem support                                                                  | |
	  | |                          <*>   RFCOMM protocol support                                                                    | |
	  | |                          [*]     RFCOMM TTY support                                                                       | |
	  | |                          < >   BNEP protocol support                                                                      | |
	  | |                          < >   HIDP protocol support                                                                      | |
	  | |                                Bluetooth device drivers  --->  
	  


	
	.config - Linux/arm 3.10.65 Kernel Configuration
	 > Networking support > Bluetooth subsystem support > Bluetooth device drivers ------------------------------------------------------
	  +-------------------------------------------------- Bluetooth device drivers ---------------------------------------------------+
	  |  Arrow keys navigate the menu.  <Enter> selects submenus --->.  Highlighted letters are hotkeys.  Pressing <Y> includes, <N>  |
	  |  excludes, <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help, </> for Search.  Legend: [*] built-in  [ ]      |
	  |  excluded  <M> module  < > module capable                                                                                     |
	  |                                                                                                                               |
	  | +---------------------------------------------------------------------------------------------------------------------------+ |
	  | |                          <*> HCI USB driver                                                                               | |
	  | |                          < > HCI SDIO driver                                                                              | |
	  | |                          < > HCI UART driver                                                                              | |
	  | |                          <*> Realtek HCI USB driver support                                                               | |
	  | |                          < > HCI BCM203x USB driver                                                                       | |
	  | |                          < > HCI BPA10x USB driver                                                                        | |
	  | |                          < > HCI BlueFRITZ! USB driver                                                                    | |
	  | |                          < > HCI VHCI (Virtual HCI device) driver                                                         | |
	  | |                          < > Broadcom Bluetooth Low Power Manager Support                                                 | |
	  | |                          < > Realtek Bluesleep driver support                                                             | |
	  | |                          < > Marvell Bluetooth driver support                                                             | |
	  | |                          < > Atheros firmware download driver     
		
	
	b,内核修改
	
		将 D:\jkl\f1c100s\RE817\rtl8723du\欧智通\20240508_LINUX_BT_DRIVER(2)\20240508_LINUX_BT_DRIVER\usb\bluetooth_usb_driver 文件夹下所有.c 和.h 文件拷贝
		至 kernel/driver/bluetooth 目录。
		修改 kernel/driver/bluetooth 目录下 Kconfig 和 Makefile,增加对 Realtek Bluetooth HCI 
		USB driver 的支持。
		
	  1,diff --git a/tina/lichee/linux-3.10/drivers/bluetooth/Kconfig b/tina/lichee/linux-3.10/drivers/bluetooth/Kconfig
		index 04bc2e8..a25b43f 100755
		--- a/tina/lichee/linux-3.10/drivers/bluetooth/Kconfig
		+++ b/tina/lichee/linux-3.10/drivers/bluetooth/Kconfig
		@@ -59,6 +59,18 @@ config BT_HCIUART_BCSP
		 
				  Say Y here to compile support for HCI BCSP protocol.
		 
		+config BT_HCIBTUSB_RTLBTUSB
		+       tristate "Realtek HCI USB driver support"
		+       depends on USB
		+       help
		+       Realtek Bluetooth HCI USB driver.
		+       This driver is required if you want to use Realtek Bluetooth
		+       device with USB interface.
		+       
		+       Say Y here to compile support for Bluetooth USB devices into the
		+       kernel or say M to compile it as module (rtk_btusb)
		+
		+
		 config BT_HCIUART_ATH3K
				bool "Atheros AR300x serial support"
				depends on BT_HCIUART
			

		
	 2,diff --git a/tina/lichee/linux-3.10/drivers/bluetooth/Makefile b/tina/lichee/linux-3.10/drivers/bluetooth/Makefile
		index 78ca2e0..06d0b7c 100755
		--- a/tina/lichee/linux-3.10/drivers/bluetooth/Makefile
		+++ b/tina/lichee/linux-3.10/drivers/bluetooth/Makefile
		@@ -33,3 +33,6 @@ hci_uart-$(CONFIG_BT_HCIUART_LL)      += hci_ll.o
		 hci_uart-$(CONFIG_BT_HCIUART_ATH3K)    += hci_ath.o
		 hci_uart-$(CONFIG_BT_HCIUART_3WIRE)    += hci_h5.o
		 hci_uart-objs                          := $(hci_uart-y)
		+
		+obj-$(CONFIG_BT_HCIBTUSB_RTLBTUSB) := rtk_btusb.o
		+rtk_btusb-objs := rtk_bt.o rtk_misc.o rtk_coex.o
		
		
	3.D:\jkl\f1c100s\RE817\rtl8723du\欧智通\20240130_LINUX_BT_DRIVER\usb\bluetooth_usb_driver\rtk_misc.c添加头文件
				#include <linux/version.h>
				#include <linux/vmalloc.h>  ==>添加此处
	
	4.添加request_firmware 函数对应的固件路径:
	
		tina/lichee/linux-3.10/drivers/base/firmware_class.c 
			static const char * const fw_path[] = {
				fw_path_para,
				"/lib/firmware/updates/" UTS_RELEASE,
				"/lib/firmware/updates",
				"/lib/firmware/" UTS_RELEASE,
				"/lib/firmware",
				"/etc"
			};
		可参考文档:D:\jkl\f1c100s\RE817\rtl8723du\欧智通\20240130_LINUX_BT_DRIVER\doc\《Realtek_Linux_Bluetooth_Porting_Guide.pdf》		

三、测试

复制代码
	方式一、
	参考链接:https://dandelioncloud.cn/article/details/1577822731087605762

修改配置文件:
	1.
	/etc/wpa_supplicant.conf:
	
	ctrl_interface=/var/log/wpa_supplicant			/*ctrl_interface接口找不到的问题是接口的路径不存在导致的,例如:/etc/wifi/wpa_supplicant/ 这个目录不存在*/
	update_config=1
	#ap_scan=1
	network={
			ssid="Magic3"
			psk="11111111"
	}
				
	
	2./etc/wpa_supplicant.conf:
		ctrl_interface=/var/log/sockets
		update_config=1
		#ap_scan=1
		network={
				ssid="Magic3"
				psk="11111111"
		}

	wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf &  链接AP
	udhcpc -i wlan0 获取IP地址
	
3.修改wep的加密方式时,wpa配置文件得修改:
		ctrl_interface=/var/log/sockets			/*ctrl_interface接口找不到的问题是接口的路径不存在导致的,例如:/etc/wifi/wpa_supplicant/ 这个目录不存在*/
		update_config=1

		network={
				ssid="FAST_FW306R"
				key_mgmt=NONE
				auth_alg=SHARED			/*这项要根据路由器的配置  SHARED/OPEN */
				wep_key0="12345"
		}
		
	参考链接:https://blog.csdn.net/Golden_Chen/article/details/123512744
	
wpa_cli	(使用第二种配置方式才可使用wpa_cli)
	wpa_cli -iwlan0 -p/tmp/log/sockets:			(socket根据实际路径配置)
		命令				返回值	含义	备注
		scan				ok		搜索wifi	 
		scan_results		wifi名称	搜到到的全部wifi名称等信息	 
		set_network			ok		设置wifi的SSID和psk	 
		list_network		列出所有的配置文件中的信息	列出保存的文件中的所有信息	 
		add_network			添加一个网络	添加一个网络	 
		save_network		OK		将配置保存	 
		remove_network		删除一个网络,根据网络ID删除	删除一个网络ID,根据网络ID删除

方式二、使用wifimanager-v2.0
	wifi_deamon	==> 类似于守护进程
	
	wifi:
	=======================================================================
	*************************  sta mode Options  **************************
	=======================================================================
	wifi -o sta
			: open sta mode
	wifi -f
			: close sta mode
	wifi -s
			: scan wifi
	wifi -c ssid [passwd]
			: connect to an encrypted or non-encrypted ap
	wifi -d
			: disconnect from ap
	wifi -a [enable/disable]
			: Auto reconnect
	wifi -l [all]
			: list connected or saved ap information
	wifi -r [ssid/all]
			: remove a specified network or all networks
	wifi -p [softap/ble/xconfig/soundwave]
			: softap/ble/xconfig/soundwave distribution network

	=======================================================================
	*************************  ap mode Options  ***************************
	=======================================================================
	wifi -o ap [ssid] [passwd]
			: open ap mode
			: if ssid and passwd is not set, start the default configuration: (allwinner-ap Aa123456)
			: if only set ssid, start the ap without passwd
	wifi -l
			: list current ap mode information
	wifi -f
			: close ap mode
	=======================================================================
	***********************  monitor mode Options  ************************
	=======================================================================
	wifi -o monitor
			: open monitor mode
	wifi -f
			: close monitor mode
	=======================================================================
	***************************  other Options  ***************************
	=======================================================================
	wifi -D [error/warn/info/debug/dump/exce]
			: set debug level
	wifi -g
			: get system mac addr
	wifi -m [macaddr]
			: set system mac addr
	wifi -h
			: print help
	=======================================================================
相关推荐
Aczone282 天前
驱动(二)Linux 系统移植、驱动开发框架
linux·运维·驱动开发
天山老妖的混世牛魔王2 天前
KMDF驱动编写遇到的第一个编译问题
c++·驱动开发
fatfishccc3 天前
(七)API 重构的艺术:打造优雅、可维护的 API
java·驱动开发·intellij-idea·软件研发·后端开发·代码重构·api重构
小狗爱吃黄桃罐头4 天前
正点原子【第四期】Linux之驱动开发学习笔记-6.1 pinctrl和gpio子系统
linux·驱动开发·学习
每天更新4 天前
linux驱动开发笔记
linux·驱动开发·笔记
sheepwjl4 天前
《嵌入式驱动(二):驱动开发基本概念》
arm开发·驱动开发·单片机·嵌入式硬件·imx6ull·驱动·裸机
fatfishccc4 天前
(四)优雅重构:洞悉“搬移特性”的艺术与实践
java·驱动开发·intellij-idea·软件研发·后端开发·代码重构·搬移
CoderBob5 天前
【easy_tools】一个跨平台裸机工具库,包含任务/堆栈/消息/定时器/日志等实现
c语言·驱动开发·单片机·嵌入式硬件