I have the same issue on STM targets with programs built using Mbed OS 6.6.0.
Changing the STM-Link firmware revision did not help.
One way how to recover such board is to erase the chip’s flash memory with the STM32CubeProgrammer. Make sure you keep the Reset
button pushed on the Mbed board when clicking on the Connect
button on the STM32CubeProgrammer. Otherwise it won’t connect. When connected you can release the Reset
button. Once the board is recovered you can continue to use it with Mbed OS 6.5.0 or earlier.