I want to compile a Linux kernel from scratch for the arm64 (aarch64) platform, used for booting a Raspberry Pi 4.

The host is amd64 and is running a Debian-variant (Ubuntu 20.04.1 LTS)

I created the following script, that tries to do everything:

###### Build Environment ######

# download and install required packages for host system that will do the compiling
apt install build-essential libgmp-dev libmpfr-dev libmpc-dev libisl-dev libncurses5-dev bc git-core bison flex

# create temporary Build Environment in RAM
mkdir -p ${PREFIX}
umount ${PREFIX} 2>&1 > /dev/null
mount -t tmpfs tmpfs ${PREFIX}

# binutils:
# download binutils from ftp.gnu.org and compile and install it to the host [redacted]
cd obj-binutils
../binutils-${BINUTILSVERSION}/configure --prefix=${PREFIX}/binutils --target=aarch64-linux-gnu --disable-nls
make install

# gcc:
# download gcc from ftp.gnu.org and compile and install it to the host [redacted]
# configure gcc:
../gcc-${GCCVERSION}/configure --prefix=${PREFIX}/gcc --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
# install gcc:
make all-gcc -j${THREADS}
make install-gcc
# test with:
${PREFIX}/gcc/bin/aarch64-linux-gnu-gcc -v
# libgcc optional [skipped]

###### Linux ######

# note that we download from raspberrypi linux git
mkdir -p ${PREFIX}/linux
cd ${PREFIX}/linux
git clone --depth=1 -b ${LINUXBRANCH} https://github.com/raspberrypi/linux.git
mkdir kernel-out

# copy the compiled gcc/binutils binaries to linux /bin directory
cd linux
mkdir bin
mv ${PREFIX}/binutils/bin/* ${PREFIX}/linux/linux/bin/
mv ${PREFIX}/gcc/bin/* ${PREFIX}/linux/linux/bin/

# RPi4 specific configuration
make O=../kernel-out/ ARCH=arm64 CROSS_COMPILE=${PREFIX}/linux/linux/bin/aarch64-linux-gnu- bcm2711_defconfig

# Linux menuconfig
make O=../kernel-out/ ARCH=arm64 CROSS_COMPILE=${PREFIX}/linux/linux/bin/aarch64-linux-gnu- menuconfig

# Linux build
make -j${THREADS} O=../kernel-out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
# note, produced result:
ls -l /tmp/BE/linux/kernel-out/vmlinux
#in my case:
#-rwxr-xr-x 1 root root 26179040 feb 25 22:48 /tmp/BE/linux/kernel-out/vmlinux

# Linux compress vmlinux into bzImage
# note: pwd = /tmp/BE/linux/linux
make bzImage O=../kernel-out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
find ${PREFIX} -iname vmlinuz

But I am currently stuck at the last step, creating the bzImage from the vmlinux. Apparently, you cannot just compress vmlinux into vmlinuz, it needs to be created with make bzImage. But this produces the error:

# reminder: pwd = /tmp/BE/linux/linux
make[1]: Entering directory '/tmp/BE/linux/kernel-out'
make[1]: *** No rule to make target 'bzImage'.  Stop.
make[1]: Leaving directory '/tmp/BE/linux/kernel-out'
make: *** [Makefile:185: __sub-make] Error 2

Any help on the bzImage problem is welcome, but generally my question refers to the overall process of cross compiling a linux kernel for ARM64 platform.

Any advice is welcome on whether I am doing the right thing with GCC and binutils here. I do get some GCC errors here and there. But vmlinux did compile. I would like to test the produced vmlinux first by converting it to a vmlinuz and modifying an existing SD card image from say Ubuntu.

I hope to edit my question so that the script would be useful for other people wanting to compile ARM64 Linux kernel for their RPi4 or other device.

  • 1
    bzImage is the image for an i386 boot floppy, so it does not make any sense to try and build it on ARM.
    – psusi
    Commented Feb 26, 2021 at 19:29

1 Answer 1


Apparently, the correct procedure to compile a Linux kernel is different for each platform:

# on 32-bit x86
make bzImage

# on 64-bit x86
make zImage

# on 64-bit ARM
make Image

# search for compiled linux kernel in current directory
find ./ -iname "*Image"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .