Build the Bootloader and RAM Disk


Before starting

Create the working directories:

$ install -d ~/project/khadas/ubuntu/{linux,rootfs,archives/{ubuntu-base,debs,hwpacks},images,scripts}
$ cd ~/project/khadas/ubuntu/

Clone the utils repository to fetch the tools for development:

$ git clone

Build U-Boot:

Download the U-Boot source tree, take a notice of the branch ubuntu as the option when you run git clone:

$ git clone -b ubuntu

Build for Khadas VIM:

$ cd u-boot/
$ make kvim_defconfig
$ make -j8 CROSS_COMPILE=aarch64-linux-gnu-

Generated files:

Now, you can move to next step, or in some cases below, you might want to create a bootable SD card based on the newly built bootloader:

Build Linux kernel

Download the Linux kernel source tree, take a notice of the branch ubuntu as the option when you type git clone:

$ git clone -b ubuntu

Build for Khadas VIM:

$ cd linux
$ make ARCH=arm64 kvim_defconfig
$ make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image kvim.dtb modules

Generated files:

Build Initramfs and RAM Disk

Download the source tree and build:

$ git clone
$ make -C initrd

Generated files:

Run mkbootimg to generate the ramdisk image:

$ ./utils/mkbootimg --kernel linux/arch/arm64/boot/Image --ramdisk images/initrd.img -o images/boot.img

Well, you are almost done, and the output file images/boot.img is the final ramdisk you needed.

And now you can follow one of the instructions below to build the rootfs:

Or if you want to prove the images above are right built, please continue to read the following instruction.

Flash the images [Optional]

Note that all the following commands prefixed as kvim# are executed on your target device using a serial module.

And you might need to boot from a bootable SD if your target device doesn't have a bootloader installed on it yet.

Upgrade the new built bootloader into eMMC storage via TFTP (Ensure done the right setup first):

kvim# tftp 1080000 u-boot.bin
kvim# store rom_write 1080000 0 100000

After this, you can remove the bootable SD card from your target device, and reboot from the eMMC.

Download the DTB blob into eMMC:

kvim# tftp 1080000 kvim.dtb
kvim# store dtb write 1080000

Load the Ramfs blob into memory and boot from the memory:

kvim# tftp 1080000 boot.img
kvim# bootm

If everything goes well, the printing should be like this when you hit enter after boom command:

ee_gate_off ...
## Booting Android Image at 0x01080000 ...
load dtb from 0x1000000 ......
   Loading Kernel Image(COMP_NONE) ... OK
   kernel loaded at 0x01080000, end = 0x01ef6be8
   Loading Ramdisk to 73a7d000, end 73ebe47e ... OK
   Loading Device Tree to 000000001fff3000, end 000000001ffff0bd ... OK

Starting kernel ...

uboot time: 58429787 us
domain-0 init dvfs: 4
[    0.000000@0] Initializing cgroup subsys cpu
[    0.000000@0] Initializing cgroup subsys cpuacct
[    0.000000@0] Linux version 3.14.29 (gouwa@Server) (gcc version 4.8.4 (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) ) #25 SMP PREEMPT Sun Jan 1 15:57:33 CST 2017
[    0.000000@0] CPU: AArch64 Processor [410fd034] revision 4

The printing says that your bootloader can load Linux kernel Image now.