The cheap stlinkv2 usb dongles can be feisty. Yeah, you can pick them up for $3 with free shipping from faraway if you are willing to wait for them to show up. And that can really have some appeal to the underfunded programmer.
After finishing the first minimum viable product version of the software for a neat embedded device, the programming apparatus immediately decided to take a long-lunch. The stlinkv2's in it stopped playing nice. I started by updating the firmware to the latest from ST, which did not work. Fortunately, it did not entirely brick the programmers. After flashing many versions of the official firmware from ST, I have found that the one mentioned here still works with stm8flash for the most part. It's older, but that's what works for now.
This software that ST provides is a java app that other folks have written at-length about. There seems to be a different zip file version of it for every version of the stlinkv2 firmware. Is that really the easiest way to do it?
The next problem was that it worked, repeatedly flashing onto the same device, but when I plugged in a new device to program, the usb programmers stopped responding. I suspect because the firmware is so old.
Workaround. After trying a bunch of different ways to reset the usb device for each programmer before trying to use stm8flash, I found that this one worked pretty consistently. The usbreset.c code compiled readily on both my main linux box and on the raspberry pi in my flashing apparatus.
resetting stlink devices
Resetting USB device /dev/bus/usb/001/005
Resetting USB device /dev/bus/usb/001/006
It's not ideal, but it works. Flashing devices resumes normally after the reset.