Longan Nano: a super low-cost RISC-V board

In this article I introduce the Longan Nano, a small and inexpensive (US$ 4.90) RISC-V development board by Seeed Studio. We take a look at the GD32VF103CBT6 microcontroller, its peripherals, the board features, programming environment and example code.

RISC-V Microcontroller

The Longan Nano board is powered by a RISC-V microcontroller. For those who still don’t know, RISC-V is a free and open architecture which defines an Instruction Set Architecture (ISA) for high-performance and low-power processors. I have talked about the another RISC-V 32-bit core in my article “FE310G: an open source RISC-V microcontroller – Introduction“.

One main difference here is that the Longan Nano is powered by a different RISC-V microcontroller: the GigaDevice GD32VF103CBT6. This is a general purpose 32-bit RISC-V microcontroller with 128 KiB of flash memory and 32 KiB of RAM. Unlike the FE310, GD32V devices include flash memory built into the silicon, just like an ordinary MCU.

The GD32V product line ranges from 36-pin QFN MCUs with 16 KiB of flash and 6 KiB of RAM, up to 100-pin LQFP MCUs with 128 KiB of flash and 32 KiB of RAM. They include 4 16-bit timers, PWM timer, RTC, USARTs, SPI, I2C, CAN 2.0B, Full-speed USB, I2S, 12-bit ADC and 12-bit DAC. Clock speed can go up to 108 MHz.

These parts are extremely similar to STmicro’s STM32F103 product line, the main difference is the RISC-V core (GigaDevice also has Cortex-M3, Cortex-M4 and Cortex-M23 lines) and the higher clock speed.

For more details you can check the datasheet or the user manual.

Bumblebee Core

Talking about core, these microcontrollers use a Nuclei Bumblebee core (N200) which implements RISC-V ISA version 2.2 RV32IMAC. The IMAC suffix stands for:
I – 32 32-bit integer general purpose registers;
M – Multiply/divide instructions;
A – Atomic instructions;
C – 16-bit Compressed instructions.

It features a 2-stage pipeline with a dynamic branch predictor and a 2-instruction prefetch unit.  An Enhanced Core Level Interrupt Controller (EPLIC) handles the interrupt and exception system. There is a 64-bit core timer (as per RISC-V standard) that can be used for core timing and . It also sports an internal debugger module with JTAG interface and up to four hardware breakpoints.

According to Nuclei, this RISC-V core can achieve higher performance and lower power consumption when compared to a Cortex-M3 in the same silicon process:

N205 comparison

Longan Nano

The board itself is very small (5.3 x 2.2 cm). It includes a GD32VF103CBT6, a 160 x 80 TFT LCD, a micro SD card slot, two onboard LEDs (one red for power and another RGB that can be controlled by user application) and a USB-C connector.

Top view of Longan Nano - Boot0 and Reset buttons are located between USB-C and the LCD
Top view – Boot0 and Reset buttons are located between USB-C and the LCD

The LCD is based on the ST7735S controller and uses SPI interface to communicate with the microcontroller. It is fast enough to play real-time video as we can see on the video on the top of this article. That video is playing a raw binary video using the example provided by Seeed. The original example outputs a sequence of images (stored in the micro SD card) to the LCD. I introduced some tiny changes to improve display speed in the video above. It can be improved even further by enabling the DMA to handle SPI transfers.

In anyway, the end result is impressive.

Bottom view of Longan Nano - micro SD card and JTAG (on the left)
Bottom view – micro SD card and JTAG (on the left)


Programming Environment

GigaDevices relies on PlatformIO, a plugin that enables quick and easy embedded systems development using Visual Studio Code.  To get started with GD32V on PlatformIO, all you have to do is to install the GD32V platform as shown below.

Thanks to similarities with STM32, writing applications for the GD32VF is really easy. There is a Github repository with examples (just an LED blinker) and a separate repository for the example that ships with the board. Gigadevices website also hosts several examples for almost all peripherals.

The default method for flashing an application is by pressing BOOT0 followed by RESET button. That forces the microcontroller into DFU (Device Firmware Update) mode. You can then use the “Upload” task on PlatformIO to upload the binary file to the GD32V over USB.

There is an ongoing work to add support for Arduino (which can be directly selected within PlatformIO).

And if you like Rust there is a Rust repository with a GD32V HAL and examples!


Leave a Reply