Linux kernel build step

What’s this all about?

Most of the support for RISCV specific development has taken place on very new versions of Linux. A fully generic kernel is hard to achieve given all the possible scenarios where RISCV could be used. Nevertheless certain helperss are assumed to be always available which simplify matters:

  1. The Kernel entry address is 0x80200000
  2. Berkeley boot loader (BBL) handles the initial console output using it’s SBI interface
  3. A device tree blob (DTB) is passed to Linux to enable it to decide which devices to enable. This blob is analogous to the BIOS settings in a traditional PC.

In addition an initial root filing system is needed to allow site specific configuration. This initial filesystem is responsible for loading the real rootfs, which might be on SD card or NFS.

The initial boot environment will interrogate the FPGA switch settings to decide how to boot:

FPGA Switch:15..1211..87..43..0
Don’t boot0000
GDB boot00?1
SD boot0010
DHCP boot0100
SD root0000
NFS root0001
Custom root001?
Reserved01??
Reserved1???
Reserved????
MAC LSB????

The LSB of the switches determines the boot address and should always be off unless GDB is in use. The SD boot and DHCP boot switches are interpreted by the boot loader to determine whether to check for an SD-Card presence or not. The SD root and NFS root options are determined by Linux using the /dev/gpio0 device, which also controls the LEDs. The decision making code is in debian-riscv64/work/busyboxinit.sh and is interpreted as an ash shell script. If a custom option is chosen the DOS partition the card will be mounted to search for further customisations (such as an address of a server to search for).

You should already have prepared a cpio archive in the Debian directory. If not, visit here first:

or generate directly with this command:

make -C ../debian-riscv64 cpio

or copy from the quickstart binary release:

wget https://github.com/lowRISC/lowrisc-chip/releases/download/v0.6-rc3/initramfs.cpio

Configuring and building the Linux kernel (independent of the device tree blob)

cd $TOP/riscv-linux
make ARCH=riscv defconfig
make ARCH=riscv -j 4 CROSS_COMPILE=riscv64-unknown-linux-gnu- CONFIG_INITRAMFS_SOURCE="initramfs.cpio"

The next recommended step is: