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:
- PlatformIO terminology regarding platforms, boards, frameworks and packages (see Frameworks, platforms, and boards, oh my! - #2 by maxgerhardt)
- how platform and board definitions work (Custom Platform & Board — PlatformIO latest documentation)
- a rough understanding of SCons (the underlying build system)
- how the Python builder code for the SPL framework works, what information it expects from a board definition file and what the expected filepaths of certain things (like the SPL code, startup files, CMSIS core headers, … ) are
Roughly what happened here is:
- download GigaDevice’s SPL pacakge
- copy header files from
GD32F3x0_Firmware_Library\Firmware\CMSIS
inframework-spl\gd32\cmsis\cores\gd32
- copy device header and system header files from
GD32F3x0_Firmware_Library\Firmware\CMSIS\GD\GD32F3x0\Include
intoframework-spl\gd32\cmsis\variants\gd32f35
- copy
system_gd32f3x0.c
fromGD32F3x0_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 wheremain()
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 fixedstartup_gd32f3x0.s
file which will correctly assembler in GCC.
- the content in there is the
- Copy all files from
GD32F3x0_Firmware_Library\Firmware\GD32F3x0_standard_peripheral\Include
toframework-spl\gd32\spl\variants\gd32f35\inc
(SPL code header files) - Copy all files from
GD32F3x0_Firmware_Library\Firmware\GD32F3x0_standard_peripheral\Source
toframework-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
orGD32F350
)
- 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.
- make PlatformIO use the new SPL files (that is, exchanging the source of
framework-spl
withplatform_packages
- make PlatformIO use a custom board definition file (that is, create a folder
boards/
in the project and put in theabc.json
board definition file, then sayboard = abc
in theplatformio.ini
, as documented)
Let me know if the example above is flashable + runs.