Port MTK SDK to OpenWrt

Source: Internet
Author: User
Tags bool bz2 config crc32

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 ke Rnel 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.

Is explained here, so you had 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 invalid
ralink/kconfig:207:warning: ' Rt_first_card ': Number is invalid
ralink/kconfig:208:warning: ' Rt_first_card ': number is invalid
ralink/kconfig:221:warning: ' Rt_second_card ': number is invalid
ralink/kconfig:222:warning: ' Rt_second_card ': number is invalid
ralink/ Kconfig:223:warning: ' Rt_second_card ': number is invalid
ralink/kconfig:224:warning: ' Rt_second_card ': number is Invalid

Because of config entries that is defined as "int" but has 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 FIRS t_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_mt7603e config Rt_second_card int depends on ! Second_if_none default 3090 If second_if_rt3092 default 5392 if second_if_rt5392 default 5592 if S  econd_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, but it doesn ' t affect us--this produces a successful build. Adding OpenWrt Support

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

..... snip
... Make-c  libnvram
make[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 ' failed
make[1]: * * [_dir_libnvram] Error 2
make[1]: Leaving directory '/home/rpjday/ Flex/mtk_sdk/sdk/rt288x_sdk/source/lib '
makefile:493:recipe for Target ' lib_only ' failed make
: * * * [lib_ Only] Error 2

This seems odd since if you *don ' t* select ' Support OpenWrt ', which library appears to build just fine, so there ' s somethin G 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.o
HEADERS: = Nvram_env.h nvram.h flash_api.h $ (rootdir)/$ (linuxdir)/ Include/linux/autoconf.h

So a early setting of kernel_headers can certainly screw things up.

From a completely fresh checkout of the SDK, we had 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 to 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. config
5c5
< # CONFIG_SUPPORT_OPENWRT is not set
---
> Config_support_ Openwrt=y
31a32
> # Config_rt2880_rootfs_in_flash are not set
42c43
< # Config_boot_raw are not Set
---
> config_boot_raw=y
55d55
< config_boot_elf32=y
604a605
> # config_ Mtd_split is not set
$

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

Make-c  libnvram
make[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 ' failed
make[1]: * * [_dir_libnvram] Error 2
make[1]: Leaving directory '/home/rpjday/ Flex/mtk_sdk/sdk/rt288x_sdk/source/lib '
makefile:493:recipe for Target ' lib_only ' failed make
: * * * [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-OpenWrt support prevents Autoconf.h from being placed in the Kernel_headers directory. Oh, wait, here it's in the kernel source file Include/uapi/linux/kbuild:

Ifndef config_support_openwrt
header-y + = autoconf.h
endif

What's the reason for? 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 would be under INCLUDE/UAP I/and various other uapi/directories.

For now, cheap fix for Include/uapi/linux/kbuild:

# ifndef Config_support_openwrt
header-y + = autoconf.h
# endif

But why is this do in the first place? (Need-to-clean and rebuild-to-take effect.) Ralink/kconfig Wireless Selection

In the 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 is 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 _driver

choice
        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 this config symbol doesn ' t appear to being 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_rt6352 linux-2.6.36.x/ralink/kconfig: Select ralink_rt6352 linux-3.10.14.x/ralink/kconfig:select ralink_rt6352 linux-3.10.14.x/ralink/kconfig:select ralink_rt6352 vendors/ralink/mt7621/config/8m_16m_config.linux-2.6.36.x.mt7612-efuse-txbf:# CONFIG_RALINK_RT6352 is not set vendors/ralink/mt7621/config/8m_64m_config.linux-2.6.36.x:# config_ralink_rt6352 are not set vendors/Ralink/ mt7621/config/128m_128m_config.linux-2.6.36.x:# CONfig_ralink_rt6352 is not set vendors/ralink/mt7621/config/8m_16m_config.linux-2.6.36.x.mt7612-efuse:# CONFIG_RALINK
_rt6352 is not set vendors/ralink/mt7621/config/8m_16m_config.linux-2.6.36.x.txbf:# config_ralink_rt6352 are not set Vendors/ralink/mt7620/config/2m_16m_config.linux-2.6.36.x:config_ralink_rt6352=y vendors/Ralink/MT7620/config/ 8m_64m_config.linux-2.6.36.x:config_ralink_rt6352=y vendors/ralink/mt7620/config/4m_32m_config.linux-2.6.36.x:
 Config_ralink_rt6352=y Vendors/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_rt2860
linux-3.10.14.x/ralink/ Kconfig:	Select ralink_rt2860
$

And this, too:

Linux-3.10.14.x/ralink/kconfig:select Rtmp_mac linux-3.10.14.x/ralink/kconfig:select RTMP_MAC linux-3.10.14.x/	Ralink/kconfig:select Rtmp_mac linux-3.10.14.x/ralink/kconfig:select Rtmp_mac linux-3.10.14.x/ralink/kconfig:
Select Rtmp_mac linux-3.10.14.x/ralink/kconfig:select rtmp_mac linux-3.10.14.x/ralink/kconfig:select RTMP_MAC Linux-3.10.14.x/ralink/kconfig:select Rtmp_mac linux-3.10.14.x/ralink/kconfig:select RTMP_MAC linux-3.10.14.x/	Ralink/kconfig:select Rtmp_mac linux-3.10.14.x/ralink/kconfig:select Rtmp_mac linux-3.10.14.x/ralink/kconfig: Select Rtmp_mac linux-3.10.14.x/ralink/kconfig:select rtmp_mac vendors/ralink/mt7621/config/8m_16m_ config.linux-2.6.36.x.mt7612-efuse-txbf:# Config_rtmp_mac is not set vendors/ralink/mt7621/config/8m_64m_ config.linux-2.6.36.x:# Config_rtmp_mac is not set vendors/ralink/mt7621/config/128m_128m_config.linux-2.6.36.x:# Config_rtmp_mac is not set vendors/ralink/mt7621/config/8m_16m_config.linux-2.6.36.x.mt7612-efuse:# CONFIG_RTMP_MAC is noT set vendors/ralink/mt7621/config/8m_16m_config.linux-2.6.36.x.txbf:# Config_rtmp_mac is not set vendors/Ralink/ mt7628/config/8m_64m_config.linux-2.6.36.x:# Config_rtmp_mac is not set vendors/ralink/mt7628/config/4m_32m_ config.linux-2.6.36.x:# Config_rtmp_mac is not set vendors/ralink/mt7628/config/2m_8m_config.linux-2.6.36.x:# CONFIG _rtmp_mac is not set vendors/ralink/mt7620/config/2m_16m_config.linux-2.6.36.x:config_rtmp_mac=y vendors/Ralink/ Mt7620/config/8m_64m_config.linux-2.6.36.x:config_rtmp_mac=y vendors/ralink/mt7620/config/4m_32m_ Config.linux-2.6.36.x:config_rtmp_mac=y Vendors/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


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.