1. 程式人生 > >移植MT7620A+MT7610E+MT76X2E到Openwrt trunk(Linux Kernel 3.14.32)

移植MT7620A+MT7610E+MT76X2E到Openwrt trunk(Linux Kernel 3.14.32)

一)MT7620

1)
#if defined(CONFIG_RA_HW_NAT) || defined(CONFIG_RA_HW_NAT_MODULE)
#include "../../../linux-2.6.36/net/nat/hw_nat/ra_nat.h"
#include "../../../linux-2.6.36/net/nat/hw_nat/frame_engine.h"
#endif

#if defined(CONFIG_RA_HW_NAT) || defined(CONFIG_RA_HW_NAT_MODULE)
#include "../../../../../../net/nat/hw_nat/ra_nat.h"
#include "../../../../../../net/nat/hw_nat/frame_engine.h"
#endif

2)
trunk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/mt7620-wifi2716_all_dpa_20130426/rt2860v2/os/linux/rt_linux.c
  將:  
    pOSFSInfo->fsuid = current_fsuid();
    pOSFSInfo->fsgid = current_fsgid();
  修改為:
    pOSFSInfo->fsuid = *(int *)&current_fsuid();
    pOSFSInfo->fsgid = *(int *)&current_fsgid();

3)application
編譯ralink自帶的gpio等程式時,可能會出現如下錯誤。

make[4]: Entering directory `*******/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/gpio'

staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/lib  -o gpio gpio.c
gpio.c:28:28: fatal error: linux/autoconf.h: No such file or directory
 #include <linux/autoconf.h>
                            ^

compilation terminated.
make[4]: *** [gpio] Error 1

修改a)

//#include <linux/autoconf.h>
#include <generated/autoconf.h>


修改b)
可能需要將原始碼中CONFIG_RALINK_MT7620這樣的編譯巨集修改為CONFIG_SOC_MT7620;
因為autoconf.h只有CONFIG_SOC_MT7620巨集定義;

enum {
#if defined (CONFIG_RALINK_RT3052)
 gpio2300,
 gpio3924,
 gpio5140,
#elif defined (CONFIG_RALINK_RT3883)
 gpio2300,
 gpio3924,
 gpio7140,
 gpio9572,
#elif defined (CONFIG_RALINK_RT3352)
 gpio2300,
 gpio3924,
 gpio4540,
#elif defined (CONFIG_RALINK_RT5350)
 gpio2100,
 gpio2722,
#elif defined (CONFIG_RALINK_RT6855A)
 gpio1500,
 gpio3116,
#elif defined (CONFIG_RALINK_MT7620)
 gpio2300,
 gpio3924,
 gpio7140,
 gpio72,
#elif defined (CONFIG_RALINK_MT7621)
 gpio3100,
 gpio6332,
 gpio9564,
#elif defined (CONFIG_RALINK_MT7628)
 gpio2300,
 gpio3924,
 gpio7140,
 gpio72,
#else
 gpio2300,
#endif
};

解決的一種方法是在gpio的Makefile檔案中新增如下的定義
ifeq ($(CONFIG_SOC_MT7620),y)
EXTRA_CFLAGS += -DCONFIG_RALINK_MT7620
endif


修改c)
build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/linux-3.14.32/drivers/char/ralink_gpio.h:37:32: fatal error: asm/rt2880/rt_mmap.h: No such file or directory

一種解決辦法:
建立目錄build_dir\target-mipsel_24kec+dsp_uClibc-0.9.33.2\linux-ramips_mt7620\linux-3.14.32\include\asm
將原廠SDK中的linux-2.6.36\include\asm\rt2880目錄拷貝到該目錄中,
#include <asm/rt2880/rt_mmap.h>


二)MT76x2e
1)
build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/mt7612e_mt7602e_LinuxAP_3.0.2.9_iPA_20140103/rlt_wifi_ap/../rlt_wifi/os/linux/rt_linux.c:911:20: error: incompatible types when assigning to type 'int' from type 'kgid_t'
   pOSFSInfo->fsgid = current_fsgid();

build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/mt7612e_mt7602e_LinuxAP_3.0.2.9_iPA_20140103/rlt_wifi_ap/../rlt_wifi/os/linux/rt_linux.c
 將:  
    pOSFSInfo->fsuid = current_fsuid();
    pOSFSInfo->fsgid = current_fsgid();
  修改為:
    pOSFSInfo->fsuid = *(int *)&current_fsuid();
    pOSFSInfo->fsgid = *(int *)&current_fsgid();

2)build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/mt7612e_mt7602e_LinuxAP_3.0.2.9_iPA_20140103/rlt_wifi_ap/../rlt_wifi/os/linux/rt_linux.c

#if defined(CONFIG_RA_HW_NAT) || defined(CONFIG_RA_HW_NAT_MODULE)
#include "../../../linux-2.6.36/net/nat/hw_nat/ra_nat.h"
#include "../../../linux-2.6.36/net/nat/hw_nat/frame_engine.h"
#endif

#if defined(CONFIG_RA_HW_NAT) || defined(CONFIG_RA_HW_NAT_MODULE)
#include "../../../../../../net/nat/hw_nat/ra_nat.h"
#include "../../../../../../net/nat/hw_nat/frame_engine.h"
#endif


三)MT7610e
1)build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/mt7610e_wifi_v3006_dpa_20130613//os/linux/pci_main_dev.c:43:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'rt2860_remove_one'
 static VOID __devexit rt2860_remove_one(struct pci_dev *pci_dev);

解決方法可以參考以下連結:
http://www.tinylab.org/faqs/fixup-compile-error-with-devinit-devexit/
如果報錯的函式前有 __devinit 或者 __devexit 等巨集,那麼罪魁禍首的就是這個了。因為這些巨集在 Linux Kernel 3.8 之後,就已經移除了;而在3.8.1之前的版本中
在linux/init.h中有如下的定義。
* Used for HOTPLUG */
#define __devinit        __section(.devinit.text) __cold notrace
#define __devinitdata    __section(.devinit.data)
#define __devinitconst   __constsection(.devinit.rodata)
#define __devexit        __section(.devexit.text) __exitused __cold notrace
#define __devexitdata    __section(.devexit.data)
#define __devexitconst   __constsection(.devexit.rodata)

修改後參考程式碼如下:
/* */
/* Function declarations */
/* */
/*extern int rt28xx_close(IN struct net_device *net_dev); */
/*extern int rt28xx_open(struct net_device *net_dev); */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,1)
static VOID __exit rt2860_remove_one(struct pci_dev *pci_dev);
static INT __init rt2860_probe(struct pci_dev *pci_dev, const struct pci_device_id  *ent);
#else
static VOID __devexit rt2860_remove_one(struct pci_dev *pci_dev);
static INT __devinit rt2860_probe(struct pci_dev *pci_dev, const struct pci_device_id  *ent);
#endif


/* */
/* Ralink PCI device table, include all supported chipsets */
/* */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,1)
static struct pci_device_id rt2860_pci_tbl[] __initdata =
#else
static struct pci_device_id rt2860_pci_tbl[] __devinitdata =
#endif
{
#ifdef RT3290
 {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3290_PCIe_DEVICE_ID)},
#endif /* RT3290 */

/* */
/* Our PCI driver structure */
/* */
static struct pci_driver rt2860_driver =
{
    name:       RTMP_DRV_NAME,
    id_table:   rt2860_pci_tbl,
    probe:      rt2860_probe,
#if LINUX_VERSION_CODE >= 0x20412
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,1)
    remove:     __exit_p(rt2860_remove_one),
#else
    remove:     __devexit_p(rt2860_remove_one),
#endif
#else
    remove:     __devexit(rt2860_remove_one),
#endif

/* */
/* PCI device probe & initialization function */
/* */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,1)
static int __init rt2860_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
#else
static int __devinit rt2860_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
#endif
{
 VOID     *pAd = NULL;


#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,1)
static VOID __exit rt2860_remove_one(struct pci_dev *pci_dev)
#else
static VOID __devexit rt2860_remove_one(struct pci_dev *pci_dev)
#endif
{
 PNET_DEV net_dev = pci_get_drvdata(pci_dev);


2)
build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/mt7610e_wifi_v3006_dpa_20130613//os/linux/rt_linux.c:899:20: error: incompatible types when assigning to type 'int' from type 'kuid_t'
   pOSFSInfo->fsuid = current_fsuid();


build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/mt7610e_wifi_v3006_dpa_20130613//os/linux/rt_linux.c
 將:  
    pOSFSInfo->fsuid = current_fsuid();
    pOSFSInfo->fsgid = current_fsgid();
  修改為:
    pOSFSInfo->fsuid = *(int *)&current_fsuid();
    pOSFSInfo->fsgid = *(int *)&current_fsgid();

3)build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/mt7610e_wifi_v3006_dpa_20130613//os/linux/rt_linux.c

#if defined(CONFIG_RA_HW_NAT) || defined(CONFIG_RA_HW_NAT_MODULE)
#include "../../../linux-2.6.36/net/nat/hw_nat/ra_nat.h"
#include "../../../linux-2.6.36/net/nat/hw_nat/frame_engine.h"
#endif

#if defined(CONFIG_RA_HW_NAT) || defined(CONFIG_RA_HW_NAT_MODULE)
#include "../../../../../../net/nat/hw_nat/ra_nat.h"
#include "../../../../../../net/nat/hw_nat/frame_engine.h"
#endif