RIOT RTOS Port for HiFive1

I wanted to test my coding chops and enable the RIOT RTOS on the SiFive RISC-V HiFive1 board. Now I’d like to share my project and get some feedback from others that may be working on RISC-V implementations. I’m a Windows guy, so all the instructions below are geared towards developing on a Windows PC, but I’m pretty sure the port will comile under a Ubuntu system. I’m curious as to what you all think. By the way, kudos to SiFive for making the Freedom Studio tools. They definitely made it very easy to get up a running with the HiFive1 board.

RISC-V port fork:

Tools Used on Windows 10:

Freedom Studio v20170616 (beta2) -

GNU MCU Eclipse -
RISC-V Embedded GCC v7.1.1-2-20170912

MinGW & MSYS -

Putty -

Setup Steps on Windows 10:

  1. Install Freedom Studio per instructions for Windows. Import the example projects for HiFive1
  2. Install HiFive1_Driver.exe under \FreedomStudio\SiFive\Misc
  3. Follow steps for compiling RIOT under Windows
  4. In addition to the Mintty mingw-get install steps, add the following: mingw-get install msys-mktemp
  5. Copy RISC-V Embedded GCC to \riscvgcc folder somewhere on PC
  6. Add to Windows system environment Path env var full dir to riscvgcc\bin folder
  7. Clone RIOT RISC-V fork respository to \RIOT folder
  8. Open mintty window, cd to /RIOT/examples/default
  9. Build application: make BOARD=hifive1
  10. Setup Putty with implicit CR after LF and configure with the USB COM port per Freedom Studio instructions

Flashing and Debugging RIOT:

I liked using the Freedom Studio IDE for flashing and debugging RIOT. Also, I used the GCC and OpenOCD tool versions that come with Freedom Studio as they seemed to have been built with an XML lib that the GNU MCU versions did not, which causes download issues (seems to be related to the “cannot parse XML memory map” issue that has been discussed in the SiFive forums). I do compile RIOT with the newer compiler because it has support for the newlib_nano libraries which are smaller. So, compile with the newer GCC but flash and debug with the Freedom Studio GCC and OpenOCD tool versions.

  1. Add RIOT source tree to Freedom Studio via File->New->Makefile Project with Existing Code
  2. Make project name RIOT and give path to \RIOT folder; select the RISC-V Cross GCC toolchain for the indexer
  3. Under Run->Debug Configurations, duplicate one of the HiFive1 debugging configurations like led_fade Debug, name the config RIOT Debug
  4. Edit the RIOT Debug configuration:

Main tab: set the project to RIOT and the C/C++ app to be the full path to the RIOT app .elf file (C:\RIOT\examples\default\bin\hifive1\default.elf) Select “Disable auto build” because builds of RIOT can only be done from the Mintty shell

Debugger tab: tge OpenOCD Config option will need a full path to the HiFive1 cfg file (eg. -f C:\FreedomStudio\SiFive\Misc\sifive-freedom-e300-hifive1.cfg)

Startup tab: For Load Symbols and Load Executable, set the Use file option and give the full path to the application .elf file. Set breakpoint at: _start (the entry point to the .elf file in start.S)

  1. Apply the configuration, then press Debug. The .elf file will be flashed to the HiFive1 board and Freedom Studio will kick into the GDB debugger just like any of the other example projects that ship with Freedom Studio

  2. To debug other RIOT applications, update the full paths to the app’s .elf file in the RIOT Debug configuration

Features Supported:

Base RIOT core OS
FE310 CPU package
Interrupt routing via PLIC driver
Bypass clock setting via PRCI driver
Peripherals: Timer, UART, GPIO, RTT/RTC, CPUID
HiFive1 board package
Stdin/Stdout routed to UART1
Tested with RIOT Examples Default, Hello-World, IPC_pingpong, Timer_periodic_wakeup and various RIOT tests apps

Feature WIP:

PMW, SPI peripheral support
Configuration of other CPU clock speeds
Determine why the newer GNU MCU OpenOCD won’t work
Finish RIOT support of commandline flash and debug scripts
Pull request into the main RIOT repository to have offical support of RISC-V


Very cool! Would you consider adding (or would you mind if we add) this to our Freedom E Projects Wiki? (

Superb! There were a few people talking about doing a port on the riot-devel mailing list back in June who I’m sure would be very interested to see your progress.

Yes, feel free to add the info to the Wiki.

I also port a rtos to hifive1, url is here:

1 Like

I’ve been slowly working on a RIOT port too and just noticed your post. I was the one mentioned on the riot-devel mailing list back in June but we never got funding so it’s been a back-burner project that never even started until recently. What’s the current status of your port? It looks like the only recent changes in github are merges.

I’ll try your repository out. Offhand thread_arch_start_threading looks suspect but I’ll have to look more carefully. I’ve been developing using Eclipse CDT with the GNU MCU plugin on Fedora 26 without problems.

It looks like your port is further along than mine - I’m definitely interested in collaborating.

I’d be happy to collaborate on the port. I’ve mainly been merging in the latest RIOT changes just to make sure nothing breaks. I think the port is pretty solid, but would like to have feedback on it. The only strangeness is the mix of tools I use. You definitely need the newer compiler to get the newlib-nano support, but the older OpenOCD that comes with Freedom Studio to download and debug. I haven’t gotten the newer OpenOCD to work (the XML memory map issue). I build RIOT from the commandline, but download and debug completely in Freedom Studio. I ran most of the examples and low level test apps for RIOT and they all worked. I have a start on the PWM driver but have not done anything with the SPI driver yet. Please let me know what you think.

Just an update on the RIOT port to support the HiFive1 - the PR was accepted and now the RIOT RTOS officially supports RISC-V, the FE310 CPU and the HiFive1 board

More info on the RIOT wiki:


Great news, Thanks!