linux kernel - trying to cross compile on ubuntu (for rpi zero)

[fresh virtual box vm, using ubuntu 20.04, all updates made during install]

I just try to run make bcmrpi_defconfig on a linux kernel git repository

patched for RT :

wget
zcat patch-4.19.127-rt55.patch.gz | patch -p1

but it say it cannot find the arm compiler...

phil@rt-linux-pi:~/linux$ /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
bash: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian
/bin/arm-linux-gnueabihf-gcc: No such file or directory
phil@rt-linux-pi:~/linux$ ls /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc -lha
lrwxrwxrwx 1 phil phil 29 Jun 25 22:58 /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc -> arm-linux-gnueabihf-gcc-4.8.3

I now realize arm-linux-gnueabihf-gcc is nowhere to be found on the system

I get this error :

make bcmrpi_defconfig
/bin/sh: 1: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
/bin/sh: 1: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 26: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 27: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 29: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 26: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 27: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 29: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
init/Kconfig:17: syntax error
init/Kconfig:16: invalid option
./scripts/clang-version.sh: 15: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-plugin.sh: 11: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
make[1]: *** [scripts/kconfig/Makefile:104: bcmrpi_defconfig] Error 1
make: *** [Makefile:534: bcmrpi_defconfig] Error 2

I tried :

  • installing build essentials

  • I installed these packages : libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf

  • I moded the PATH variable :

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/

thanks for the time you'll spend on this question

regards

I follow this tutorial :

6

1 Answer

the official doc explains things a bit better and in a more "recent way" of doing things

first mod and source .bashrc file and add at the end :

if [ -d "$HOME/tools/arm-bcm2708/arm-linux-gnueabihf/bin" ] ; then PATH="$PATH:$HOME/tools/arm-bcm2708/arm-linux-gnueabihf/bin"
fi

to build kernel do :

sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev
git clone --depth=1 --branch rpi-4.19.y
cd linux
export KERNEL=kernel
make bcmrpi_defconfig
cd ..
git clone ~/tools
cd linux
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcmrpi_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

hope this helps someone else too

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like