"Linux kernel driver" compile Linux mt7612u driver __linux

Source: Internet
Author: User

A WiFi module was used in the recent project, the master being mt7612u, and the USB interface. Use of Linux version 2.6.35, in the process of compiling the driver encountered a lot of problems, especially in this record. Get the source

MTK official website Drive. Contains Windows, Linux, and drivers under the Mac. I modified the GitHub drive. Add a new platform

In the source code built some hardware platform configuration information, if not suitable for the platform you use information, you need to manually add configuration information. Modifying the makefile of the root directory

The following code can be found near line 38:

#PLATFORM: Target PLATFORM
PLATFORM = PC
#PLATFORM = 5VT
#PLATFORM = ikanos_v160

Below I need to add a platform of the arm architecture and make it effective:

#PLATFORM: Target PLATFORM
#PLATFORM = PC
PLATFORM = ARM
#PLATFORM = 5VT
#PLATFORM = ikanos_v160

Note that only one platform can be in effect, otherwise there will be a conflict.

Near line 111, you can find platform-dependent environment variables, mainly including the kernel source path and the path of the cross compiler:

Ifeq ($ (PLATFORM), 5VT)
linux_src =/home/ralink-2860-sdk-5vt-distribution/linux-2.6.17
cross_compile =/ opt/crosstool/uclibc_v5te_le_gcc_4_1_1/bin/arm-linux-
endif

Imitating the above code, we add two environment variable settings for the ARM platform:

Ifeq ($ (PLATFORM), ARM)                                                                      
linux_src =/home/ryan/develop/kernel/linux-2.6.35.3                                        
cross_compile =/home/common/ cross_compiler/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-                              
endif
Modify Os/linux/config.mk

Platform-related definitions can be found near line 1280, mainly the definition of cflags, which determines what features are supported by the driver, and special compilation options:

#################################################
# Platform Related Definitions
#  
################## ###############################

ifeq ($ (PLATFORM), 5VT)                                                                                                    
#WFLAGS + +-dconfig_5vt_enhance
endif

Next, add the platform information for the ARM architecture:

Ifeq ($ (PLATFORM), ARM)                                                                                                    
wflags + =-drt_little_endian-w
extra_cflags: = $ (wflags)-i$ (rt28xx_dir)/include
endif

Because ARM uses small-end storage, the purpose of defining a macro rt_little_endian,-w is to not display warning messages, because many of the code, for historical reasons, produce a large number of warnings that are not conducive to fast locating error messages. Select the operating mode of the network card

There are generally two modes of NIC, AP and Sta. The AP is one of the connected parties, and the STA is the one that initiates the connection. Because my demand is AP, I need to configure it as AP.

Open the root directory of the makefile, in line 2nd can find rt28xx_mode this variable, the default is STA, we change it to AP. Select Chipset

Many chip manufacturers for the same model of the chip, provide a variety of different interfaces, such as USB,PCI. A chip that has been slightly modified may have changed another model, but they actually use the same drive and they can act as a series. When choosing a chipset, we need to select all of the same series of chips that use the same interface, and in Makefile, they will be configured for the same and different features.

The chipset variable can be found near 21 rows in the makefile of the root directory. There are some comments above, as follows:

# chipset # rt2860, rt2870, rt2880, rt2070, rt3070, rt3090, rt3572, rt3062,
rt3562, rt3593, rt3573
# rt3562 (for RT 3592), rt3050, rt3350, rt3352, rt5350, rt5370, rt5390, rt5572, rt5592, 
# rt8592 (for rt85592), 
# mt7601e, mt7601u,< c4/># mt7620,
mt7650e, mt7630e, mt7610e, mt7650u, mt7630u, mt7610u, mt7662e, mt7632e, mt7612e, mt7662u, mt7632u
, mt7612u

Each line represents a series, e ends with a PCI interface, and u ends with a USB interface, which requires selection of mt7662u, mt7632u, and mt7612u for mt7612u.

So the chipset variable is configured as follows:

Ifeq ($ (chipset),)
chipset = mt7612u mt7632u mt7662u

Notice here that the first value will be the driver's name, so I put the mt7612u on the first one. compiling

Complete the above configuration, the following can be compiled, directly in the source root directory to execute make can, usually, usually you will encounter a lot of errors, a little modification can be. The problems I've encountered

WARNING: "Cfg80211_find_vendor_ie" [/home/ryan/develop/module/mt7612u/os/linux/mt7662u_ap.ko] undefined!

The reason for this problem is that the function is declared, but not defined. By searching in the kernel, we found that there was no such function, but the search was found in the kernel of 3.10, which was basically determined to be a kernel version problem.
The workaround is to use conditional compilation to include the code that calls the function, provided the kernel version is used. By searching, we can know that the function is called in line 113th of the Cfg80211_ap.c file:

Wmm_ie = Cfg80211_find_vendor_ie (Wfa_oui, Wmm_oui_type, Pbeacon->beacon_tail, Pbeacon->beacon_tail_len);

Through Google search, modified to the following form

#if (Linux_version_code >= kernel_version (3, 2, 0)) 

Wmm_ie = Cfg80211_find_vendor_ie (Wfa_oui, Wmm_oui_type, Pbeacon->beacon_ta

#endif

WARNING: "rtmp_cfg80211_vif_p2p_go_on" [/home/ryan/develop/module/mt7612u/os/linux/mt7662u_ap.ko] undefined!
This is the same as the problem for the above, function declaration but undefined. But this function is not a function in the kernel, but a function that drives the source code.
By searching, you can tell that the function is actually defined, but because we do not have peer-to-peer functionality, so it is not compiled, at this time can not be taken for granted Peer-to-peer support, when not understand a feature, if used it will introduce more errors.
Because we did not enable Peer-to-peer, but this warning indicates that we did call the function, but normally it should not be called, the following is the location of the call, in the CFG80211_AP.C 287 lines:

if (rtmp_cfg80211_vif_p2p_go_on (pAd)) 
    BeaconTransmit.field.MODE = MODE_OFDM/* Use 6Mbps */
else
    BeaconTransmit.field.MODE = MODE_CCK;   

The solution is still to add conditional compilation, still through Google search, I found the right way to add:

#ifdef rt_cfg80211_p2p_support

if (rtmp_cfg80211_vif_p2p_go_on (pAd)) 
    BeaconTransmit.field.MODE = MODE_OFDM ; /* Use 6Mbps
*

/Else #endif

    BeaconTransmit.field.MODE = MODE_CCK;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.