Skip to content

Kernel Build Prerequisites

Kevin Doren edited this page Feb 5, 2022 · 2 revisions

32-bit kernel build prerequisites

sudo apt-get install flex bison libncurses-dev libssl-dev

64-bit kernel build prerequisites (to cross compile 64-bit kernel on 32-bit system)

Thanks to this link: https://www.tal.org/tutorials/raspberry-pi3-build-64-bit-kernel

sudo apt-get install build-essential libgmp-dev libmpfr-dev libmpc-dev libisl-dev libncurses5-dev bc git-core bison flex texinfo

Create and enter an appropriate work directory:

mkdir tools
cd tools

Download/build/install binutils and 64-bit cross compiler

wget https://ftp.gnu.org/gnu/binutils/binutils-2.34.tar.bz2
tar xf binutils-2.34.tar.bz2
mkdir binutils-obj
cd binutils-obj
../binutils-2.34/configure --prefix=/opt/aarch64 --target=aarch64-linux-gnu --disable-nls
make -j4
sudo make install
cd ..

export PATH=$PATH:/opt/aarch64/bin/
wget https://ftp.gnu.org/gnu/gcc/gcc-8.4.0/gcc-8.4.0.tar.xz
tar xf gcc-8.4.0.tar.xz
mkdir gcc-out
cd gcc-out
../gcc-8.4.0/configure --prefix=/opt/aarch64 --target=aarch64-linux-gnu --with-newlib --without-headers  --disable-nls --disable-shared --disable-threads --disable-libssp --disable-decimal-float  --disable-libquadmath --disable-libvtv --disable-libgomp --disable-libatomic  --enable-languages=c
make all-gcc -j4
sudo make install-gcc
# check correct operation
/opt/aarch64/bin/aarch64-linux-gnu-gcc -v

# optional build & install aarch64 libgcc (needed if building i.e. u-boot)
make all-target-libgcc
sudo make install-target-libgcc