Linux学习笔记之RTL8723使用

 

1 RTL8723模块

RTL8723是一款具有wifi和蓝牙功能的芯片。Wifi是usb接口的。

2驱动移植与编译

2.1 配置内核

Usb设备支持

clip_image002

支持wifi设备

clip_image004

支持IEEE 802.11

clip_image006

2.2 编译驱动

解压驱动源文件

#tar xvf rtl8723BU_WiFi_linux_v4.3.16_14189.20150519_BTCOEX20150119-5844.tar.gz

进入驱动源文件目录

#cd rtl8723BU_WiFi_linux_v4.3.16_14189.20150519_BTCOEX20150119-5844

修改Makefile文件,增加平台类型,默认为I386_PC。增加CONFIG_PLATFORM_NUVOTON_NUC970 = y,把将其他平台都设置为n

###################### Platform Related #######################

CONFIG_PLATFORM_I386_PC = n

CONFIG_PLATFORM_NUVOTON_NUC970 = y

CONFIG_PLATFORM_ANDROID_X86 = n

CONFIG_PLATFORM_ANDROID_INTEL_X86 = n

CONFIG_PLATFORM_JB_X86 = n

CONFIG_PLATFORM_ARM_S3C2K4 = n

CONFIG_PLATFORM_ARM_PXA2XX = n

CONFIG_PLATFORM_ARM_S3C6K4 = n

CONFIG_PLATFORM_MIPS_RMI = n

CONFIG_PLATFORM_RTD2880B = n

CONFIG_PLATFORM_MIPS_AR9132 = n

CONFIG_PLATFORM_RTK_DMP = n

CONFIG_PLATFORM_MIPS_PLM = n

CONFIG_PLATFORM_MSTAR389 = n

CONFIG_PLATFORM_MT53XX = n

CONFIG_PLATFORM_ARM_MX51_241H = n

CONFIG_PLATFORM_FS_MX61 = n

CONFIG_PLATFORM_ACTIONS_ATJ227X = n

CONFIG_PLATFORM_TEGRA3_CARDHU = n

CONFIG_PLATFORM_TEGRA4_DALMORE = n

CONFIG_PLATFORM_ARM_TCC8900 = n

CONFIG_PLATFORM_ARM_TCC8920 = n

CONFIG_PLATFORM_ARM_TCC8920_JB42 = n

CONFIG_PLATFORM_ARM_RK2818 = n

CONFIG_PLATFORM_ARM_RK3066 = n

CONFIG_PLATFORM_ARM_RK3188 = n

CONFIG_PLATFORM_ARM_URBETTER = n

CONFIG_PLATFORM_ARM_TI_PANDA = n

CONFIG_PLATFORM_MIPS_JZ4760 = n

CONFIG_PLATFORM_DMP_PHILIPS = n

CONFIG_PLATFORM_MSTAR_TITANIA12 = n

CONFIG_PLATFORM_MSTAR = n

CONFIG_PLATFORM_SZEBOOK = n

CONFIG_PLATFORM_ARM_SUNxI = n

CONFIG_PLATFORM_ARM_SUN6I = n

CONFIG_PLATFORM_ARM_SUN7I = n

CONFIG_PLATFORM_ARM_SUN8I_W3P1 = n

CONFIG_PLATFORM_ARM_SUN8I_W5P1 = n

CONFIG_PLATFORM_ACTIONS_ATM702X = n

CONFIG_PLATFORM_ACTIONS_ATV5201 = n

CONFIG_PLATFORM_ACTIONS_ATM705X = n

CONFIG_PLATFORM_ARM_RTD299X = n

CONFIG_PLATFORM_ARM_SPREADTRUM_6820 = n

CONFIG_PLATFORM_ARM_SPREADTRUM_8810 = n

CONFIG_PLATFORM_ARM_WMT = n

CONFIG_PLATFORM_TI_DM365 = n

CONFIG_PLATFORM_MOZART = n

CONFIG_PLATFORM_RTK119X = n

CONFIG_PLATFORM_NOVATEK_NT72668 = n

CONFIG_PLATFORM_HISILICON = n

###############################################################

增加CONFIG_PLATFORM_NUVOTON_NUC970相关配置在(ifeq ($(CONFIG_PLATFORM_I386_PC), y)之后添加)

ifeq ($(CONFIG_PLATFORM_NUVOTON_NUC970), y)

EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN

ARCH := arm

CROSS_COMPILE :=arm-linux-

KVER := 3.10.108

KSRC := /work/nuc970/emyard/nuc970_linux_kernel

endif

其中

EXTRA_CFLAGS:小端模式;

ARCH:arm 平台;

CROSS_COMPILE:交叉编译器;

KVER:内核版本号;

KSRC:内核所在目录;

#make 编译驱动

2.3 编译wpa_supplication

解压缩

#tar xvf wpa_supplicant_hostapd-0.8_rtw_r7475.20130812.tar.gz

进入wpa_supplication目录

#cd wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/wpa_supplicant

编译wpa_supplication

#make CC=arm-linux-gcc

编译成功后,在wpa_supplication目录下会出现3个可执行工具:wpa_supplicant、wpa_passphrase、wpa_cli,将他们拷贝到开发板。

在开发板上,创建wpa_supplicant.conf文件。文件的内容如下:

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

update_config=1

ap_scan=1

network={

ssid=”MF20_IPCAM”

key_mgmt=WPA-PSK

proto=WPA2

pairwise=CCMP

psk=”MF201234567890″

}

2.4 使用wifi驱动

加载驱动模块

#insmod 8723bu.ko

启动wifi模块

#ifconfig wlan0 up

连接到路由器

开启一个无线路由器,设置名称与密码,同配置文件wpa_supplicant.conf中一致。

在开发板上执行wpa_supplicant:

# ./wpa_supplicant -Dwext -iwlan0 -c wpa_supplicant.conf &

设置ip地址

#ifconfig wlan0 xxx.xxx.xxx.xxx

或动态获取IP地址

# udhcpc -i wlan0

用ping测试网络

#ping 192.168.1.1

3. softAP实现

3.1 编译hostap

解压源文件

#tar xvf wpa_supplicant_hostapd-0.8_rtw_r7475.20130812.tar.gz

进入hostapd目录

#cd wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/hsotapd

编译hostapd

#make CC=arn-linux-gcc

编译后生成hostapd、hostapd_cli等命令

拷贝hostapd、hostapd_cli等命令及配置文件rtl_hostapd_2G.conf到开发板中。复制rtl_hostapd_2G.conf到开发板/etc目录下。

3.2使用hostap

加载驱动并设置IP地址

#insmod 8723bu.ko

#ifconfig wlan0 up

#ifconfig wlan0 192.168.0.2

启动hostap

#./hostapd /etc/rtl_hostapd_2G.conf -B

此时,可以用笔记本检测到此wifi信号,并可以连接上,但需要配置静态IP地址

支持dhcp

从busybox源码里的example/dhcp/下复制udhcpd.conf文件到开发板/etc下,修改里面的interface为wlan0。

开启udhcpd服务

#udhcpd -fs /etc/udhcpd.conf