Tagged: NRFConnect NRF9160
June 5, 2021 at 12:16 #30636
targeting the NRF9160 DK (‘Non-Secure’ nrf9160ns) per NCS 1.5.1
with VisualGDB (build 4132 from this forum, due latest VS 16.10 breaking) and the VisualGDB own arm-GCC 9.3.1 toolchain. Both the ncs folder and my project are on same drive.
I tried to follow tutorial
but in your NRFConnect wizzard, I’m selecting the offered, SPECIAL example named ‘NRFX’ from ncs zephyr folder
demonstrating the GPIOTE and DPPI/PPI using nrfx API directly (without a zephyr device).
First, this example runs OK with the Nordic provided SES IDE!
(NOTE: it has a source bug with the DPPI-out LED not toggling, but thats another story!)
debugging with VisualGDB is quite impossible!
– with direct F5 execute, the breakpoints can’t be set at most lines, or never get hit.
– using the attach method (per tutorial steps: burning flash per nrfjprog, awaiting with ‘SysprogsDebuggerAttached’):
all I can see (VisualGDB, debug -suspend) is the app looping in an single idle task.
I verified both, Configuration Settings ‘Optimize for debugging’ and Compiler Options / Optimization level ‘Optimize debugging experience’
Note, as soon as I added more code lines to the source, the breakpoint displacement got worse,
especially when adding zephyr-os calls like k_msleep.
For me it looks like the generated HEX-code does not match to the source / ELF anymore?
– is this 1.5.1 ‘NRFX’ example supported and tested with current VisualGDB?
– does SysprogsDebuggerAttached work automatically, or is there a debugger setting?
ThanksJune 7, 2021 at 12:38 #30642
The specific examples come from the device vendors (Nordic in this case). We do not test every example on every device and generally advise contacting the device vendor if some of the examples don’t work.
That said,the Nordic devices are somewhat trickier to debug than other device families, because their proprietary network hardware may stop working if the core it stopped in a debugger for too long. In our experience, using non-intrusive debugging techniques (e.g. Fast semihosting and Live Watch) works better than the regular step-by-step debugging.
Another issue is that the NRFConnect SDK normally sets the optimization level to -Og instead of -O0, making GDB somewhat less precise. VisualGDB can override the optimization level to -O0 via VisualGDB Project Properties -> NRFConnect Project -> Optimization = Disable Completely, however it will increase the amount of memory used by the application (heap/stack) and may cause runtime errors for some examples.
We would normally advise the following steps to troubleshoot it:
- Try completely disabling optimization. Do the breakpoints work correctly?
- If not, try adding a hardcoded breakpoint to the same location where you would normally set a regular one:
- If the hardcoded breakpoint doesn’t work, disabling optimization has triggered errors (e.g. heap/stack overflows in the project). You can then revert to the “optimize for debugging” setting and manually disable optimization for a select set of sources where you would like to have precise debugging. This can be done by editing CMakeLists.txt as shown below:
C++1set_source_files_properties(src/main.c COMPILE_FLAGS -O0)
The SysprogsDebuggerAttached logic should work out-of-the-box. However, the Zephyr thread enumeration in NRFConnect SDK 1.5.1 requires the following hotfix: VisualGDB-188.8.131.5242.msiJune 8, 2021 at 11:55 #30646
Thanks for the valuable tips, I will try them out in the next days, once I have the priority back to this platform.
You must be logged in to reply to this topic.