Status of GD32 ARM support?

There’s no short answer to that, so I just did some experimenting and got something that is compilable. I have no board so I’d be pleased if you can test it (and possible adopt it to get it there):

https://github.com/maxgerhardt/pio-gd32f350cb

I’ve also updated the modified framework-spl library at https://github.com/maxgerhardt/pio-framework-spl-with-gd32.

Basically to understand what’s going on here you need to understand:

Roughly what happened here is:

  • download GigaDevice’s SPL pacakge
  • copy header files from GD32F3x0_Firmware_Library\Firmware\CMSIS in framework-spl\gd32\cmsis\cores\gd32
  • copy device header and system header files from GD32F3x0_Firmware_Library\Firmware\CMSIS\GD\GD32F3x0\Include into framework-spl\gd32\cmsis\variants\gd32f35
  • copy system_gd32f3x0.c from GD32F3x0_Firmware_Library\Firmware\CMSIS\GD\GD32F3x0\Source into the above mentioned target path too
  • find CMSIS\GD\GD32F3x0\Source\ARM\startup_gd32f3x0.s as the startup assembly code meant for the ARM compiler / assembler
    • the content in there is the Reset_Handler entry point, initialization and startup code up to the piont where main() is called and all interrupt vectors
    • here is where it get’s tricky: PlatformIO uses GCC. GigaDevices only provides the startup script for IAR + ARM assemblers/compilers. GCC will not accept assembly file in the ARM compiler syntax. The file has to be converted into proper arm-gcc assembly. using a template like startup_stm32f30x.s together with the interrupt vector names from the original file and some background knowledge in assembly allows one to create a fixed startup_gd32f3x0.s file which will correctly assembler in GCC.
  • Copy all files from GD32F3x0_Firmware_Library\Firmware\GD32F3x0_standard_peripheral\Include to framework-spl\gd32\spl\variants\gd32f35\inc (SPL code header files)
  • Copy all files from GD32F3x0_Firmware_Library\Firmware\GD32F3x0_standard_peripheral\Source to framework-spl\gd32\spl\variants\gd32f35\src (SPL code implementation files)

So all in all it’s knowing which paths PlatformIO’s SPL builder scripts expects the different type of files to be and copying there, and doing one conversion for the startup assembly.

After that it’s down to knowing how to

  • create board definition JSON files (documentation linked above, and existing stm32 definitions can be used as template)
    • just contains some names, OpenOCD config file names, amount of flash & RAM, clockspeed, and activated macros (which can in turn be read from the SPL framework code to find out which are needed for a specific chip, e.g. GD32F350 or GD32F350)
  • make PlatformIO use the new SPL files (that is, exchanging the source of framework-spl with platform_packages
  • make PlatformIO use a custom board definition file (that is, create a folder boards/ in the project and put in the abc.json board definition file, then say board = abc in the platformio.ini, as documented)

Let me know if the example above is flashable + runs.

1 Like