tree: 201d2d7f20d87d9de36a2da9f9937da86855ca8e [path history] [tgz]
  1. config_busybox_rv64_092021

title: LupV Booloader/Kernel and Disk image tags: - lupio - riscv - fullsystem layout: default permalink: resources/lupv shortdoc: > Sources for the LupV bootloader/kernel and disk image. author: [“Joël Porquet-Lupine”]

This README will cover how to create a bootloader/kernel, and a disk image which may be used to run LupV (LupIO with RISC-V) in gem5.

An example script which uses these resources is provided here:


Install a 64-bit RISCV toolchain:


The software stack is composed of two parts: the bootloader (riscv-pk) and the kernel (linux). They are combined together in a single file.

Linux kernel

First compile the linux kernel.

$ git clone
$ cd linux
$ git checkout lupio-dev-v5.8
$ make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- lupv_defconfig
$ make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -j8


  • Adapt CROSS_COMPILE to your toolchain's prefix
  • Adapt -j8 to the number of parallel jobs you want to run

The resulting kernel image is in arch/riscv/boot/Image.


Now, compile the bootloader and include the linux image into the bootloader's payload.

$ git clone
$ cd riscv-pk
$ mkdir build && cd build
$ ../configure --host=riscv64-linux-gnu --with-payload=/path/to/linux/arch/riscv/boot/Image
$ make

The resulting firmware which includes the bootloader and the kernel, and can be loaded as a kernel image in gem5, is in build/bbl.

<<<<<<< HEAD A pre-built bootloader/kernel binary can be obtained from here.

A pre-built bootloader/kernel binary can be obtained from here.


Root filesystem

The root filesystem is based on busybox. First, we need to compile busybox for RISC-V, and then we need to create a complete directory tree structure.

Note that you need root access in order to create the root filesystem.


Copy config_busybox_rv64_092021 file to your computer and compile busybox using this configuration.

$ git clone
$ cd busybox
$ mv /path/to/config_busybox_rv64_092021 .config
$ make -j8

The resulting busybox binary is ./busybox.

Rootfs image

Finally, create an entire ext2-formatted filesystem that is based on busybox.

First, populate the contents of this filesystem:

$ mkdir -p rootfs/contents && cd rootfs/contents
$ mkdir -p bin etc dev lib proc sbin sys tmp usr usr/bin usr/lib usr/sbin
$ cp </path/to/busybox>/busybox bin/busybox
$ ln -s bin/busybox sbin/init
$ ln -s bin/busybox init
$ cat << EOF > etc/inittab
# Mount special filesystems
::sysinit:/bin/busybox mount -t proc proc /proc
::sysinit:/bin/busybox mount -t tmpfs tmpfs /tmp
# Remount root partition in RW
::sysinit:/bin/busybox mount -o remount,rw /
# Install all of the BusyBox applets
::sysinit:/bin/busybox --install -s
# Run shell directly
$ sudo mknod dev/console c 5 1
$ cd ..

Then, create an image:

$ qemu-img create rootfs.img 2M
$ echo ";" | sfdisk rootfs.img
$ sudo kpartx -a rootfs.img
$ sudo mkfs -t ext2 /dev/mapper/loop0p1
$ mkdir -p mountfs
$ sudo mount /dev/mapper/loop0p1 mountfs
$ sudo cp -a contents/* mountfs
$ sudo chown -R root:root mountfs
$ sudo umount mountfs
$ rm -rf mountfs
$ sudo kpartx -d rootfs.img

The resulting filesystem image, which can be loaded as a partition image in gem5, is rootfs.img.

<<<<<<< HEAD A pre-built, gzipped, image can be obtained here.

A pre-built, gzipped, image can be obtained here.