NZD | USD

How to Get Started with RISC-V-Based Microcontrollers

By Jacob Beningo

Contributed By Digi-Key's North American Editors

Designers are under constant pressure to innovate yet keep their intellectual property (IP) secret, while also lowering power consumption and cost. This made the RISC-V open-source hardware instruction set architecture (ISA) interesting for designers of processors for mobile applications. Now that RISC-V is an option for microcontrollers, designers of embedded systems and consumer devices need a quick on-ramp to start their own RISC-V designs.

One such on-ramp is the FE310 LoFive-R1 development board from GroupGets LLC. Before introducing the LoFive-R1, this article will discuss RISC-V and why a developer may want to consider using it. It will then describe the LoFive-R1 and show how to get started developing applications, including some tips and tricks.

What is RISC-V?

RISC-V is an open-source hardware instruction set architecture project that began at the University of California Berkeley in 2010. There were many reasons for creating the RISC-V architecture, including:

  • Meeting the need for an open-source instruction set architecture (ISA) that could be used academically in university projects and by students
  • A means to share design expertise in developing ISAs
  • A way to avoid paying royalties to incumbent chip companies and so save on cost
  • To guard the design details of an architecture (a company’s IP) in order to remain commercially viable

From a designer’s point of view, RISC-V is a simplified architecture that is designed for speed and low-power operation. This makes RISC-V-based chips good for commercial applications, not just academia. In fact, the RISC-V Foundation has drawn enough interest to grow to approximately 325 members, including companies such as Si-Five, Google, Microchip Technology, NVIDIA, and Qualcomm.

While there are many companies that are contributing to RISC-V development, for the average developer, the best way to get hands-on with RISC-V is to find a development board based on a RISC-V processor.

The LoFive FE310 development board

One such development board is the LoFive-R1 development board from GroupGets LLC (Figure 1).

Image of GroupGets LoFive-R1 development boardFigure 1: The LoFive-R1 development board includes a RISC-V processor along with all the necessary support circuitry to make the development board a processor module that can be directly soldered to a carrier board. (Image source: GroupGets LLC)

First, the LoFive R1 includes a RISC-V processor that can run at up to 320 megahertz (MHz). The processor includes 8 kilobytes (Kbytes) of one-time-programmable (OTP) memory, 8 Kbytes of mask ROM, 16 Kbytes of instruction cache, and 16 Kbytes of SRAM. The processor also has three independent pulse width modulation (PWM) controllers, SPI, I2C, UART, and even a QSPI flash interface.

Second, the development board can either have headers soldered to it, or due to the castellated edges, the development board can be directly soldered onto a carrier board and used as a processor module. This can make it extremely easy for a developer to design custom hardware without having to work through the logistics of sourcing the processor.

Next, the development board includes on-board QSPI flash that is provided through an IS25LP128 flash module from Integrated Silicon Solution Inc. (ISSI). The IS25LP128 is a 128 megabit (Mbit), 16 Mbyte flash module that can operate at SPI bus speeds up to 133 MHz when used in quad input/output mode (Figure 2). The SPI flash module can be used for storage to ensure that there is plenty of application space, or to store run-time data such as application logs.

Diagram of ISSI 128 Mbit SPI flash moduleFigure 2: The LoFive-R1 development board includes an ISSI 128 Mbit SPI flash module that is used for application storage. (Image source: ISSI)

Next, the development board will also run on 5 volts which is converted to 3.3 volts by an SPX3819M5 linear regulator from MaxLinear. The regulator comes in a SOT23-5 package but provides up to 500 mA. The development board will not draw much current so it can support additional sensors and devices without having to add additional power circuitry.

Diagram of MaxLinear SPX3819 3.3 volt linear regulatorFigure 3: The SPX3819 3.3 volt linear regulator on the LoFive-R1 development board provides up to 500 mA. This is sufficient for both the on-board circuits as well as some external devices, such as sensors. (Image source: MaxLinear)

Finally, all the design details for the development board such as the schematics and bill-of-materials are located on github. This information makes it easier for a developer to understand how the board works and can also be used as a design guide for custom development projects.

Setting up the RISC-V toolchain and programming development board

A developer will find that there are multiple toolchains that are available for RISC-V depending on the development board that has been chosen. It’s important to realize that the SDK for RISC-V is available for Windows, macOS and Linux. This article will show how to set up the development board for Linux.

First, in a terminal, check out the LoFive Freedom-E SDK from git using the following command:

git clone --recursive https://github.com/mwelling/freedom-e-sdk.git

Next, move into the directory created by the SDK using:

cd freedom-e-sdk

There are two different SDKs that are available for the development board. The first is referred to as “the legacy SDK” because it is an older version. Use the latest SDK. This has a prebuilt toolchain and includes OpenOCD for debugging. The SDK can be checked out using the following commands:

git checkout lofive-r1

git submodule sync

git submodule update –init –recursive

Programming of the development board can be done in several different ways. First, there are standard JTAG signals on the processor which are available through the LoFive-R1 expansion connectors. A developer can use any programmer that supports JTAG, such as a SEGGER J-Link. If a programmer is not available, a developer can also use a low cost USB-to-serial converter like the FT2232H-56Q Mini MDL from FTDI (Figure 4). The FT2232H-56Q Mini MDL is a module that hosts all the connections and breakouts that are required to interface to the LoFive-R1 development board. The SDK uses the general purpose I/O available on the FT2232H-56Q to create the necessary JTAG connections to program the microcontroller.

Image of FTDI FT2232H-56Q MINI MDL serial moduleFigure 4: The FT2232H-56Q MINI MDL is a low-cost serial module that can be directly interfaced to a computer through USB and then to the UART on-board the LoFive-R1 development board. (Image source: FTDI)

There are nine different connections that need to be made between the LoFive-R1 development board and the FT2232H-56Q module (Table 1).

LoFive-R1 Dev Board Pin FT2232H-56Q Module Pin
+5 VIN VBS
Ground GND
TRSTN AD5
TCK AD0
TDO AD2
TMS AD3
TDI AD1
UART0.TX BD1
UART0.RX BD0

Table 1: A simple table that can be used to bridge the connections between the LoFive-R1 development board and the FT2232H-56Q module. (Table source: Digi-Key Electronics)

These connections can be summed up as:

  • Power and ground
  • JTAG signals
  • UART signals

The connections could be made directly, or they could be done using a breadboard like the PB-83M from Global Specialties (Figure 5). These breadboards feature banana plugs for two voltage sources and ground to simplify prototyping.

Image of Global Specialties PB-83M breadboard with banana jacks

Figure 5: The PB-83M provides banana jacks for two voltage sources and ground to make  prototyping easier. (Image source: Global Specialties)

When using the LoFive-R1 for the first time, it is advisable to install a bootloader on-board. The bootloader is installed once and can be used to facilitate further upgrades. The bootloader can be made from the SDK by executing the following command:

make PROGRAM=lofive-boot TARGET=lofive-r1-bootloader upload

The “hello world” application can then be loaded onto the development board using the following command:

make PROGRAM=sifive-welcome TARGET=lofive-r1 upload

At that point, a developer will have programmed their first RISC-V application, and the possibilities of where to go from here are limitless.

Tips and tricks for working with RISC-V

Getting started with RISC-V processors is a little bit different than standard microcontroller ecosystems.  Here are a few “tips and tricks”:

  • After checking out the LoFive-R1 SDK, take the time to review the README.md file in the main directory. It has useful information about where to find the SDK documentation, board support packages and other useful information.
  • If a professional debug probe like a SEGGER J-Link is available, use it to program applications to the RISC-V processor. J-Link has been supporting RISC-V since 2017.
  • For developers that prefer to use an IDE rather than command line tools, consider using the Freedom Studio for RISC-V development which is an Eclipse-based IDE.

Developers that follow these “tips and tricks” will find that they save quite a bit of time and grief when working with RISC-V for the first time.

Conclusion

RISC-V is an interesting architecture that may be a fit for developers who are looking to use an open-source hardware architecture. Development boards currently exist for RISC-V processors and as seen in this article, setting up the toolchains is not much more difficult than any other standard microcontroller.

Don’t forget that while RISC-V is intriguing, it doesn’t have the rich ecosystem that many existing microcontroller platforms enjoy, so developers that choose to go down the RISC-V path may find they have fewer choices and resources to leverage along their journey. That trade-off may well be worth it, depending on the end application and the developer’s preferences and resources.

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of Digi-Key Electronics or official policies of Digi-Key Electronics.

About this author

Jacob Beningo

Jacob Beningo is an embedded software consultant. He has published more than 200 articles on embedded software development techniques, is a sought-after speaker and technical trainer, and holds three degrees, including a Masters of Engineering from the University of Michigan.

About this publisher

Digi-Key's North American Editors