MTK APSOC 5.0.2 Build Process

本文记录了在Ubuntu16.64x64环境下编译MTK_APSoC_SDKV5.0.2的过程及遇到的问题解决方法,包括编译警告、错误修正、依赖库安装等,并分享了U-Boot配置与编译经验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Host gcc version : gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Target gcc version: mipsel-buildroot-linux-uclibc-gcc-4.6.3

下面是在ubuntu 16.64 x64上编译MTK_APSoC_SDK V5.0.2的过程.

Source 编译过程

recipe for target ‘extra/locale/wctables.h’ failed

  GEN extra/locale/lt_defines.h
  HOSTCC extra/locale/gen_wctype
extra/locale/gen_wctype.c: In function 'main':
extra/locale/gen_wctype.c:684:2: warning: #warning fix the upper bound on the upper/lower tables... save 200 bytes or so [-Wcpp]
 #warning fix the upper bound on the upper/lower tables... save 200 bytes or so
  ^
  GEN extra/locale/wctables.h
extra/locale/Makefile.in:179: recipe for target 'extra/locale/wctables.h' failed
make[1]: *** [extra/locale/wctables.h] Error 1
make[1]: Leaving directory '/home/thomas/work/mtk/MTK_APSoC_SDK/source/uClibc-0.9.33.2'
Makefile:892: recipe for target 'uClibc-0.9.33.2_only' failed
make: *** [uClibc-0.9.33.2_only] Error 2

vi ./uClibc-0.9.33.2/Rules.mak

修改编译警告 Wall 为 W


error: ‘__LOCALE_DATA_WCctype_II_LEN’ undeclared here

In file included from extra/locale/gen_ldc.c:45:0:
extra/locale/locale_mmap.h:11:45: error: '__LOCALE_DATA_WCctype_II_LEN' undeclared here (not in a function)
 #define __LOCALE_DATA_WCctype_TBL_LEN      (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
                                             ^
extra/locale/locale_mmap.h:46:32: note: in expansion of macro '__LOCALE_DATA_WCctype_TBL_LEN'
  const unsigned char tblwctype[__LOCALE_DATA_WCctype_TBL_LEN];
                                ^
extra/locale/locale_mmap.h:11:76: error: '__LOCALE_DATA_WCctype_TI_LEN' undeclared here (not in a function)
 #define __LOCALE_DATA_WCctype_TBL_LEN      (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
                                                                            ^
extra/locale/locale_mmap.h:46:32: note: in expansion of macro '__LOCALE_DATA_WCctype_TBL_LEN'

/source/uClibc-0.9.33.2/#  patch -p0 < gen_wctype.patch

Download gen_wctype.patch from http://ftp.osuosl.org/pub/manulix/scripts/build-scripts/PPFILES/ppfiles-uclibc/gen_wctype.patch


Busybox no menuconfig

make[1]: Entering directory '/home/thomas/work/mtk/MTK_APSoC_SDK/source/user/busybox'
Makefile:437: *** mixed implicit and normal rules: deprecated syntax
Makefile:1278: *** mixed implicit and normal rules: deprecated syntax
make[1]: *** No rule to make target 'menuconfig'.  Stop.
make[1]: Leaving directory '/home/thomas/work/mtk/MTK_APSoC_SDK/source/user/busybox'
Makefile:306: recipe for target 'menuconfig' failed
make: *** [menuconfig] Error 2

参见:https://www.cnblogs.com/weidongshan/p/8036182.html

分析原因:
新版Makefile不支持这样的组合目标:config %config(一个有通配符,另一个没有通配符)
 
解决方法:
要么把config %config拆成2个规则,要么把其中一个目标去掉。
 
所以,
a.修改busybox-1.7.0 顶层Makefile 405行:
config%config: scripts_basic outputmakefile FORCE
改为:
%config:scripts_basic outputmakefile FORCE
 
b.修改busybox-1.7.0 顶层Makefile 1242行:
/%/: prepare scripts FORCE
改为:
%/:prepare scripts FORCE

LZMA ERROR 1 When kernel bootup

Bytes transferred = 4302136 (41a538 hex)
NetBootFileXferSize= 0041a538
Automatic boot of image at addr 0x80A00000 ...
## Booting image at 80a00000 ...
   Image Name:   Linux Kernel Image
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    4302072 Bytes =  4.1 MB
   Load Address: 80001000
   Entry Point:  803af3c0
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... LZMA ERROR 1 - must RESET board to recover

The reason is higher verison of lzma is not back compatible.
MTK use an old version of lzma and mksquashfs to compress the kernel and rootfs.


mksquash_lzma-3.2 连接出错

cc   mksquashfs.o read_fs.o sort.o  -L/home/thomas/work/mtk/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_Alone -L/home/thomas/work/mtk/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_C -lpthread -lunlzma_r -llzma_r -lstdc++ -lz -o mksquashfs
/usr/bin/ld: mksquashfs.o: undefined reference to symbol 'log10@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'mksquashfs' failed
make[1]: *** [mksquashfs] Error 1
make[1]: Leaving directory '/home/thomas/work/mtk/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools'
Makefile:28: recipe for target 'all' failed
make: *** [all] Error 

https://blog.youkuaiyun.com/chaehom/article/details/7776047

After build, do not make install, just copy files:

~/work/mtk/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools$ cp mksquashfs /opt/buildroot-gcc463/usr/bin/mksquashfs_lzma-3.2

cp /home/thomas/work/mtk/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_Alone/lzma_alone /opt/buildroot-gcc463/usr/bin/


squashfs4.2 编译错误

thomas@PC3039:~/work/mtk/MTK_APSoC_SDK/toolchain/squashfs4.2/squashfs-tools$ make
cc -O2  -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"xz\" -Wall -DGZIP_SUPPORT -DXZ_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o mksquashfs.o mksquashfs.c
cc -O2  -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"xz\" -Wall -DGZIP_SUPPORT -DXZ_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o read_fs.o read_fs.c
cc -O2  -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"xz\" -Wall -DGZIP_SUPPORT -DXZ_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o sort.o sort.c
cc -O2  -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"xz\" -Wall -DGZIP_SUPPORT -DXZ_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o swap.o swap.c
cc -O2  -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"xz\" -Wall -DGZIP_SUPPORT -DXZ_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o pseudo.o pseudo.c
pseudo.c:69:13: warning: ‘dump_pseudo’ defined but not used [-Wunused-function]
 static void dump_pseudo(struct pseudo *pseudo, char *string)
             ^
cc -O2  -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"xz\" -Wall -DGZIP_SUPPORT -DXZ_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o compressor.o compressor.c
cc -O2  -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"xz\" -Wall -DGZIP_SUPPORT -DXZ_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o gzip_wrapper.o gzip_wrapper.c
cc -O2  -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"xz\" -Wall -DGZIP_SUPPORT -DXZ_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT   -c -o xz_wrapper.o xz_wrapper.c
xz_wrapper.c:28:18: fatal error: lzma.h: No such file or directory
compilation terminated.
<builtin>: recipe for target 'xz_wrapper.o' failed
make: *** [xz_wrapper.o] Error 1

sudo apt-get install liblzma-dev

~/work/mtk/MTK_APSoC_SDK/toolchain/squashfs4.2/squashfs-tools$ cp mksquashfs /opt/buildroot-gcc463/usr/bin/mksquashfs_lzma-4.2


更换lzma 和mksquashfs 工具后,MTK SDK可以正常运行!!

Ethernet 正常工作了, 但是无线部分没有驱动起来, 还有不少后续工作.


UBOOT Build 过程

首先make menuconfig,按照开发板配置如下选择:
在这里插入图片描述

注意:我采用的板子网络需要如下配置:
在这里插入图片描述
然后执行make, 出现了下面一些错误:

/bin/sh: 1: [: Illegal number: 03-64) 2

/opt/mips-2012.03/bin/../lib/gcc/mips-sde-elf/4.6.3/include -pipe  -DCONFIG_MIPS -D__MIPS__ -mabicalls -DRALINK_MDIO_ACCESS_FUN -DRALINK_DUAL_VPE_FUN -EL -mmt -mips32r2 -DRALINK_SPI_UPGRADE_CHECK -DRALINK_RW_RF_REG_FUN -DRALINK_UPGRADE_BY_SERIAL -DRALINK_CMDLINE -DRALINK_EPHY_INIT -DCONFIG_LZMA -DASIC_BOARD -DMT7621_ASIC_BOARD -DMT7621_MP -DMAC_TO_GIGAPHY_MODE_ADDR=0x1e -DMAC_TO_100PHY_MODE -DMT7621_USE_GE1 -DGE_MII_AN -DRALINK_EV_BOARD_PVLAN -DPDMA_NEW -DRX_SCATTER_GATTER_DMA -DUBOOT_ROM -DON_BOARD_DDR3 -DON_BOARD_DDR_WIDTH_16 -DON_BOARD_16BIT_DRAM_BUS -DON_BOARD_2048M_DRAM_COMPONENT -DCFG_ENV_IS_IN_SPI -Wall -Wstrict-prototypes -c -o i2c_drv.o i2c_drv.c
/bin/sh: 1: [: Illegal number: 03-64) 2
i2c_drv.c:1:0: warning: cannot use small-data accesses for '-mabicalls' [enabled by default]
"/opt/mips-2012.03/bin"/mipsel-linux-gcc -gdwarf-2 -DDEBUG -Os   -D__KERNEL__ -DTEXT_BASE=0xBFC00000 -I/home/thomas/work/mtk/MTK_APSoC_SDK/Uboot/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/mips-2012.03/bin/../lib/gcc/mips-sde-elf/4.6.3/include -pipe  -DCONFIG_MIPS -D__MIPS__ -mabicalls -DRALINK_MDIO_ACCESS_FUN -DRALINK_DUAL_VPE_FUN -EL -mmt -mips32r2 -DRALINK_SPI_UPGRADE_CHECK -DRALINK_RW_RF_REG_FUN -DRALINK_UPGRADE_BY_SERIAL -DRALINK_CMDLINE -DRALINK_EPHY_INIT -DCONFIG_LZMA -DASIC_BOARD -DMT7621_ASIC_BOARD -DMT7621_MP -DMAC_TO_GIGAPHY_MODE_ADDR=0x1e -DMAC_TO_100PHY_MODE -DMT7621_USE_GE1 -DGE_MII_AN -DRALINK_EV_BOARD_PVLAN -DPDMA_NEW -DRX_SCATTER_GATTER_DMA -DUBOOT_ROM -DON_BOARD_DDR3 -DON_BOARD_DDR_WIDTH_16 -DON_BOARD_16BIT_DRAM_BUS -DON_BOARD_2048M_DRAM_COMPONENT -DCFG_ENV_IS_IN_SPI -Wall -Wstrict-prototypes -c -o mii_mgr.o mii_mgr.c
/bin/sh: 1: [: Illegal number: 03-64) 2

修改./cpu/ralink_soc/config.mk 中的shell 比较,改成直接赋值:
MIPSFLAGS="-mabicalls"


mt7621_ddr.sh unexpected operator

./mt7621_ddr.sh: 6: [: _2048M: unexpected operator
./mt7621_ddr.sh: 15: [: IN_SPI: unexpected operator

因为ubuntu默认的sh是连接到dash的,dash跟bash的不兼容所以出错了.

    修改sh默认连接到bash, 执行下面的命令,选择NO.

sudo dpkg-reconfigure dash


用tftp 下载uboot.bin并且烧录到spi flash后, 该uboot能运行, 但网络配置不对,不能再使用tftpboot下载.

修改uboot配置 GE1 Connected to : GE_MII_AN --> GE_RGMII_FORCE_1000

使用串口kermit下载烧录后网络功能恢复正常.

Kermit 安装配置

sudo apt-get install ckermit
~/.kermrc

set line /dev/ttyUSB0  
set speed 57600  
set carrier-watch off  
set handshake none  
set flow-control none  
robust
set file type bin  
set file name lit  
set rec pack 1000  
set send pack 1000  
set window 5 

define rz !rz < /dev/ttyUSB0 > /dev/ttyUSB0    
define sz !sz \%0 > /dev/ttyUSB0 < /dev/ttyUSB0

参考:https://blog.youkuaiyun.com/zijie_xiao/article/details/53283963

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值