Today I've had success again.
I had some very weird problems (as usual).
One of the problems was that my latest batch of "Blue Pills" had some "id code" 0x2ba01477
For older Pills, the ID code was: 0x1ba01477
This had some problem with the toolchain I used "some time ago".
Yesterday & today I got a blinking LED working again on my new batch of Blue Pills.
I could not install stlink-tools with apt (Still have to figure out why that does not work), So I compiled from source (github.com/texane)
I had a look at the first tutorial from Matej Bagsic:
His blinking led project (github) does not "blink" though, and is dependent on an I/O pin, and it's also for an STM32F40x.
So, after a quick search:
https://www.startpage.com/row/search?q="blue+pill"+blinking+led+example+program
I found Satoshim (again):
https://github.com/satoshinm/pill_blinkI compiled his "bare-metal/" project with the provided makefile.
There is no programmer specified in that makefile, so I added a target for st-flash:
flash: pill_blink.bin
st-flash write pill_blink.bin 0x8000000
After that I have changed the blink rate multiple times, and verified the change in the blink rate on the Blue Pill after flashing.
There were 2 other weird problems I had to overcome:
I have another Blue Pill, which I flashed with a GRBL variant some time ago (years), and this was still attached to an USB port and somehow this showed up as an STM32F40x and gave an incromprehensible error with libusb, but after detaching the plug the error went away.
Some other things to keep track of:
The first time you flash with st-flash, you overwrite the bootloader (which also has a blinking led). And then the led stopped blinking, it just went off. After a power cycle it started flashing at the new flashrate, and consecutive programming cycles did not need a power cycle, nor reset button or BOOT jumper changes. Both BOOT jumpers are "0", that is, on the side of the USB connector.
In the old programmer software I used I had to "unlock" the flash of each new blue pill before it could be written. With st-flash this is apparently not necessary anymore.
Satoshinm also has blink projects for CubeMX and LibOpenCM3, so pick your poison.