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:
- The Kernel entry address is 0x80200000
- Berkeley boot loader (BBL) handles the initial console output using it’s SBI interface
- 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:
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:
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: