Remix.run Logo
bobmcnamara a day ago

> If we don’t have a debugger connected, the breakpoint instruction is going to throw and exception.

Another fun trick: route all semihosting calls through this function in RAM:

  BX LR
  BX LR

Then when you connect the debugger, overwrite with `BKPT 0xAB` to enable semihosting like so:

  BKPT 0xAB
  BX LR
This saves the overhead of an interrupt when not in use. You can still have the hardfault handler ignore it in case you uncleanly disconnect the debugger.