在 ubuntu 中为 ARM 交叉编译 Linux 内核 4.4.2 的问题

在 ubuntu 中为 ARM 交叉编译 Linux 内核 4.4.2 的问题

我按照以下步骤编译 linux 4.4.2 内核和 gcc

verion is gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1) 
ravi@ravi-Inspiron-3537:~/linux$ make ARCH=arm CROSS_COMPLILE=arm-linux-gnueabi- vexpress_defconfig
#
# configuration written to .config
#
ravi@ravi-Inspiron-3537:~/linux$ make ARCH=arm CROSS_COMPLILE=arm-linux-gnueabi- 
scripts/kconfig/conf  --silentoldconfig Kconfig
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CC      kernel/bounds.s
gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’
gcc: note: valid arguments to ‘-mabi=’ are: ms sysv
gcc: error: unrecognized command line option ‘-mlittle-endian’
gcc: error: unrecognized command line option ‘-mno-thumb-interwork’
gcc: error: unrecognized command line option ‘-mfpu=vfp’
make[1]: *** [kernel/bounds.s] Error 1
make: *** [prepare0] Error 2

我该如何解决这个问题?

答案1

您可以在自己的目录中安装 arm 工具链。然后设置一组定义,例如:

    MY_ARM_BASE=${HOME}/dev/toolchain/arm-2008q3
    C_INCLUDE_PATH=${MY_ARM_BASE}/lib/gcc/arm-none-linux-gnueabi/4.3.2/include:${MY_ARM_BASE}/lib/gcc/arm-none-linux-gnueabi/4.3.2/include-fixed
    LIBRARY_PATH=${MY_ARM_BASE}/arm-none-linux-gnueabi/libc/lib:${MY_ARM_BASE}/arm-none-linux-gnueabi/libc/usr/lib
    CPLUS_INCLUDE_PATH=${MY_ARM_BASE}/arm-none-linux-gnueabi/include/c++/4.3.2
    #OBJC_INCLUDE_PATH
    COMPILER_PATH=${MY_ARM_BASE}/bin
    #LD_RUN_PATH
    #GPROF_PATH
    #######
    CC=${COMPILER_PATH}/gccMY_ARM_BASE=${HOME}/dev/toolchain/arm-2008q3 C_INCLUDE_PATH=${MY_ARM_BASE}/lib/gcc/arm-none-linux-gnueabi/4.3.2/include:${MY_ARM_BASE}/lib/gcc/arm-none-linux-gnueabi/4.3.2/include-fixed LIBRARY_PATH=${MY_ARM_BASE}/arm-none-linux-gnueabi/libc/lib:${MY_ARM_BASE}/arm-none-linux-gnueabi/libc/usr/lib CPLUS_INCLUDE_PATH=${MY_ARM_BASE}/arm-none-linux-gnueabi/include/c++/4.3.2
#OBJC_INCLUDE_PATH COMPILER_PATH=${MY_ARM_BASE}/bin
#LD_RUN_PATH
#GPROF_PATH
#######MY_ARM_BASE=${HOME}/dev/toolchain/arm-2008q3 C_INCLUDE_PATH=${MY_ARM_BASE}/lib/gcc/arm-none-linux-gnueabi/4.3.2/include:${MY_ARM_BASE}/lib/gcc/arm-none-linux-gnueabi/4.3.2/include-fixed LIBRARY_PATH=${MY_ARM_BASE}/arm-none-linux-gnueabi/libc/lib:${MY_ARM_BASE}/arm-none-linux-gnueabi/libc/usr/lib CPLUS_INCLUDE_PATH=${MY_ARM_BASE}/arm-none-linux-gnueabi/include/c++/4.3.2
#OBJC_INCLUDE_PATH COMPILER_PATH=${MY_ARM_BASE}/bin
#LD_RUN_PATH
#GPROF_PATH
####### CC=${COMPILER_PATH}/gcc CXX=${COMPILER_PATH}/g++ RANLIB=${COMPILER_PATH}/ranlib STRIP=${COMPILER_PATH}/strip export C_INCLUDE_PATH LIBRARY_PATH CPLUS_INCLUDE_PATH COMPILER_PATH export CC CXX RANLIB STRIP CC=${COMPILER_PATH}/gcc CXX=${COMPILER_PATH}/g++ RANLIB=${COMPILER_PATH}/ranlib STRIP=${COMPILER_PATH}/strip export C_INCLUDE_PATH LIBRARY_PATH CPLUS_INCLUDE_PATH COMPILER_PATH export CC CXX RANLIB STRIP
    CXX=${COMPILER_PATH}/g++
    RANLIB=${COMPILER_PATH}/ranlib
    STRIP=${COMPILER_PATH}/strip
    export C_INCLUDE_PATH LIBRARY_PATH CPLUS_INCLUDE_PATH COMPILER_PATH
    export CC CXX RANLIB STRIP

请注意,该示例不是用于内核编译,只是我为 ARM 编译的一些 Web 服务器,我甚至没有设置所有可能的变量。

相关内容