Booting Linux with U-BOOT
Reading Time: 3 minutes
The basic idea is to be able to create a system, much like we’ve one on which we’re developing, and put this system on a media which can be booted.
Since we use a Computer on a daily basis we know somethings that must be present in this new system we would like to build
These are some of the basic things we need to do in order to make this new system work, however depending what you would like to build it for, viz, a router or say a streaming device you might want to add or remove some of the features to this basic list.
We might want to go with some general purpose distribution viz OpenSuSE or Ubuntu however since we want to understand the fundamentals here we’ll just use BusyBox.
The following steps can be done in order to achieve this sytem
This one is pretty straight forward. Since we’ll be using Arm 64 bit virtual machine we’ll use that configuration. The following commands show how this can be done
#The following command needs to be run from
#u-boot directory
~/u-boot> ARCH=arm64 CROSS_COMPILE=aarch64-none-elf-gnu- \
make qemu_arm64_defconfig
~/u-boot> ARCH=arm64 CROSS_COMPILE=aarch64-none-elf-gnu- \
make -j16
Once the above command is complete we’ll have a file named u-boot
~/u-boot> file u-boot
u-boot: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), statically linked, with debug_info, not stripped
We’ll use the same tool chain used to compile U-Boot for compiling Linux kernel. Since we want to run this on QEMU virtual machine therefore we need to select that machine only as shown below
~/kernel_source/linux> ARCH=arm64 \
CROSS_COMPILE=aarch64-none-elf-gnu- make menuconfig
We need to select ARM Software Emulation machine which can be done by selecting the following option
As shown in the above image we need to select ARMv8 software model. Note that the CPU supported is Cortex-A57 for this machine.
Since BusyBox is an application program it needs supports from the kernel, and thus needs to be build from the none-linux toolchain instead of none-elf tool
busybox> ARCH=arm64 CROSS_COMPILE=aarch64 \
-none-linux-gnu- make menuconfig
We’ve two choices here, to either statically link everything or dynamically link all applets (commands). For this tutorial we’ll go with the dynamically link option to show the extra steps which need to be done in order to run these programs. This can be done on the Settings option of menuconfig.
Once this Step is done then we’ve created everything we require to make this thing work. All that’s needed now is to package it. We’ll see that in the next post.