cvw/linux
2024-07-24 20:19:30 -07:00
..
buildroot-config-src Added fortran compiler to buildroot for spec benchmarks. 2024-04-11 13:58:13 -05:00
buildroot-packages Fixed the sdc linux bug which preventing loading the driver. The irq lock was not correctly initalized. 2023-08-25 17:01:38 -05:00
devicetree Updated riscv,isa-extensions property with the correct syntax. Added riscv,cbom-block-size. 2024-07-12 09:28:54 -05:00
sdcard Remove hardcoded /opt/riscv 2024-07-23 23:29:45 -07:00
testvector-generation Update buildroot makefile to test for write access to $RISCV and remove separate sudo/no_sudo versions (just run the makefile as sudo if needed) 2024-07-24 20:19:30 -07:00
bootmem.txt disassembleBootTrace works on first 50M lines of boot 2023-11-22 22:17:01 -08:00
Makefile Update buildroot makefile to test for write access to $RISCV and remove separate sudo/no_sudo versions (just run the makefile as sudo if needed) 2024-07-24 20:19:30 -07:00
README.MD Updated README to explain usage of flash-sd.sh 2023-08-23 10:22:55 -05:00

Linux for core-v-wally

Table of Contents

  1. Setting up Buildroot
  2. Generating Device Tree Binaries
  3. Disassembling the Binaries for Debugging
  4. Creating a Bootable SD Card

Setting up Buildroot

In order to generate the Linux and boot stage binaries compatible with Wally, Buildroot is used for cross-compilation. To set up a Buildroot directory, configuration files for Buildroot, Linux, and Busybox must be copied into the correct locations inside the main Buildroot directory. This can be done automatically using the Makefile inside Wally's Linux subdirectory (this one). To install and patch a fresh Buildroot directory, type:

$ make install BUILDROOT=path/to/buildroot

You can override the BUILDROOT variable to place buildroot where you want it. By default it will be placed at /opt/riscv/buildroot. In addition to copying the configuration files, it will install the buildroot package needed to build the SD card driver for Linux.

To install a new buildroot directory, build the binaries, and generate the device tree binaries in one command, use:

$ make BUILDROOT=path/to/buildroot

Or simply use the default buildroot location in /opt/riscv:

$ make

Note that the $RISCV variable cannot be set prior to building in buildroot or the build will fail. It is best to run source ./setup.sh to alter your $PATH and set the $RISCV variable after buildroot has succesfully built the binaries. If you're new to buildroot, you can find the binaries in <BUILDROOT>/output/images.

Generating Device Tree Binaries

The device tree files for the various FPGA's Wally supports, as well as QEMU's device tree for the virt machine, are located in the ./devicetree subdirectory. These device tree files are necessary for the boot process. In order to build the device tree binaries (.dtb) from the device tree sources (.dts), we can build all of them at once using:

$ make generate BUILDROOT=path/to/buildroot

Or for the default buildroot location:

$ make generate 

The .dts files will end up in the <BUILDROOT>/output/images folder of your chosen buildroot directory.

Disassembling the Binaries for Debugging

By using the riscv64-unknown-elf-objdump utility, we can disassemble the binaries in <BUILDROOT>/output/images so that we can explore the resulting machine code instructions and see what assembly or C code the instructions came from, along with the corresponding addresses. This is useful during debugging in order to trace how code is being executed.

To create the disassembled binaries, run:

$ make disassemble BUILDROOT=path/to/buildroot

You'll find the resulting disassembled files in <BUILDROOT>/output/images/disassembly.

Creating a Bootable SD Card

To flash a bootable sd card for Wally's bootloader, use the flash-sd.sh script located in <WALLY>/linux/sdcard. The script allows you to specify which buildroot directory you would like to use and to specify the device tree. By default it is set up for the default location of buildroot in /opt/riscv and uses the vcu108 device tree. To use the script with your own buildroot directory and device tree, type:

$ cd sdcard
$ ./flash-sd.sh -b <path/to/buildroot> -d <device tree name> <DEVICE>

for example

$ ./flash-sd.sh -b ~/repos/buildroot -d wally-vcu118.dtb /dev/sdb