首先修改driver下驱动文件中的Makefile文件:
添加自己的平台,我的平台是hi3518c,具体操作如下:
#add the new platform hi3518c alter by kj
CONFIG_PLATFORM_HI_3518C = y
添加平台的编译选项:
#add the compile option for hi_3518c alter by kj
ifeq ($(CONFIG_PLATFORM_HI_3518C), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN-DCONFIG_MINIMAL_MEMORY_USAGE
ARCH := arm
CROSS_COMPILE := arm-hisiv100nptl-linux-
KVER := 3.0.8
KSRC :=/home/kongjun/mywork/develop_kj/Hi3518_SDK_V1.0.3.0/osdrv/kernel/linux-3.0.y
endif
注意:
CONFIG_POWER_SAVING =n(省电模式最好关闭)
下面是官方文档的编译说明:
Introduction
Inthis document, we introduce two ways to compileand install our Wi-Fidriver:
1) Using install.sh script for PC-Linux and 2) Step by step manually. The former
targets for end users who are not familiar with Linux system, while the later for
engineers who want to portour Wi-Fi driver ontodifferentplatforms.
1. Using install.sh Script for PC-Linux
For driver compilation and installation in PC-Linux, we provide an install.sh
script to do the duties automatically. If you want to use our Wi-Fi solutions to access
network on PC-Linux, you can just run install.sh script and then control Wi-Fi with
utilities such as Network Manager. For further information about Wi-Fi station mode,
please refer to:
document/Quick_Start_Guide_for_Station_Mode.pdf.
If you want to apply our Wi-Fi solutions on other embedded platforms, you
should readand checkthe followingparagraphs.
2. Decompress the driversource tarball
The driver source tar ball is located in the driver folder of our software package.
For example, to decompressrtl8188C_8192C_8192D_usb_linux_v3.3.0_2920.20111123.tar .gz :
root@driver/# tar zxvfrtl8188C_8192C_8192D_usb_linux_v3.3.0_2920.20111123.tar .gz
2
3. Selecting Chip T ype with make_drv Script (forcompound release)
Our driver source release has two types: 1) single release, which can build out
driver only for singlechiptype,and 2) compound release, whichcan build out drivers
for multiple chiptypes separately .
For compoundrelease driver , you will see make_drvscriptafter youdecompress
the driver tar ball locatedin driver folder . Before compilingdriver source, executing
the make_drv toselect the target chip type to compile. Forexample:
4. Compilation Settings in Makefile
4.1. Adding orSelecting T arget Platform
The default target platform is PC-Linux, if you donot wanttocompile driver for
otherplatforms you canskip this section.
T o add or select target platform for compilation, we provide two sections in
Makefile: 1) platform selection section and 2) platform setting section. First, you
should look atthe platform selection section of Makefile:
The platform selection section consists of entries with ‘CONFIG_PLA TFORM_’
prefix. Only one entry is allowed to be set with value ‘y’ and others with ‘n’. The
CONFIG_PLATFORM_I386_PC = y
CONFIG_PLA TFORM_ANDROID_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_MT53XX = n
CONFIG_PLATFORM_RTK_DMP = n
root@rtl8188C_8192C_8192D_usb_linux_v3.3.0_2920.20111123#./make_drv
Please select chip type(1/2):
1) RTL8192cu
2) RTL8192du
#?1
You have selected RTL8192cu
3
‘CONFIG_PLA TFORM_I386_PC’ is selectedbydefault.
We can select an existing entry or add a new entry for your target platform. For
example, toadd andselect a new entry , ‘CONFIG_PLATFORM_NEW’:
Second, you shouldcreateand/or modify thecorresponding entry inside platform
settingsection. For example, addingthe followingentry in platform setting sectionfor
‘CONFIG_PLA TFORM_NEW’ we justadd:
4.2. PlatformSetting Section in Detail
l EXTRA_CFLAGS
The EXTRA_CFLAGS is usually used to carry some additional settings at
compilation time throughmacro definitions.
Macro Effect
CONFIG_BIG_ENDIAN Define some internal datastructure as big endian.
CONFIG_LITTLE_ENDIAN Define some internal datastructure as little endian.
CONFIG_MINIMAL_MEMORY_USAGE For better performance in powerful platform, we
allocate large physical continuous memory as TX/RX
IO buffers. In some embedded platform, there is
chance to fail to allocate memory . Define this macroto
prevent this situation.
CONFIG_PLA TFORM_ANDROID Older Android kernel do not has CONFIG_ANDROID
defined. Define this macro to force the Android
corresponding code inside our driver to be compiled.
For newer Android kernel, it has no need to define this
macro, otherwise, warning message about redefinition
will show up
ifeq ($(CONFIG_PLA TFORM_NEW), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
ARCH := arm
CROSS_COMPILE :=/opt/new/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
KSRC := /opt /new/kernel
endif
CONFIG_PLATFORM_I386_PC = n
CONFIG_PLATFORM_NEW = y
4
l ARCH
TheARCH is used to specify the architecture of the target platformCPU, such as:
arm, mips, i386, etc.
l CROSS_COMPILE
The CROSS_COMPILE is used to specify the toolchain prefix used for driver
compilation.
l KSRC
The KSRC is used to specify the path of kernel source used for driver
compilation
l MODULE_NAME
Differentmodule name is assigned to drivers for differentchips:
If you wantto change the modulename, you can set value of MODULE_NAME
here. For example, settingmodule name as ‘wlan’:
4.3. Other Compilation Settings
We still have some compilationsettings couldbe applied. Forsettings andfurther
informationaboutpowersaving mode, please refer to:
document/HowT o_enable_the_power_saving_functionality .pdf.
If you know what the macro means in the autoconf file, you could modify the
Chip type Default module name
RTL8192CU-series 8192cu
RTL8192CE-series 8192ce
RTL8192DU-series 8192du
RTL8192DE-series 8192de
RTL8723AS-series 8723as
RTL8723AU-series 8723au
RTL8189ES-series 8189es
RTL8188EU-series 8188eu
ifeq ($(CONFIG_PLA TFORM_NEW), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
ARCH := arm
CROSS_COMPILE :=/opt/new/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
KSRC := /opt /new/kernel
MODULE_NAME := wlan
endif
5
configuration by yourself. See the following table for the autoconf file you should
modifyfor a specific chip type:
5. Integrating DriverSource into Linux Kernel Tree
This paragraph is for integrating our driver source into Linuxkernel tree and
buildingsystem. If you havenoneedtodo this, simplyskip thisparagraph.
For compoundrelease driver source, make_drvshould be execute toselect chip
typefor the driver source. Please refer to:
“3. SelectingChip T ypewith make_drvScript (for compoundrelease)”.
For different chip types, we have different suggestions for and
touse for the integration process:
Assuming the driver source is for RTL8192CU-series, to integrate driver source
into kernel buildingsystem, go through the followingsteps:
1). Copy the driver source folder into drivers/net/wireless/ and rename it as
, rtl8192cu.
Chip type Autoconf file to modif y
RTL8192CU-series autoconf_rtl8192c_usb_linux.h
RTL8192CE-series autoconf_rtl8192c_pci_linux.h
RTL8192DU-series autoconf_rtl8192d_usb_linux.h
RTL8192DE-series autoconf_rtl8192d_pci_linux.h
RTL8723AS-series autoconf_rtl8723a_sdio_linux.h
RTL8723AU-series autoconf_rtl8723a_usb_linux.h
RTL8189ES-series autoconf_rtl8189e_sdio_linux.h
RTL8188EU-series autoconf_rtl8188e_usb_linux.h
Chip type
RTL8192CU-series CONFIG_RTL8192CU rtl8192cu
RTL8192CE-series CONFIG_RTL8192CE rtl8192du
RTL8192DU-series CONFIG_RTL8192DU rtl8192du
RTL8192DE-series CONFIG_RTL8192DE rtl8192de
RTL8723AS-series CONFIG_RTL8723AS rtl8723as
RTL8723AU-series CONFIG_RTL8723AU rtl8723au
RTL8189ES-series CONFIG_RTL8189ES rtl8189es
RTL8188EU-series CONFIG_RTL8188EU rtl8188eu
6
2). Add the following line into drivers/net/wireless/Makefile, CONFIG_RTL8192CU
is for , rtl8192cuis for :
3). Add the following line into drivers/net/wireless/Kconfig, rtl8192cu is for
:
4). Config kernel, for example,with ‘make menuconfig’ command to select ‘y’ or‘m’
for our driver .
5). Now, you canbuild kernel with ‘make’command.
6. Compiling Driver
6.1. Compiling Driverin DriverSource Folder
For compilingdriver inthe originaldriver source folder , simply cdinto the
driver source folder andstart builddriver with‘make’ command.
If everything goes well, it will produce a MODULE_NAME.ko file.The
MODULE_NAME is specifiedinMakefile. Please refer to:
“MODULE_NAME” in “4.2. Platform SettingSection in Detail”.
6.2. Compiling Driver under Kernel Tree
For compilingdriver under kerneltree, please refer to:
“5. IntegratingDriver Source intoLinux Kernel Tree”.
7. DriverInstallation
If you have compiled Wi-Fi driveras kernel module and produced a .kofile such
as 8192cu.ko, you should insert driver module with‘insmod’ command:
As for driver compiledin kernel, it has no needtodo ‘insmod’command