PlatformIO Community

Stm32 blue pill upload not working on windows

I am trying to flash a program on my stm32 blue pill using a (fake) stlinkv2. I am on windows. When trying to upload, I do get the following error:

target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x1ffff020 msp: 0x200001fc
* Programming Started *
Warn : no flash bank found for address 0x08010000
Warn : no flash bank found for address 0x08010550
* Programming Finished *
* Verify Started *
Error: checksum mismatch - attempting binary compare
embedded:startup.tcl:521: Error: * Verify Failed *
in procedure 'program' 
in procedure 'program_error' called at file "embedded:startup.tcl", line 582
at file "embedded:startup.tcl", line 521
* [upload] Error 1

This is the platformio.ini:

platform = ststm32
board = genericSTM32F103CB
framework = arduino
upload_protocol = stlink
debug_tool = stlink
build_flags = 
monitor_dtr = 1

Any ideas what is happening?

The error message says that there is no flash found beyond 64Kbyte (starting at 0x8000000). The Bluepill comes with a STM32F103C8 chip which is guaranteed to have 64Kbyte of flash. Yes, there are C8 chips around that are actually lesser-tested CB chips with 128Kbyte because they come from the same die, but that is not guaranteed. It looks to me like you have a 64KByte bluepill but want to program it beyond 64Kbyte, as if it had 128Kbyte flash.

Does your firmware require > 64Kbyte flash? What happens when you say board = genericSTM32F103C8 instead?

Wow, this makes sense! The sketch uses just a bit more than half of the 128kb I expected the board to haveā€¦ When setting the correct board the software also complains about too little storage.