How sycuricon/riscv-spike-sdk works
Main Components
• Toolchain: The “repo/riscv-gnu-toolchain” directory holds the GNU compiler toolchain. This component is fundamental for compiling Linux, test programs, and possibly newlib.
• Linux Kernel: Found in “repo/linux” with configuration files (e.g., work/linux_defconfig). This kernel is compiled by the toolchain and deployed as the system.
• Root Filesystem/Buildroot: “repo/buildroot” is used to build the initramfs/rootfs. Also note that configuration for Buildroot is provided in “conf/buildroot_initramfs_config”.
• Bootloader: The README outlines the option to use either BBL or OpenSBI (repo/opensbi) as the bootloader for launching the simulation.
• Simulator: Spike itself is the simulator that ultimately runs the compiled Linux environment. This involves not only the simulator binary (from “repo/riscv-isa-sim” and possibly “repo/riscv-pk”) but also configuration files like “conf/boot.log” and “conf/spike.cfg”.
• Debug Support: The “conf/starship.cfg” alongside references to OpenOCD and JTAG debugging reflect external debugging support, particularly for an FPGA or similar hardware interface.
Interactions and Flow
• Build Process Coordination: The Makefile and quickstart.sh script, along with configuration files in the “conf” folder, orchestrate the building of the toolchain, rootfs, Linux kernel, and bootloader.
• Compilation Workflow: The toolchain builds all software components while referencing appropriate headers from the Linux kernel (as noted in the README regarding toolchain dynamic linking and kernel headers).
• Boot Process: Once built, the bootloader (either BBL or OpenSBI) initiates system startup, which then loads the Linux kernel, which in turn mounts the Buildroot-generated rootfs into memory.
• Simulation & Debug: Spike simulates the hardware. In parallel, there is an optional JTAG/debug interface configured via OpenOCD (using “conf/starship.cfg”) to debug through a physical interface connected to an FPGA development board.
Architectural Patterns and Design Principles
• Modular Design: The project is structured to allow independent development and testing of individual components (kernel, toolchain, bootloader, rootfs), similar to a microservices approach but applied to system development.
• Configurability: The heavy emphasis on configuration files (in “conf”) and menuconfig-based reconfiguration (for both Buildroot and Linux) underlines a design geared toward adaptability.
• Clear Separation of Concerns: Each repository directory clearly encapsulates a major subsystem and the supporting configuration enhances clarity.