Bare metal programming on the RED-V Thing Plus board (SiFive RISC-V FE310 SoC).
This repository implements an entirely manually-written, pure bare metal Blinky Project for the SiFive RISC-V FE310 SoC (on the RED-V Thing Plus board).
Features include:
- CPU, power, chip, clock and PLL initialization,
- timebase derived from
mtimer
, - blinky LED show with adjustable frequency,
- implementation in C99 with absolute minimal use of assembly.
Clear and easy-to-understand build systems based on either GNUmake or CMake complete this fun and educational project.
This repository provides keen insight on starting up a bare metal SiFive RISC-V controller. It emphasizes simplicity and independence from monolithic toolchains through its lightweight, self-written implementation.
The application boots from a tiny startup code in the boot ROM.
Following low-level chip initialization, the program jumps to
the main()
subroutine. Here the timer interrupt is setup
for LED blinky.
The adjustable LED-phase (its half-period) can be tuned
to provide a rudimentary, visible blinky LED show.
The timebase for blinky is based on the mtimer
interrupt handler.
Blinky running on the target is shown in the image below.
Build on *nix*
is easy using gcc-riscv32-unknown-elf
Both Make and Cmake can be used to build the Application:
cd RED-V_SiFive_RISC-V_FE310_SoC
./Rebuild.sh
mkdir Output && cd Output
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-unix.cmake .. && make
The build results including ELF-file, HEX-mask, MAP-file
and assembly list file are created in the Output
directory.
If gcc-riscv32-unknown-elf
is not installed, it can easily
be obtained from embecosm.
Add the path of the RISC-V GCC tools' bin folder to $PATH
in the usual *nix
way.
CI runs on pushes and pull-requests with simple
build(s) including result verification on ubuntu-latest
and macos-latest
using GitHub Actions.
- The source and build code written for this repo is licensed under The Unlicense.
- Also the system-register file
riscv-csr.h
, originally from five-embedded, is licenced under The Unlicense.