When I try to debug a programm (build with "optimize for debugging" and debugging started by pressing "Debug" in VSCode) I get to the debug-view and can also go one or a few lines further (using e.g. Step-Over or Continue), but then the program crashes and enters a restart-loop (as visible from the serial terminal).
The same programm executes without issues when just ran (pressing "Flash" instead of "Debug" in Visual Studio Code).
I'm building a more complex programm that also uses the secure partition etc, but for demonstration purposes I just build a very simple Hello-World programm without any of that consisting just of these three files:
main.c
int main(void) #include <zephyr/kernel.h> #include <stdio.h> int main(void) { printf("Begin \n"); for (int i = 0; i < 3; i++) { printf("Hello World \n"); } printf("End \n"); return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(helloworldtest) target_sources(app PRIVATE src/main.c)
complete empty prj.conf
When executing by pressing "Flash" the terminal once prints the correct/expected output:
*** Booting nRF Connect SDK v3.5.99-ncs1-1 *** Begin Hello World Hello World Hello World End
When instead pressing "Debug" i get to the Debug view, but can only get to until the first printf (whether i select "Step Over", "Step Into", or just "Continue"). Then the program enters a boot-loop:
*** Booting nRF Connect SDK v3.5.99-ncs1-1 *** Begin *** Booting nRF Connect SDK v3.5.99-ncs1-1 *** Begin *** Booting nRF Connect SDK v3.5.99-ncs1-1 *** Begin
(and so on)
Similar behavior occurs in my actual programm (debugging crashes after first/first few lines), this simple Hello World programm is just for demonstration purposes.
(This is SDK v2.6.1 with a nRF9161.)
How might this be fixed?