Bad checksum with stm32F411CE black pill

First time on the forum. I have to say I’m very intrigued by platformIO and I hope someone will be able to spot what I’m doing wrong.

I have a black pill board with the STM32F411CEU6 and I’m trying to flash it using an STlink looking like this:

I have been trying a few different configurations that look like this:

[env:blackpill_f411ce]
platform = ststm32
board = blackpill_f411ce
extra_scripts = undefined_exit.py
; change microcontroller
board_build.mcu = stm32f411ceu6

; change MCU frequency
board_build.f_cpu = 100000000L

build_flags = -v

[env:genericSTM32F411CE]
platform = ststm32
board = genericSTM32F411CE
upload_protocol=stlink
extra_scripts = undefined_exit.py

; change microcontroller
board_build.mcu = stm32f411ceu6

; change MCU frequency
board_build.f_cpu = 100000000L

I execute with the command like this

platformio run -eblackpill_f411ce -t upload

And it doesn’t matter which of the configurations I use it gives me the same problem:

Processing blackpill_f411ce (platform: ststm32; board: blackpill_f411ce)
-----------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/blackpill_f411ce.html
PLATFORM: ST STM32 (15.6.0) > WeAct Studio BlackPill V2.0 (STM32F411CE)
HARDWARE: STM32F411CEU6 100MHz, 128KB RAM, 512KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES: 
 - tool-dfuutil @ 1.11.0 
 - tool-openocd @ 2.1100.211028 (11.0) 
 - tool-stm32duino @ 1.0.1 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/blackpill_f411ce/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.1% (used 124 bytes from 131072 bytes)
Flash: [          ]   0.1% (used 424 bytes from 524288 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, serial, stlink
CURRENT: upload_protocol = stlink
Uploading .pio/build/blackpill_f411ce/firmware.elf
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:15)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

hla_swd
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000734 msp: 0x20020000
** Programming Started **
Warn : no flash bank found for address 0x00000000
Warn : no flash bank found for address 0x00018164
** Programming Finished **
** Verify Started **
Error: checksum mismatch - attempting binary compare
embedded:startup.tcl:1070: Error: ** Verify Failed **
in procedure 'program' 
in procedure 'program_error' called at file "embedded:startup.tcl", line 1131
at file "embedded:startup.tcl", line 1070
*** [upload] Error 1
==================================== [FAILED] Took 1.07 seconds ====================================

Environment       Status    Duration
----------------  --------  ------------
blackpill_f411ce  FAILED    00:00:01.071
=============================== 1 failed, 0 succeeded in 00:00:01.071 ===============================

The program I’m trying to flash is just an empty and infinite while loop.
I should also say this is my first time using anything STM or platformIO so I feel like I must have missed something simple but I can’t quite see what. I’ll be happy to do my best to provide further information or logs. Any tips on what I can try is helpful.
This is my test setup to learn how to program stm32 chips as I have a custom PCB ordered for assembly and coming in a few weeks.

I got it working.
When using CLion I had started the project as an stm32cube project and that needed to be specified in platformio.ini as framework = stm32cube and that duplicated the work of my extra_script so I needed to remove that as well.

Just for completeness: This looks like eiher no linker script was used during linking or the wrong one, e.g. by the absence of a framework directive that would automatically take care of it. Flash is at 0x8000000, but without a linker script telling it about the memory layout, it will default to 0x0, but a then a flash to 0x0 will fail because there’s no flash memory there.