I did some more tests, and exactly the same code runs just fine on Rapsberry RP2040, STM NUCLEO-F411 and a board with STM32H743.
On STM32F767 the issue occurred in 2 of the 3 tests, in different locations at different moments in time, differently on slow (RPI4) and fast (MacMini). A simple loop of semihosting BKPT calls ran for tens of minutes without halting while being interrupted by the 1000 Hz SysTick, so the problem is not a simple interrupt pending why the BKPT is active. I do not have an explanation why the core triggers the breakpoint at the beginning of the SysTick handler, but the issue is most probably a time sensitive sequence of events (possibly a bug in the mcu?), that also depends on the speed of the machine running OpenOCD. I have no other ideas on how to diagnose this. :-( Unless you have better ideas, my proposal is to take this unexpected BKPT as 'a fact of life', and change OpenOCD to resume it when running with semihosting enabled but standalone (i.e. not in a debug session). Unfortunately my knowledge of OpenOCD internals is not good enough, but if someone else suggests a change, I can tests it. If no fix is found for OpenOCD, my workaround is to simply document the issue and no longer use the F767 board for my tests. Any thought on this? Liviu