This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Application code debugging will ALWAYS hang in SoftDevice address range

I'm having a very strange issue when trying to debug application code on my Nordic platform. I'm hoping that someone else can shed some light on the issue, or at least confirm if others are seeing it.

The background: ANT-based application using nRF51422 Using single wire debug (SWD) setup via Keil/Segger JLINK (NOT building source through Keil MDK)

My problem is that anytime I want to debug application code ("real" debugging using SWD, not UART print outs) I always get "stuck" in a SoftDevice call. For example, one of the first things that application code does is to enable the SoftDevice, calling sd_softdevice_enable(). If, while debugging, I place a breakpoint anywhere after this call (with no other breakpoints), I will never reach that breakpoint. I can halt the debugger and I am always at the same address, off in the SoftDevice stack. I can run or "step out" from this point all I like, but I will always stay in the same address range (always returning back to the same address, able to step to subsequent addresses, but never exiting the SD call).

I inadvertently discovered that, in a few of these scenarios, I can step a "magic number" of times and somehow I exit the SD address range and return to my application code. This does not work for most SD calls, and the "magic number" differs almost every time.

I know that at least one other developer at my company has seen this issue, on a separate (but very similar) project from my own, so I at least know I'm not crazy. If anyone can provide some insight on this, you would really make my Nordic development much more enjoyable.

Thanks!

Parents
  • I see something similar - in some of the example projects for nRF51422 using softdevice and Keil.

    For instance in the ant_bicyle_power_only_sensor.. In the infinite event handling loop:

    for ( ; ; ) 
    {             
                       return_value = sd_app_event_wait(); 
                       APP_ERROR_CHECK(return_value);
                        if (!m_ant_stack_event_received)
                      {            
                           ....
                       }
    }
    

    If I put a breakpoint anywhere in this loop and it gets hit, the application stops working when resuming. Without a breakpoint or when it is not hit, the application is running as expected.

    I can also break into the loop by setting a breakpoint while it is running in the debugger (never been stopped in debugger), but when resuming it will run at most one loop, then the application is hung and RF communication stops. Probably it is caught in a fatal assert() as mentioned in above link.

    I also tried to set AllowSimulation = 0 in the JLinkSettings.ini as I have read somewhere to be recommended - but it does not make any difference at all.

    So are we really left with print-statements to debug while softdevice is active?

Reply
  • I see something similar - in some of the example projects for nRF51422 using softdevice and Keil.

    For instance in the ant_bicyle_power_only_sensor.. In the infinite event handling loop:

    for ( ; ; ) 
    {             
                       return_value = sd_app_event_wait(); 
                       APP_ERROR_CHECK(return_value);
                        if (!m_ant_stack_event_received)
                      {            
                           ....
                       }
    }
    

    If I put a breakpoint anywhere in this loop and it gets hit, the application stops working when resuming. Without a breakpoint or when it is not hit, the application is running as expected.

    I can also break into the loop by setting a breakpoint while it is running in the debugger (never been stopped in debugger), but when resuming it will run at most one loop, then the application is hung and RF communication stops. Probably it is caught in a fatal assert() as mentioned in above link.

    I also tried to set AllowSimulation = 0 in the JLinkSettings.ini as I have read somewhere to be recommended - but it does not make any difference at all.

    So are we really left with print-statements to debug while softdevice is active?

Children
No Data
Related