RISC-V: A Baremetal Introduction using C++. Development Environment


  • -nostartfiles is used as this example includes a custom startup routine,
  • -std=c++17 for all the needed modern C++ features, and
  • -fno-threadsafe-statics to prevent threadsafe code from being emitted (we have no threads and these ensure static declarations are initialized only once).
build_flags = 

Adding a Post Compile Action

extra_scripts = post_build.py
targets = disasm
def after_build(source, target, env): 
""" Run objdump on the target elf file and save the
output in the top dir.
cmd=" ".join([
objdump, "-SC","--file-start-context", "-w",
src_elf,">","${PROGNAME}.disasm"]) #
title="Disasm 2",
description="Generate a disassembly file on demand",

Other C++ Development Environments

  • SiFive, like most processor vendors, has a GCC and Eclipse-based IDE, the Freedom Studio.
  • For a vendor-independent path GNU MCU Eclipse supports RISC-V compilation and debugging very well. I have personally used this to target proprietary RISC-V cores and simulators with success.

Other RISC-V Devices

  • Professionally my experience has been with IQonIC Works RISC-V IP. They provide a small RV32EC core targeted at deeply embedded applications, where stripped-down bare-metal programming is essential.
  • Many open-source options.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Phil Mulholland

Phil Mulholland

Experienced in Distributed Systems, Event-Driven Systems, Firmware for SoC/MCU, Systems Simulation, Network Monitoring and Analysis, Automated Testing and RTL.