Sipeed Longan Nano Versions

Having bought a small lump of what I thought were Longan Nano boards from aliexpress I struggled for a while to get them to do anything other than become bricks. So this explanation is intended to make an explicit post about the issue rather than it be buried in a discussion of uploading or debugging tools.

Apologies where this is a slight repeat of a sub part of one of those topics :-

A bunch of digging, googling and coupled with trial and error work showed that there is a lot of confusion amongst the sellers as to what they are selling. The boards as supplied had the wrong processors on them.

In most cases the Sipeed (I am assuming none are clones of the earlier version, but they could well be) boards appear to have been produced in two identical looking versions.

Longan Nano using the GD32VF103CBT6 processor (128K Flash, 64K Ram)

Longan Nano Lite using the GD32VF103C8T6 processor (64K Flash, 20K Ram)

In discussion with Sipeed, they did confirm that there were a small number of initial boards made using the GD32VF103C8T6. But that they should be pretty rare.

However there seems to be a lot of confusion on aliexpress when you read the item descriptions. Some descriptions in one place claim GD32VF103CBT6 and go on to later counter claim GD32VF103C8T6. And vice versa.

In my own case the claims were all consistently GD32VF103CBT6, but the boards that arrived were GD32VF103C8T6. So worth asking before buying, and be prepared to test them as soon as they arrive before the buyer protection has expired.

Platformio will support either (\o/) as there are board profiles for both using the GD32V platform . And putting aside the flash and ram they are otherwise identical CPU, IO etc.

Symptoms of programming a GD32VF103C8T6 with either pre-compiled code or compiled code for the GD32VF103CBT6 are that it crashes randomly and quickly or does not run at all. Although the DFU or JTAG upload appear to have succeeded (errors not withstanding).

There are a bunch of errors shown in the terminal for DFU or JTAG (Sipeed RV-Debugger Lite) uploading (Platformio 5.1.0, out of the box) which does confuse matters a lot. Particularly if you are a platformio newbie like myself.

It is also possible to upload them the other way around, programming a GD32VF103CBT6 with either a pre-compiled binary or a compiled binary for the GD32VF103C8T6 . In this case it all works fine except that you don’t get the full code and memory space.

Oddly the loading tools are not currently able to tell the two apart or warn of the issue.

The mismatch that fails is probably due to the heap v stack placement leaving one or other of them placed into ram that does not exist with random results.

Overall though nice little boards, well featured processors (when you know for sure what they are) and using the same peripherals as the STM32F10 version of the same chip, but with a Risc-V core. Don’t be put off by the evolving Platformio support or randomness of vendors.

To tell the processors apart if there is any confusion this function will print out the ram size, flash size, device Id (unique serial No) and Product ID (I think this is specific to the model of gd32vf103).

// get and print information about the device to usart0
void device_info(){
   uint32_t *deviceSig = (uint32_t*)0x1FFFF7E0;
   uint32_t memInfo = deviceSig[0];
   uint32_t *deviceId = (uint32_t*)0x1FFFF7E8;
   uint32_t *productId = (uint32_t*)0x40022100;

   printf("Device Info:-\n\n") ;
   printf("Flash: %3lukB\n", (memInfo >>  0) & 0xffff); 
   printf("SRAM: %3lukB\n", (memInfo >> 16) & 0xffff);
   printf("Device ID: %08lX %08lX %08lX\n", deviceId[0], deviceId[1], deviceId[2]);
   printf("Product ID: %08lX\n", productId[0]);


This prints out:-

Sipeed Longan Nano Lite

USART0 Initialised to 128000 8N1 no flow control
Device Info:-
Flash:  64kB
SRAM:  20kB
Device ID: 3934057C 00053935 FFFFFFFF
Product ID: 4A384333

Sipeed Longan Nano

USART0 Initialised to 128000 8N1 no flow control
Device Info:-
Flash: 128kB
SRAM:  32kB
Device ID: 3941282D 01033637 FFFFFFFF
Product ID: 4A424333

Note the Product ID, RAM and Flash. I have tried the same code on 5 different Longan Nano Lites and they each have the same values for these items, but the Device ID differs.

I used the same platformio.ini and it was setup as per the Longan Nano Lite. The code runs without changes to either itself or the environment on both boards. It wont work if you do it the other way around.