ARM Beaglebone黑色的交叉编译器错误

问题描述:

我正在尝试从运行Ubuntu的桌面交叉编译beaglebone black:

I am trying to cross compile for a beaglebone black from a desktop running Ubuntu:

Linux DESKTOP-4UIP5QG 4.4.0-18362-Microsoft #836-Microsoft Mon May 05 16:04:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux

目标机器是长骨黑色:

Linux beaglebone 4.19.94-ti-r42 #1buster SMP PREEMPT Tue Mar 31 19:38:29 UTC 2020 armv7l GNU/Linux

我目前正在关注可以帮助我完成此操作的教程,但我似乎找不到他们正在使用的编译器版本:

I am currently following a tutorial that will help me do this but i cant seem to find the compiler version that they are using: https://www.itdev.co.uk/blog/building-linux-kernel-cross-compiling-beaglebone-black

我尝试通过以下方式安装编译器:

i have tried to install the compiler with:

sudo apt-get install gcc-arm-linux-gnueabi

但是我收到错误:

E: Unable to locate package gcc-arm-linux-gnueabi

所以我然后尝试用以下方式安装gcc-arm编译器

So i then tried to install a gcc-arm compiler with

sudo apt-get install gcc-arm*

,但在安装此程序并尝试使用以下代码进行编译后:

but after install this and attempting to compile with:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- bb.org_defconfig

我收到此错误:

/bin/sh: 1: arm-linux-gnueabi-gcc: not found
init/Kconfig:17: syntax error
init/Kconfig:16: invalid option
./scripts/clang-version.sh: 15: arm-linux-gnueabi-gcc: not found
./scripts/gcc-plugin.sh: 11: arm-linux-gnueabi-gcc: not found 
make[1]: *** [scripts/kconfig/Makefile:104: bb.org_defconfig] Error 1
make: *** [Makefile:534: bb.org_defconfig] Error 2 

任何帮助将不胜感激,谢谢.

Any help will be appreciated, thank you.

指向您要使用的确切工具链的更具确定性的方法是在设置CROSS_COMPILE时提供其完整前缀.这样可以避免可能的与路径相关的错误,并且将用于构建的确切工具链的信息嵌入到您的构建脚本中.

A more deterministic way of pointing to the exact toolchain you want to use is to provide its full prefix when setting CROSS_COMPILE. This will avoid possible path-related errors, and the information on which exact toolchain was used for building will be embedded in your build script.

完整示例-安装官方Arm gcc 9.2.0工具链并检索/构建beaglebone black的u-boot 20.04(使用您自己的u-boot和defconfig):

Full example - installing official Arm gcc 9.2.0 toolchain and retrieving/building u-boot 20.04 for the beaglebone black (use your own u-boot and defconfig):

# gcc 9.2.0
mkdir -p /opt/arm/9
wget 'https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi.tar.xz?revision=64186c5d-b471-4c97-a8f5-b1b300d6594a&la=en&hash=5E9204DA5AF0B055B5B0F50C53E185FAA10FF625'
tar Jxf gcc-arm-9.2-2019.12-x86_64-arm-none-eabi.tar.xz -C /opt/arm/9

# u-boot
wget https://github.com/u-boot/u-boot/archive/v2020.04.tar.gz
tar zxf v2020.04.tar.gz
cd u-boot-2020.04
make CROSS_COMPILE=/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/arm-none-eabi- ARCH=arm mrproper am335x_evm_defconfig all

以上命令应在本机x86_64 Linux,在Windows上的VMWare或VirtualBox下运行的x86_64 Linux以及在Windows 64位系统上的WS1/WSL2 Windows Linux子系统上运行.

The commands above should work on a native x86_64 Linux, an x86_64 Linux running under VMWare or VirtualBox on Windows, and WSl/WSL2 Windows Linux Subsystems on a Windows 64 bit system.

这就是说,如果您要调查特定问题,请确认安装了哪个工具链:

This being said, if you want to investigate your specific issue, you verify which toolchain you installed:

sudo dpkg --get-selections | grep gcc-arm
gcc-arm-linux-gnueabihf                         install

如果没有输出,则可能未安装您认为已安装的产品.您可以使用apt-cache search:

If there are not outputs, you may not have installed what you think you installed. You can search what are the packages available on your system using apt-cache search:

sudo apt-cache search gcc-arm-linux
gcc-arm-linux-gnueabihf - GNU C compiler for the armhf architecture
gcc-arm-linux-gnueabi - GNU C compiler for the armel architecture

安装软件包:

sudo apt-get install arm-linux-gnueabihf

验证编译器是否存在:

which arm-linux-gnueabihf-gcc
/usr/bin/arm-linux-gnueabihf-gcc

但是,我建议坚持使用Arm或Linaro工具链,而不要使用发行版.

I would however recommend to stick with an Arm or Linaro toolchain rather than a distro-delivered one.