|
RISC-V Architecture Getting Started: From Principles to Your First Dev Board

RISC-V Architecture Getting Started: From Principles to Your First Dev Board

Introduction

Over the past two decades, the processor architecture market has been essentially split between two players: Intel’s x86 dominates PCs and servers, while ARM rules mobile and IoT. Want to design your own chip? Sorry — you’ll need to pay a rather expensive licensing fee first.

RISC-V changed all that.

RISC-V is a completely open-source instruction set architecture (ISA). Anyone can freely use it to design, manufacture, and sell chips or RISC-V-based products without paying licensing fees to any company. It was initiated by Professor Krste Asanović and his team at the University of California, Berkeley in 2010, and has since become one of the hottest new forces in the chip industry.

In this article, I’ll start from the basic concepts of instruction sets, help you understand what makes RISC-V different, and then guide you through picking a development board and running your first RISC-V program.

1. What Is an Instruction Set Architecture (ISA)?

1.1 The Simplest Explanation

An instruction set architecture is essentially the “contract” between the CPU and software — it defines:

  • What basic operations the CPU can perform (addition, subtraction, loading data, jumping, etc.)

  • How many registers there are and how wide each one is

  • How memory is addressed

  • The encoding format of instructions

You can think of it as the CPU’s “language specification.” Software writes instructions in this language, and the CPU understands and executes them.

1.2 x86 vs ARM vs RISC-V

x86ARMRISC-V
DeveloperIntel/AMDArm Ltd.RISC-V Foundation (open source)
LicensingProprietaryPaid licensingCompletely free and open source
Instruction typeCISC (Complex Instruction Set)RISC (Reduced Instruction Set)RISC (Reduced Instruction Set)
Primary domainPC/ServerMobile/EmbeddedIoT/Embedded/AI/All domains
ExtensibilityNot extensibleLimited extensibilityHighly extensible

RISC-V’s killer feature comes down to two words: freedom.

You don’t need anyone’s permission to use the RISC-V ISA. You can customize instruction set extensions based on your needs. You can design a minimalist 32-bit MCU, or an AI accelerator with vector extensions — all legal, all free.

1.3 Why the “V”?

V stands for “five” (Roman numeral). The Berkeley team had already designed four generations of RISC processors (ROCK I–IV), so the fifth generation was named RISC-V. The V also hints at “Variable,” since the RISC-V instruction set is extensible.

2. Core Features of the RISC-V Architecture

2.1 Reduced Instruction Set (RISC)

RISC-V follows the RISC philosophy:

  • Fixed 32-bit instruction length (base ISA) — simple decoding, clean hardware design

  • Load/Store architecture — only load and store instructions can access memory; arithmetic operations can only be performed between registers

  • Plenty of registers — 32 general-purpose integer registers (x0–x31), double the 16 in x86

This design makes hardware implementations simpler and power consumption lower, making it ideal for embedded scenarios.

2.2 Modular Design

RISC-V isn’t “one instruction set for all scenarios” — it’s composed of modular extensions:

ExtensionNameDescription
RV32I / RV64IBase integer ISAMandatory; included in all RISC-V processors
MMultiply/Divide extensionHardware multiplication and division instructions
AAtomic operations extensionAtomic instructions for multi-core synchronization
FSingle-precision floating pointHardware single-precision floating-point operations
DDouble-precision floating pointHardware double-precision floating-point operations
CCompressed instructions16-bit encoded compressed instructions to reduce code size
VVector extensionSIMD vector operations, suitable for AI/multimedia

Typical combination examples:

  • Minimal IoT node: RV32I + C (minimum code size)

  • General-purpose MCU: RV32IMAC (with multiply/divide, atomics, compression)

  • Application processor: RV64IMAFDC (64-bit + full featured)

  • AI accelerator: RV64IMAFDCV (plus vector extension)

2.3 Privilege Levels

RISC-V defines three privilege levels:

LevelNamePurpose
U modeUserRunning user applications
S modeSupervisorRunning the OS kernel
M modeMachineFirmware/Bootloader, highest privilege

MCUs typically only need M mode; SoCs running Linux need M+S+U.

3. The Current RISC-V Ecosystem

3.1 Chip Vendors

RISC-V is no longer just an academic project — major vendors are shipping production chips:

VendorRepresentative ProductsPositioning
T-Head (Alibaba)C906/C910/C920High-performance application processors
GigaDeviceGD32VMCU, Arduino compatible
EspressifESP32-C3WiFi/BLE IoT
WCHCH32VLow-cost MCU
SiFiveE/P/U seriesGeneral-purpose RISC-V IP
Andes TechnologyRISC-V IPIoT/automotive electronics

3.2 Operating System Support

  • Linux: Merged into the mainline kernel in 2019 (5.0+), fully supported

  • FreeRTOS: Officially supported

  • Zephyr: Officially supported

  • RT-Thread: Officially supported

  • Bare-metal: Various bare-metal SDKs available

Dev BoardChipPriceUse Case
Sipeed Longan NanoGD32VF103¥30–50Beginner learning, includes LCD
ESP32-C3ESP32-C3¥15–25IoT development, WiFi+BLE
Milk-V DuoCV1800B¥50–80Linux application processor
StarFive VisionFive 2JH7110¥500–700Full Linux SBC
HiFive1 Rev BFE310-G002¥300+Officially recommended beginner board

Beginner recommendation: ESP32-C3 or Sipeed Longan Nano — affordable, well-documented, and easy to get started with.

4. Hands-On: Running Your First Program on a RISC-V Dev Board

4.1 Hardware Preparation

We’ll use the ESP32-C3 as an example — it features a RISC-V single-core processor, supports WiFi and BLE 5.0, and costs less than ¥20.

You’ll need:

  • ESP32-C3 development board (e.g., ESP32-C3-DevKitM-1)

  • USB-C data cable

  • Computer (Windows/Mac/Linux all work)

4.2 Setting Up the Development Environment

Option 1: Arduino IDE (Simplest)

  1. Download and install Arduino IDE 2.x (from the official site arduino.cc)

  2. Open Arduino IDE, go to “File → Preferences → Additional Board Manager URLs” and add the ESP32 URL: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

  3. In “Tools → Board → Board Manager,” search for “esp32” and install the latest ESP32 board support package

  4. Connect the ESP32-C3 board to your computer with the USB-C cable, and select the corresponding serial port under “Tools → Port”

  5. Select “ESP32C3 Dev Module” under “Tools → Board,” then click the Upload button

// ESP32-C3 Blink example
void setup() {
  pinMode(8, OUTPUT);
  Serial.begin(115200);
  Serial.println("Hello from RISC-V!");
}

void loop() {
  digitalWrite(8, HIGH);
  delay(500);
  digitalWrite(8, LOW);
  delay(500);
}

That’s it — you’re now running code on a RISC-V processor.

Option 2: ESP-IDF (Official SDK, More Flexible)

If you need lower-level control, use Espressif’s official SDK:

# 1. Install ESP-IDF toolchain
git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
./install.sh esp32c3  # Specify RISC-V chip

# 2. Set up environment
. ./export.sh

# 3. Create project
idf.py create-project my_riscv_app
cd my_riscv_app

# 4. Edit main/main.c
# 5. Build (note: this compiles RISC-V target code)
idf.py set-target esp32c3
idf.py build

# 6. Flash
idf.py -p /dev/ttyUSB0 flash monitor

4.3 Option 3: Bare-Metal Development (Pure RISC-V Learning)

If you want to understand RISC-V from the very bottom, try pure bare-metal development:

# Install RISC-V GCC toolchain
# Ubuntu/Debian:
sudo apt install gcc-riscv64-unknown-elf gdb-riscv64-unknown-elf

# Or use pre-built binaries:
wget https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/latest/download/xpack-riscv-none-elf-gcc-linux-x64.tar.gz
tar xzf xpack-riscv-none-elf-gcc-linux-x64.tar.gz

Write a minimal assembly program:

# hello.S - Print characters to serial port on RISC-V
.section .text
.globl _start

_start:
    # Set stack pointer
    la sp, _stack_top

    # Print "Hello RISC-V!"
    la a0, hello_msg
    jal uart_puts

    # Halt
1:  j 1b

.section .rodata
hello_msg:
    .string "Hello RISC-V!\n"

Compile:

riscv64-unknown-elf-gcc -march=rv32imac -mabi=ilp32 -nostdlib hello.S -o hello.elf

This is the smallest program you can run on bare RISC-V hardware.

5. Understanding RISC-V Instructions in Depth

5.1 Basic Instructions (RV32I)

Master these core instructions and you’ll understand how RISC-V works at a basic level:

InstructionFormatExampleDescription
addird, rs1, immaddi x1, x0, 10x1 = x0 + 10 = 10
addrd, rs1, rs2add x2, x1, x1x2 = x1 + x1 = 20
lwrd, offset(rs1)lw x3, 0(x4)Load from memory
swrs2, offset(rs1)sw x3, 0(x4)Store to memory
beqrs1, rs2, labelbeq x1, x2, equalBranch if equal
jalrd, labeljal ra, my_funcJump and link

5.2 A Complete Small Program

// A RISC-V program written in C — the compiler generates corresponding RISC-V assembly
int fibonacci(int n) {
    if (n <= 1) return n;
    return fibonacci(n - 1) + fibonacci(n - 2);
}

The compiler-generated RISC-V assembly looks like this:

fibonacci:
    addi sp, sp, -32
    sw ra, 28(sp)
    sw s0, 24(sp)
    addi s0, sp, 32
    sw a0, -20(s0)
    lw a5, -20(s0)
    li a4, 1
    bgt a5, a4, .L2    # if n > 1, skip return

    lw a5, -20(s0)
    mv a0, a5               # return n
    j .L3

.L2:
    lw a5, -20(s0)
    addi a5, a5, -1
    mv a0, a5
    jal fibonacci           # fibonacci(n-1)

    mv a5, a0
    lw a4, -20(s0)
    addi a4, a4, -2
    mv a0, a4
    jal fibonacci           # fibonacci(n-2)

    add a0, a5, a0          # result = fib(n-1) + fib(n-2)

.L3:
    lw ra, 28(sp)
    lw s0, 24(sp)
    addi sp, sp, 32
    jr ra

Although it looks complex, RISC-V assembly is very clean — each instruction does one thing, without the “one instruction does three things” magic you find in x86. This is the RISC philosophy reflected at the code level.

6. RISC-V vs Traditional Architectures: Embedded Scenario Comparison

6.1 Power Consumption

ArchitectureTypical Standby CurrentTypical Active CurrentSuitable for Battery Apps
RISC-V (ESP32-C3)~10μA~50mA✅ Excellent
ARM Cortex-M (STM32)~5μA~30mA✅ Excellent
x86 (Atom)~1mA~500mA❌ Not suitable

RISC-V and ARM are evenly matched in low-power scenarios. RISC-V’s advantage lies in having no licensing fees, enabling mass production without increasing costs.

6.2 Performance

MetricRISC-V (C906)ARM Cortex-A53Notes
Dhrystone DMIPS/MHz~2.8~2.0RISC-V slightly better
Clock frequencyUp to 2GHzUp to 1.5GHzDepends on chip implementation
Multi-core supportBoth support it

Important note: RISC-V is just an ISA — actual performance depends on the chip implementation. The same RISC-V ISA can yield vastly different performance between T-Head’s C906 and a simple MCU — just like the same x86 ISA, an i9 and a Celeron are not in the same league.

6.3 Development Ecosystem

RISC-VARM
Compiler supportGCC/Clang mainlineGCC/Clang mainline
RTOS supportFull FreeRTOS/Zephyr supportFull support
Linux supportMainline kernel 5.0+Mature
IDE supportPlatformIO/VSCode/CLionKeil/IAR/STM32CubeIDE
Community tutorialsGrowing (more Chinese resources)Very extensive
Chip selectionRapidly growingExtremely rich

The RISC-V ecosystem is still in a rapid growth phase. For typical embedded development, the tools and ecosystem are already sufficient; but if you need specific peripheral libraries or evaluation board support, ARM still offers a wider selection.

7. Frequently Asked Questions

Q: Can RISC-V run Linux?

Yes. Starting from Linux kernel 5.0 in 2019, RISC-V has been a mainline-supported architecture. Boards like the Milk-V Duo and StarFive VisionFive 2 can run full Linux distributions.

Q: Which is better, RISC-V or ARM?

There’s no absolute answer. If you’re building a commercial product and cost-sensitive, RISC-V’s zero licensing fees are a huge advantage. If you need a mature ecosystem and ready-made library support, ARM is currently richer. But RISC-V is catching up extremely fast — the ecosystem gap is expected to narrow significantly within 3–5 years.

Q: Which dev board should I start with?

  • Lowest budget: ESP32-C3 (¥15, WiFi+BLE, Arduino compatible)

  • Want to learn bare-metal: Sipeed Longan Nano (¥30, includes LCD and RGB LED)

  • Want to run Linux: Milk-V Duo (¥50) or VisionFive 2 (¥500)

Q: What does the future hold for RISC-V?

Optimistically speaking, very bright. Google has announced Android 15 support for RISC-V, and NVIDIA is also investing in RISC-V R&D. The embedded space is RISC-V’s home turf — the ESP32-C3 has already proven that RISC-V is fully viable in IoT scenarios.

8. Summary

RISC-V isn’t “just another processor architecture” — it’s an attempt at architectural democratization. Anyone can freely design and use processors, no longer constrained by licensing fees and technical barriers.

Key takeaways:

  • RISC-V is an open-source instruction set — free and extensible

  • Modular design (I/M/A/F/D/C/V), composed as needed

  • Chips like the ESP32-C3 are already in mass production, with a rapidly maturing ecosystem

  • Low barrier to entry — a ¥15 dev board is all you need to get started

  • Suitable for IoT, embedded, AI acceleration, and many other scenarios

If you’ve only worked with Arduino (AVR) or STM32 (ARM) before, RISC-V will give you a whole new perspective. In the next installment, I’ll discuss the pros and cons of Espressif’s RISC-V series (C2/C3/C6) compared to the traditional Xtensa architecture.

Test environment for this article: ESP32-C3-DevKitM-1 + Arduino IDE 2.x + ESP-IDF 5.0