Startup Code written in C++ for FE310-G002 (HiFive 1 Rev. B)

Hi everyone,

I wanted to share with you a blog post I’ve written about how to write the startup code for the SiFive FE310-G002 processor in easily understandable C++ instead of quite-hard-to-read assembler code.

You can finde the blog post here:

In case you want to investigate the code’s behaviour on real hardware you can do so easily with the Segger Ozone debugging tool. In order to do that please follow the following steps:

#1: Download/Install RISCV64 compiler

sudo wget
sudo tar -xzvf riscv64-unknown-elf-gcc-8.2.0-2019.02.0-x86_64-linux-ubuntu14.tar.gz
export PATH=$PATH:/opt/riscv64-unknown-elf-gcc-8.2.0-2019.02.0-x86_64-linux-ubuntu14/bin

#2: Clone the Snowfox Repository with all examples

git clone --recurse-submodules
cd snowfox

#3 Build the SiFive FE310-G002 LED blink example (the compiled binary is located in build/bin/hal-fe310-digital-out-pin)

.ci/script/ examples/hal/FE310/hal-fe310-digital-out-pin

#4: Download, install, start and configure Segger Ozone

#4a: Select the right device (FE310), Register Set (RV32I) and an optional peripheral file

#4b: Confirm that the HiFive 1 board is connected and the onboard JLink adapter is visible

#4c: Select the binary file for upload/debugging (snowfox/build/bin/hal-fe310-digital-out-pin)

#4d: Download binary via Download & Reset Programm and perform a reset and halt in order to start debugging from the very beginning via Reset & Halt

Kindly let me know any suggestions for improvements or if there is anything I missed :wink:

EDIT: @moderators if you could please remove the constraints of one-picture-per-post for my forum account so that I can add the other screenshots which is something I currently can’t.


This is really awesome! Thanks so much for sharing!

Any plans to expand this for ITIM? (Or, is that an exercise left to the reader? ;D)

I’m guessing that building must be fairly standalone: how much of the build environment did you have to reproduce?

Hi @tincman :wave:
Thank you very much for your kind feedback. Actually there isn’t really any specific reason for my not including support for ITIM loading … probably I just overlooked it during the initial implementation and I didn’t get around to implementing it yet. That being said I’ve added a an issue on the Snowfox repository and will likely get to it in the near future. Is there any specific use case you’d like me to address?