1

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.

programmer25
  • 375
  • 1
  • 2
  • 14
  • Which version of Ubuntu do you have installed, and was did actually get installed when you did that `apt-get install gcc-arm*`? – domen Aug 26 '20 at 14:57
  • @domen My Ubuntu version is 20.04 LTS and i installed gcc-arm with that command based off a possible solution from [link](https://stackoverflow.com/questions/14180185/gcc-arm-linux-gnueabi-command-not-found) Its not really explicit – programmer25 Aug 26 '20 at 15:07
  • That solution is quite old, and also mentions 32-bit libraries. Is that relevant in your case? And, what was actually installed? Does `arm-linux-gnueabi-gcc` actually exist now (and it's a case of libraries missing) or is now there a compiler with some other name? – domen Aug 26 '20 at 15:11
  • I am not sure if it exist, I am willing to switch compiler versions to get the job done, But then its a matter of the correct syntax in order to do so – programmer25 Aug 26 '20 at 15:18
  • Just installed it yesterday on ubuntu 20.04. – old_timer Aug 26 '20 at 16:04
  • you can install one of the many pre-builts though – old_timer Aug 26 '20 at 17:00
  • Im using a Ubuntu application on a windows 10 machine, im not sure if thats whats causing my issues – programmer25 Aug 26 '20 at 17:31

2 Answers2

3

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.

Frant
  • 5,382
  • 1
  • 16
  • 22
1

A sudo apt update and apt upgrade allowed me to run the command:

sudo apt-get install gcc-arm-linux-gnueabi
programmer25
  • 375
  • 1
  • 2
  • 14
  • Glad to read that. If, and only if, this was my answer above that made you think of the missing `sudo`, you may want to accept it. – Frant Aug 27 '20 at 14:06