Using platform io debugger with GD32FV103

I'm starting to play with the GD32FV103 chip

It is basically a STM32F103 clone with a riscV core instead of an arm M0+ one

I've used GD32 chips in the past, and they work pretty well.

The overall software support for the GD32FV103/Longan nano is not bad at all, there is a gcc toolchain, a fork of openOCD and even a blackmagic equivalent for it.

What about debugging ? Sure thing there is a working command line gdb.

Sometimes it is helpful to have a nice UI to debug stuff. Let's give it a whirl :

  • codium/vscode : Does not like  the riscv architecture
  • netbeans : Does not seem to like the very long register list and goes into error quickly
  • platform io : Works !
Platform IO is pretty good when you want an integrated environment with a one click deploy/install.
You can compile a "hello world" in 10 seconds.

The thing is, i  dont like much all integrated environment. I much prefer a cmake build system with an IDE on top of it. It gives you all the benefits of both.
You can use the cmake build system as standalone , or use another  IDE depending on your taste as long as it supports cmake (most do).

So no cigar ?

There is a solution : we can use the bait and switch method with platform io.

What does it mean ?

It means we create a fake platform io project, and when we debug the fake project, it actually debugs our project. That way we can build our project any way we see fit, and the fake platform io project is never changed.

How does that work ?

First create an empty platform io project targeting the longan nano + GD32 SDK
then modify platformio.ini that way (assuming you are using a FTDI jtag interface)


[env:sipeed-longan-nano]
platform = gd32v
board = sipeed-longan-nano
framework = gd32vf103-sdk
debug_init_cmds =
  target extended-remote :3333  
  monitor reset halt
  monitor init
  file /home/fx/Arduino_gd32/hello/build/hello.elf 
  load
  monitor reset halt

Start openOCD-riscv and hit "debug" in platform io : It works !
I'm debugging my project and not the platformIo one.

The important part is  the file line, where we point to our real elf file
The whole thing needs to be tuned, but as a proof of concept it's good enough.

Comments

Popular posts from this blog

Component tester with STM32 : Part 1 ADC, Resistor

Fixing the INA3221

INA3221, weird wiring