Reputation: 405
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
The target machine is a beaglebone black:
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
but i receive the error:
E: Unable to locate package gcc-arm-linux-gnueabi
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
I get this error:
/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.
Upvotes: 1
Views: 2888
Reputation: 405
A sudo apt update
and apt upgrade
allowed me to run the command:
sudo apt-get install gcc-arm-linux-gnueabi
Upvotes: 1
Reputation: 5895
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.
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
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
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
Install the package:
sudo apt-get install arm-linux-gnueabihf
Verify the compiler is there:
which arm-linux-gnueabihf-gcc
/usr/bin/arm-linux-gnueabihf-gcc
I would however recommend to stick with an Arm or Linaro toolchain rather than a distro-delivered one.
Upvotes: 3