MOSAIC-LoPoW / octa-stack-students

octa-stack student version
8 stars 0 forks source link

Debugging on the nRF in VSCode (BLE) #39

Closed n00bhax closed 3 years ago

n00bhax commented 3 years ago

How do you use the cortex-debugger with the nRF boards? We tried multiple launch.json configurations. One of them started the debugger seemingly successful, but when we add a breakpoint, the program stopped.

image @Klievan

n00bhax commented 3 years ago

It looks like the debugger is causing our program to crash, while it runs normally without it.

SamGeens commented 3 years ago

It seems that crashing after continouing from a debug point is the 'expected' behaviour when using a soft device: https://devzone.nordicsemi.com/f/nordic-q-a/32973/nrf_breakpoint_cond-in-debug

Klievan commented 3 years ago

Indeed. So you can't break once you've got the softdevice initialized. The reason for this is that BLE needs 100% accurate timing to sync its communication. When you stop at a breakpoint your hardware timers are still going to be running, so when you resume and the clock suddenly jumped by a couple of seconds it's going to go into a hardfault as it thinks the crystal is broken. You can still use breakpoints just to see if you're reaching a specific line, but after that you've got to reset the device. This is what I usually do to debug BLE issues.