GD32F130 problem to download the code above address 0x80016A0

Hello everyone, I’m having a problem that I can’t solve and I think you can help me.

I have a GD32f130 microcontroller and I am not able to write code above address 0x80016A0.

Below this address it records correctly and it works. When I make a program more than 16A0, it no longer records.

Here is a code example that when build in Platformio and loading the .bin file gives the problem. I used The STM32CubeProgrammer and the STM32 Link Utility, with firmware updated. ST-Link V2

I already tried cleaning the chip and then recording, always the same error.


I suspect that the .bin or elf file is being generated with an error.

Thanks in advance is not a PlatformIO project. How did you turn it into a PlatformIO project? Or are you using

Hi Max,

Yes, it is, but now I realized that maybe I’m using the wrong recording method.

I’m trying to record using the STM32 Cube programmer.

I believe I should record through Platformio. Strange, because it worked up to the size of the mentioned code, but still not working.

xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:19)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 1

target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800247c msp: 0x20002004
** Programming Started **
Error: timed out while waiting for target halted
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0xa1000003 pc: 0x0800177a msp: 0x20001fa8
Error: error waiting for target flash write algorithm
Error: error writing to flash at address 0x08000000 at offset 0x00000000
embedded:startup.tcl:1070: Error: ** Programming Failed **
in procedure ‘program’
in procedure ‘program_error’ called at file “embedded:startup.tcl”, line 1135
at file “embedded:startup.tcl”, line 1070
*** [upload] Error 1
================================= [FAILED] Took 20.25 seconds =================================

Here my platformio

src_dir = Src
include_dir = Inc

platform_packages =

platform = ststm32
board = gd32f130c8
debug_tool = stlink
framework = spl
build_flags = -IInc
extra_scripts =

I was having the exact same problem but found the solution. It seems like some GD32F130 are faulty and it won’t be easy to write firmware to them; neither through STMCubeProgrammer, nor keil, nor platformio, nor stlink-utility (even though we are just trying to upload some .hex or .bin file) BUT you will be able to upload it with st-flash (GitHub - stlink-org/stlink: Open source STM32 MCU programming toolset) here’s the original comment that I found and tested and worked (Can't flash firmware · Issue #8 · EFeru/hoverboard-sideboard-hack-GD · GitHub). And here’s the command that I ran: st-flash --reset write .pio/build/genericGD32F130C8/firmware.bin 0x08000000