Port MTK SDK to OpenWrt

来源:互联网 发布:淘宝杰士邦旗舰店 编辑:程序博客网 时间:2024/06/07 10:33

Overview

Tarball MediaTek_ApSoC_SDK_4300_20140916.tar.bz2, assuming this obsoletes MTK_Ralink_ApSoC_SDK_4210_20140326.tar.bz2, yes?

Issues

  • Do we really not need to run make dep?

Installing toolchains

Unload MTK SDK tarball, install relevant toolchains under /opt:

  • buildroot-gcc342
  • buildroot-gcc463

Activate 3.10.14 kernel for MT7620

In config/mkconfig (line 107), change:

echo "elif [ \$CONFIG_DEFAULTS_RALINK_MT7620 = \"y\" ]; then"echo " define_bool CONFIG_DEFAULTS_KERNEL_2_6_36 y"echo " define_bool CONFIG_DEFAULTS_KERNEL_3_10_14 n"

to:

echo "elif [ \$CONFIG_DEFAULTS_RALINK_MT7620 = \"y\" ]; then"echo " define_bool CONFIG_DEFAULTS_KERNEL_2_6_36 n"echo " define_bool CONFIG_DEFAULTS_KERNEL_3_10_14 y"

Fix various Makefiles

Build errors of the form:

Makefile:376: *** mixed implicit and normal rules.  Stop.

are explained here, so you have to adjust a number of Makefiles to work with the newest version of make. Just fix the errors as you run across them.

Non-wifi build

Start with trying to build a basic image with no WiFi support yet (and no OpenWrt support), make dep generates diagnostics:

ralink/Kconfig:206:warning: 'RT_FIRST_CARD': number is invalidralink/Kconfig:207:warning: 'RT_FIRST_CARD': number is invalidralink/Kconfig:208:warning: 'RT_FIRST_CARD': number is invalidralink/Kconfig:221:warning: 'RT_SECOND_CARD': number is invalidralink/Kconfig:222:warning: 'RT_SECOND_CARD': number is invalidralink/Kconfig:223:warning: 'RT_SECOND_CARD': number is invalidralink/Kconfig:224:warning: 'RT_SECOND_CARD': number is invalid

because of config entries that are defined as "int" but have some non-int values:

config  RT_FIRST_CARD        int        depends on ! FIRST_IF_NONE        default 2860 if FIRST_IF_RT2860        default 7620 if FIRST_IF_MT7620        default 7628 if FIRST_IF_MT7628        default 3090 if FIRST_IF_RT3092        default 5392 if FIRST_IF_RT5392        default 5592 if FIRST_IF_RT5592        default 3593 if FIRST_IF_RT3593        default 7610 if FIRST_IF_MT7610E        default 7612e if FIRST_IF_MT7612E        default 7602e if FIRST_IF_MT7602E        default 7603e if FIRST_IF_MT7603Econfig  RT_SECOND_CARD        int        depends on ! SECOND_IF_NONE        default 3090 if SECOND_IF_RT3092        default 5392 if SECOND_IF_RT5392        default 5592 if SECOND_IF_RT5592        default 3593 if SECOND_IF_RT3593        default 7610 if SECOND_IF_MT7610E        default 8592 if SECOND_IF_RT8592        default 3572 if SECOND_IF_RT3572        default 5572 if SECOND_IF_RT5572        default 7612e if SECOND_IF_MT7612E        default 7612u if SECOND_IF_MT7612U        default 7602e if SECOND_IF_MT7602E        default 7603e if SECOND_IF_MT7603E

Obviously, those config selections shouldn't be defined as "int"; MediaTek should fix that, but it doesn't affect us -- this produces a successful build.

Adding OpenWrt Support

If you now try to add "OpenWrt Support", you get the build error:

... snip ...make -C  libnvrammake[2]: Entering directory '/home/rpjday/flex/MTK_SDK/SDK/RT288x_SDK/source/lib/libnvram'make[2]: *** No rule to make target '/home/rpjday/flex/MTK_SDK/SDK/RT288x_SDK/source/kernel_headers/include/linux/autoconf.h', needed by 'crc32.o'.  Stop.make[2]: Leaving directory '/home/rpjday/flex/MTK_SDK/SDK/RT288x_SDK/source/lib/libnvram'Makefile:369: recipe for target '_dir_libnvram' failedmake[1]: *** [_dir_libnvram] Error 2make[1]: Leaving directory '/home/rpjday/flex/MTK_SDK/SDK/RT288x_SDK/source/lib'Makefile:493: recipe for target 'lib_only' failedmake: *** [lib_only] Error 2

This seems odd since if you *don't* select "Support OpenWrt", that library appears to build just fine, so there's something in the selection of OpenWrt support that clearly changes the build environment.

Here's a snippet of the Makefile from that directory:

ifneq ($(KERNEL_HEADERS),)LINUXDIR = $(KERNEL_HEADERS)endif... snip ...OBJS    := crc32.o nvram_env.o flash_api.oHEADERS := nvram_env.h nvram.h flash_api.h $(ROOTDIR)/$(LINUXDIR)/include/linux/autoconf.h

so an early setting of KERNEL_HEADERS can certainly screw things up.

From a completely fresh checkout of the SDK, we have this:

$ find . -name autoconf.h./linux-3.10.14.x/include/generated/autoconf.h   <--- ????./lib/libgdbm-1.8.3/autoconf.h./lib/vstr-1.0.15/include/autoconf.h$

Do a non-OpenWrt configure and build for MT7620A, and it all works (libnvram directory is compiled), and:

$ find . -name autoconf.h./linux-3.10.14.x/include/linux/autoconf.h./linux-3.10.14.x/include/uapi/linux/autoconf.h./linux-3.10.14.x/include/generated/autoconf.h./config/autoconf.h./lib/libgdbm-1.8.3/autoconf.h./lib/vstr-1.0.15/include/autoconf.h./kernel_headers/include/linux/autoconf.h./autoconf.h./user/busybox/include/autoconf.h$

After make clean:

$ find . -name autoconf.h./linux-3.10.14.x/include/linux/autoconf.h./linux-3.10.14.x/include/uapi/linux/autoconf.h./linux-3.10.14.x/include/generated/autoconf.h./config/autoconf.h./lib/libgdbm-1.8.3/autoconf.h./lib/vstr-1.0.15/include/autoconf.h./autoconf.h./user/busybox/include/autoconf.h$

After doing another make (which should change nothing):

$ find . -name autoconf.h./linux-3.10.14.x/include/linux/autoconf.h./linux-3.10.14.x/include/uapi/linux/autoconf.h./linux-3.10.14.x/include/generated/autoconf.h./config/autoconf.h./lib/libgdbm-1.8.3/autoconf.h./lib/vstr-1.0.15/include/autoconf.h./kernel_headers/include/linux/autoconf.h./autoconf.h./user/busybox/include/autoconf.h$

One last time, make clean, add OpenWrt Support, save, and here's the kernel config file difference:

$ diff .config.old .config5c5< # CONFIG_SUPPORT_OPENWRT is not set---> CONFIG_SUPPORT_OPENWRT=y31a32> # CONFIG_RT2880_ROOTFS_IN_FLASH is not set42c43< # CONFIG_BOOT_RAW is not set---> CONFIG_BOOT_RAW=y55d55< CONFIG_BOOT_ELF32=y604a605> # CONFIG_MTD_SPLIT is not set$

Nothing jumps out at me, so try to build and get earlier error:

make -C  libnvrammake[2]: Entering directory '/home/rpjday/flex/MTK_SDK/SDK/RT288x_SDK/source/lib/libnvram'make[2]: *** No rule to make target '/home/rpjday/flex/MTK_SDK/SDK/RT288x_SDK/source/kernel_headers/include/linux/autoconf.h', needed by 'crc32.o'.  Stop.make[2]: Leaving directory '/home/rpjday/flex/MTK_SDK/SDK/RT288x_SDK/source/lib/libnvram'Makefile:369: recipe for target '_dir_libnvram' failedmake[1]: *** [_dir_libnvram] Error 2make[1]: Leaving directory '/home/rpjday/flex/MTK_SDK/SDK/RT288x_SDK/source/lib'Makefile:493: recipe for target 'lib_only' failedmake: *** [lib_only] Error 2

because this:

$ find . -name autoconf.h./linux-3.10.14.x/include/linux/autoconf.h./linux-3.10.14.x/include/uapi/linux/autoconf.h./linux-3.10.14.x/include/generated/autoconf.h./config/autoconf.h./lib/libgdbm-1.8.3/autoconf.h./lib/vstr-1.0.15/include/autoconf.h./autoconf.h./user/busybox/include/autoconf.h$

In short, asking for OpenWrt support prevents autoconf.h from being placed in the kernel_headers directory. Oh, wait, here it is in the kernel source file include/uapi/linux/Kbuild:

ifndef CONFIG_SUPPORT_OPENWRTheader-y += autoconf.hendif

What's the reason for that?

KERNEL_HEADERS

Under vendors/Ralink/MT7620/config/:

$ grep KERNEL_HEADERS *2M_16M_config.uclibc0933-3.10.14.x:KERNEL_HEADERS="$(ROOTDIR)/kernel_headers/include"2M_16M_config.uclibc-3.10.14.x:KERNEL_SOURCE="$(ROOTDIR)/$(KERNEL_HEADERS)"4M_32M_config.uclibc0933-2.6.36.x:KERNEL_HEADERS="$(ROOTDIR)/$(LINUXDIR)/include"4M_32M_config.uclibc0933-3.10.14.x:KERNEL_HEADERS="$(ROOTDIR)/kernel_headers/include"4M_32M_config.uclibc-3.10.14.x:KERNEL_SOURCE="$(ROOTDIR)/$(KERNEL_HEADERS)"8M_32M_voip_config.uclibc0933-2.6.36.x:KERNEL_HEADERS="$(ROOTDIR)/$(LINUXDIR)/include"8M_32M_voip_config.uclibc0933-3.10.14.x:KERNEL_HEADERS="$(ROOTDIR)/kernel_headers/include"8M_32M_voip_config.uclibc-3.10.14.x:KERNEL_SOURCE="$(ROOTDIR)/$(KERNEL_HEADERS)"8M_64M_config.uclibc0933-3.10.14.x:KERNEL_HEADERS="$(ROOTDIR)/kernel_headers/include"8M_64M_config.uclibc-3.10.14.x:KERNEL_SOURCE="$(ROOTDIR)/$(KERNEL_HEADERS)"$

But under a 3.10 kernel, an external kernel headers seems unnecessary since all exported headers will be under include/uapi/ and various other uapi/ directories.

For now, cheap fix for include/uapi/linux/Kbuild:

# ifndef CONFIG_SUPPORT_OPENWRTheader-y += autoconf.h# endif

but why was this done in the first place? (Need to clean and rebuild to take effect.)

ralink/Kconfig

Wireless selection

In MTK SDK, extra line at end of arch/mips/Kconfig:

source "ralink/Kconfig"

As for ralink/Kconfig (the only file in the top-level ralink directory), here are the source directives:

source "drivers/net/rt_rdm/Kconfig"source "drivers/net/raeth/Kconfig"#source "drivers/net/wireless/rt2860v2_ap/Kconfig"#source "drivers/net/wireless/rt2860v2_sta/Kconfig"#source "drivers/net/wireless/RTPCI_ap/Kconfig"#source "drivers/net/wireless/RT3090_ap/Kconfig"#source "drivers/net/wireless/RT5392_ap/Kconfig"#source "drivers/net/wireless/RT5592_ap/Kconfig"#source "drivers/net/wireless/RT3593_ap/Kconfig"#source "drivers/net/wireless/RT3572_ap/Kconfig"#source "drivers/net/wireless/RT5572_ap/Kconfig"#source "drivers/net/wireless/iNIC/Kconfig"#source "drivers/net/wireless/iNIC_RT305x/Kconfig"#source "drivers/net/wireless/RT3680_ap/Kconfig"#source "drivers/net/wireless/MT7610_ap/Kconfig"#source "drivers/net/wireless/rlt_wifi/Kconfig"source "drivers/usb/dwc_otg/Kconfig"source "net/nat/hw_nat/Kconfig"

Here's the first mystery -- which selection for onboard 2.4G?

############## Wireless#############menuconfig WIFI_DRIVER        bool "WiFi Driver Support"if WIFI_DRIVERchoice        prompt "Choose First WiFi Interface"        config FIRST_IF_NONE        bool "None"        config FIRST_IF_RT2860        bool "RT2860 for rt2860v2 wifi driver"        select RTMP_MAC        select RALINK_RT2860        config FIRST_IF_MT7620        bool "MT7620 for rlt_wifi wifi driver"  <--- typo, "rtl_wifi", no?        select RTMP_MAC        select RALINK_RT6352

It looks like we want the second one -- "RT6352" is apparently the CPU type. But that config symbol doesn't appear to be tested anywhere in the newer kernels:

grep -r RT6352 *linux-2.6.21.x/include/asm-mips/rt2880/eureka_ep430.h:#elif defined(CONFIG_RALINK_RT6855) || defined (CONFIG_RALINK_RT6352)linux-2.6.21.x/include/asm-mips/rt2880/surfboardint.h:#elif defined (CONFIG_RALINK_RT3052) || defined (CONFIG_RALINK_RT3352) || defined (CONFIG_RALINK_RT2883) || defined (CONFIG_RALINK_RT5350) || defined (CONFIG_RALINK_RT6855) || defined (CONFIG_RALINK_RT6352)linux-2.6.21.x/include/asm-mips/rt2880/rt_mmap.h:#elif defined (CONFIG_RALINK_RT6855) || defined (CONFIG_RALINK_RT6352)linux-2.6.36.x/ralink/Kconfig:select RALINK_RT6352linux-2.6.36.x/ralink/Kconfig:select RALINK_RT6352linux-3.10.14.x/ralink/Kconfig:select RALINK_RT6352linux-3.10.14.x/ralink/Kconfig:select RALINK_RT6352vendors/Ralink/MT7621/config/8M_16M_config.linux-2.6.36.x.MT7612-efuse-txbf:# CONFIG_RALINK_RT6352 is not setvendors/Ralink/MT7621/config/8M_64M_config.linux-2.6.36.x:# CONFIG_RALINK_RT6352 is not setvendors/Ralink/MT7621/config/128M_128M_config.linux-2.6.36.x:# CONFIG_RALINK_RT6352 is not setvendors/Ralink/MT7621/config/8M_16M_config.linux-2.6.36.x.MT7612-efuse:# CONFIG_RALINK_RT6352 is not setvendors/Ralink/MT7621/config/8M_16M_config.linux-2.6.36.x.txbf:# CONFIG_RALINK_RT6352 is not setvendors/Ralink/MT7620/config/2M_16M_config.linux-2.6.36.x:CONFIG_RALINK_RT6352=yvendors/Ralink/MT7620/config/8M_64M_config.linux-2.6.36.x:CONFIG_RALINK_RT6352=yvendors/Ralink/MT7620/config/4M_32M_config.linux-2.6.36.x:CONFIG_RALINK_RT6352=yvendors/Ralink/MT7620/config/8M_64M_config.linux-2.6.36.x.MT7530:CONFIG_RALINK_RT6352=y$

Looking for RALINK_RT2860 is even worse:

$ grep -r RALINK_RT2860 *linux-2.6.36.x/ralink/Kconfig:select RALINK_RT2860linux-3.10.14.x/ralink/Kconfig:select RALINK_RT2860$

And this, too:

linux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MAClinux-3.10.14.x/ralink/Kconfig:select RTMP_MACvendors/Ralink/MT7621/config/8M_16M_config.linux-2.6.36.x.MT7612-efuse-txbf:# CONFIG_RTMP_MAC is not setvendors/Ralink/MT7621/config/8M_64M_config.linux-2.6.36.x:# CONFIG_RTMP_MAC is not setvendors/Ralink/MT7621/config/128M_128M_config.linux-2.6.36.x:# CONFIG_RTMP_MAC is not setvendors/Ralink/MT7621/config/8M_16M_config.linux-2.6.36.x.MT7612-efuse:# CONFIG_RTMP_MAC is not setvendors/Ralink/MT7621/config/8M_16M_config.linux-2.6.36.x.txbf:# CONFIG_RTMP_MAC is not setvendors/Ralink/MT7628/config/8M_64M_config.linux-2.6.36.x:# CONFIG_RTMP_MAC is not setvendors/Ralink/MT7628/config/4M_32M_config.linux-2.6.36.x:# CONFIG_RTMP_MAC is not setvendors/Ralink/MT7628/config/2M_8M_config.linux-2.6.36.x:# CONFIG_RTMP_MAC is not setvendors/Ralink/MT7620/config/2M_16M_config.linux-2.6.36.x:CONFIG_RTMP_MAC=yvendors/Ralink/MT7620/config/8M_64M_config.linux-2.6.36.x:CONFIG_RTMP_MAC=yvendors/Ralink/MT7620/config/4M_32M_config.linux-2.6.36.x:CONFIG_RTMP_MAC=yvendors/Ralink/MT7620/config/8M_64M_config.linux-2.6.36.x.MT7530:CONFIG_RTMP_MAC=y

but lots of checking under 2.6.36 kernel under drivers/staging/rt2860.



from http://www.crashcourse.ca/wiki/index.php/OpenWrt_MTK_SDK

1 0
原创粉丝点击