“RISC-V: A Baremetal Introduction using C++. Intro.

RISC-V?

RISC-V has been getting a lot of publicity as a new ISA that’s taking on the entrenched players such as ARM and x86–64. Realistically, RISC-V won’t be displacing ARM in the standard platforms of the embedded or mobile space or replacing x86–64 on the desktop or server space anytime soon.

Bare-metal?

Bare-metal programming for RISC-V machine mode is the target of these posts. That is, there is no operating system, everything we do will interact directly with the hardware.

  • Verification and bring up of processor cores and peripherals.
  • Porting and debugging RTOSes for new processors, SoCs.
  • Deeply embedded firmware for USB-PD/USB Type-C and power conversion.
  • Debugging embedded Linux boot-up and drivers.
Ee Ja Nai Ka? FujiQ Highlands.
Bare-metal, not for everyday programming.

Modern C++?

The evolution of C++ has unleashed a modern low overhead language. While far more complex than C, the traditional language of embedded systems, modern C++ can achieve a higher-level abstraction of programming, with less cost in terms of memory usage and instruction count. In this post, I’m targeting C++17 but will look to C++20 in later posts.

  • About RISC-V, bare-metal programming, and C++.
  • What does a pure C++ application look like for embedded RISC-V?
  • Compiling, debugging, flashing to the RISC-V target.
  • What target platform and toolchains are used for this exercise?
  • How do RISC-V processors exit reset and set up the stack and global environment?
  • How can we use the C++ algorithms library to simplify startup?
  • What do we need RISC-V system registers for? How can we access them?
  • Can C++ hide the complexity of using special instructions?
  • What does the standard RISC-V timer look like?
  • How can we abstract timing using std::chrono in C++? Can C++ access MMIO registers?
  • What is the basic interrupt model or RISC-V?
  • What is a C++ lambda function? Can they handle interrupts in C++?

The Next Step.

Please read on to the next post to find out more.

--

--

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.