Hello,
I had similar issue also with the ST-link, after a few uses the ST-link remained hanging when erasing the flash memory. Only restart of PC solve the issue. Later I found when I will wait for 3-5min, then the erasing will be finished. Of course, this may not be your case.
Maybe you can look
- Segger J-Link Support - Mbed Studio - Arm Mbed OS support forum
- pyocd/pyOCD: Open source Python library for programming and debugging Arm Cortex-M microcontrollers (github.com)
BR, jan