Skip to main content

RISC-V Toolchain

The Future of Embedded Software Development?

Alex Pluemer for Mouser Electronics

 

Image Source: Pixel B/Shutterstock.com

 

RISC-V is still a relatively new element in the world of embedded system design, but it’s already being widely adopted to replace existing custom architectures and develop new systems. The flexibility of an open-source structure provides developers with the opportunity to adapt RISC-V functionality to their design’s particular needs while still benefiting from the surrounding standardized ecosystem.  Reviewing the design tools and development environments available for RISC-V implementations is a helpful way to track its progress in the competitive world of embedded computing.     

 

Starting a Project

 

RISC-V’s novelty does not play a role in its rate of adoption. Instead, the popularity of an open source environment is dramatically accelerating its evolution. Expansion is already accelerating in the areas of RTOS support, libraries and middleware for networking, graphics, artificial intelligence (AI), the Internet of Things (IoT), security, and digital signal processing.  Many of these components are freely available to developers and can be found grouped together under a single user interface to ease the development process.  This article will take you through the process and describe the tools an engineer uses to create an embedded computing application. Engineers employ a variety of software development tools and mechanisms to create an embedded computing application. The RISC-V development environment provides extensive tools for chip development and for higher-end applications with full-featured operating system implementations (like Linux), but this article will only touch on these briefly to focus on software development.

 

Tapping into GNU

 

GNU is a mass collaborative free software development project with the goal of providing a user with all the software needed to run a computer. This includes not only the operating system (like the popular Linux operating system) but all the software elements needed to develop and run applications- like development environments, editors, compilers, libraries and applications.  The GNU Compiler Collection (GCC) is a compiler system that supports a variety of programming languages ─ it is produced by the GNU Project and is distributed by the Free Software Foundation. GCC is the official compiler of the GNU operating system and most Linux distributions, hence it is widely used and has proven to be an important element in many modern IDEs.

 

Integrated Development Environments

 

Figure 1: Integrated Development Environment for RISC-V Development. (Source: Mouser)

 

An integrated development environment (IDE) is designed to be a one-stop shop for software development. Figure 1 illustrates the key components and tool flow a developer is likely to encounter in a typical IDE. IDEs make the development process simpler by providing a range of components and functionality within a single user interface rather than requiring a developer to be proficient with a variety of unconnected tools. The Eclipse IDE is a widely-used development “cockpit” for embedded system development -- it provides a user-friendly workspace that contains all the important development functions. The Eclipse SDK is free and open source, making it a popular IDE for a wide range of languages and target microcontrollers like ARM and RISC-V. The Eclipse CDT (C/C++ Development Tooling) project provides a complete IDE based on the Eclipse platform and includes a family of standard plug-ins and tools for multi-platform embedded ARM & RISC-V development (and is available from the Eclipse foundation).

A developer would typically create a project using the project manager, which provides the developer a way to specify the key project attributes such as the targeted MCU, board, included libraries and middleware; it then creates the project’s initial folders, source files, configuration settings and other housekeeping functions.  The last step before getting into the code is configuring and initializing the project.   

 

Editors

 

Once the project is initialized, the developer can use the editor to create the code needed for the applications. Modern editors can simplify code creation by providing shortcuts that can autocomplete variables, enumerations, API function calls and even add driver stacks. Editors that flag potential compiler errors are also helpful in eliminating simple code errors. User manual information can be called up within the code context or via “smart hover” actions by using the cursor to minimize the need to manually search additional documents for API definitions or operational details.

 

Libraries and Middleware

 

Once the code is added, comprehensive libraries and middleware support allow the developer to employ the associated high-level APIs instead of creating them from scratch. Graphic user interfaces, digital signal processing, networking and security libraries and middleware are just a few examples of APIs which, when available, can significantly accelerate development time.

Glibc is the GNU C library that provides the core libraries for the GNU and GNU/Linux systems. It includes C implementations for a range of functions including file systems, cryptography, pipes and FIFOs, mathematics, input/output streams, searching and sorting, and virtual memory, among others.  Newlib is a C standard library, available under free software license, and is targeted for embedded systems. As such it includes more “lightweight” implementations than Glib, which is targeted for a more operating system-based environment. Newlib provides common functions such as serial input/output, file system access, memory management, arithmetic, search, and conversion. It uses an embedded system board support package to access MCU peripherals and other hardware-specific elements.

 

Real-time Operating System (RTOS)

 

RTOS support can be a critical factor for developers in connecting individual threads of the application using robust elements like semaphores, queues, messages and mutexes. An RTOS is often the only way to quickly and safely develop complex applications that have real-time response requirements -- as well as serial communication, a user interface, graphics, sensors and security─ key elements in most modern Internet of Things (IoT) applications.

 

Compilers and Debuggers

 

When the API functions have been implemented, the code is ready to be compiled. The compiler is often considered the operational heart of the IDE -- it converts the editor-created developer's code into RISC-V targeted native assembler instructions. Advanced compilers have a variety of settings that allow generated code to be optimized at various levels to trade-off performance and code size. Due to its simplified instruction set, the RISC-V architecture lends itself to simple optimization algorithms which minimize the need for the complex algorithms required to make sense of complex instruction sequences, instruction interactions and the impact of program branches and function calls. RISC-V’s reliance on uniform memory operations (in lieu of local CPU registers) further simplifies optimization. When memory-based operations are combined with efficient memory caching, optimization can often be done “on the fly” ─ i.e. during execution instead of during compilation.

Once code development is underway, the time spent testing and debugging the application grows. Most modern debuggers provide detailed analysis and tracing of program execution to make it easier to track variables, stacks and buffers. Real-time visual updates of variables are also useful to pinpoint issues that can be illusive with typical static breakpoint and single-stepping analysis. Some debuggers also integrate power measurement along with detailed timing analysis ─ a combination particularly useful when testing and analyzing low-power requirements that are ubiquitous in IoT applications. Developers should make sure the debugger they select provides a wide range of features that help identify bugs and tests their application thru several different “lenses” ─ ones that fit with their testing and debugging requirements.

The GNU Debugger (GDB), part of the GNU open source project, is an open source program to help debug code. It provides both the debug “engine” for a wide range of ISDs (familiar to many experienced embedded system developers) and features for tracing and changing the execution of code within the IDE. The user can track and change the value of program variables and call routines outside of a program’s usual behavior to pinpoint errors.  The open on-chip debugger (OpenOCD) project provides a free GPL-licensed interface used to connect remote debuggers to the on-chip debug hardware found on modern MCUs. OpenOCD can work in conjunction with GDB to provide debugging support for RISC-V MCUs.

 

Finding the Right Tools for Your Implementation

 

There are many other third-party tools available beyond the ones described here, each coming with their own strengths and weaknesses.  A traditional embedded system tool chain (provided by the device manufacturer) includes compilers, editors, debuggers, libraries, drivers, middleware, and real-time operating system (RTOS) support. MCU manufacturer-provided tool chain support can vary widely with respect to the robustness and completeness of libraries, drivers, middleware, documentation, development kits, example projects and other similar support resources. Often manufacturers have target applications and markets that prioritize their offerings, so it is useful to explore competitive products to see how well they match with a specific development effort. One of the most important elements to evaluate in detail is the availability of manufacturer drivers for the peripherals included on a RISC-V MCU. Since peripherals are not yet standardized for RISC-V, manufacturers provide drivers for serial communications, timers, graphics controllers, cryptographic accelerators, and networking interfaces. These drivers provide the APIs for controlling key aspects of any embedded application, so the more complete and easy-to-use they are, the more efficient development will be.

There are several other IDEs, RTOSs, compilers, debuggers, and libraries available for RISC-V software development currently on the market, each boasting its own set of key features and capabilities.  Determining which tools will best fit your development needs depends on the specifics of your project. Most IDEs offer cross-platform capability (Windows, MacOS, Linux) and support for 32- and 64-bit cores while promising to reduce code-size and enhanced debugging efficiency, and a few are even free to use for educational or evaluation purposes without any restrictions or limitations.

 

Conclusion

 

RISC-V architecture could be a game changer in the realm of embedded computing.  Its no-cost licensing, open source development environment along with an engaged and growing development community has the potential to enable the rapid development and expansion of a standardized embedded-computing platform. An open-source platform that developers can freely refine and enhance over time can contribute to the dramatic acceleration of pace at which embedded systems and the IoT provide new capabilities for our connected world.  It seems like only a matter of time before RISC-V and its development ecosystem take a leading role in the world of embedded system design.

 

About the Author

Alex is a senior technical writer for Wavefront Marketing specializing in advanced electronics, emerging technologies and responsible technology development.

Profile Photo of Alex Pluemer