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

Monitor Mode + nRF52 SDK debug issues

Hi,
I am using the nRF5_SDK_14.0.0_3bcc1f7 with SD v5.0.0 and the ble_app_beacon example together with the Jlink Monitor mode for debugging.
The issue is that under some circumstances the jlink monitor mode debugger is not working as expected.

The working environment is Keil v5.25.2.0 and the project used for reproducing the issue is:

nRF5_SDK_14.0.0_3bcc1f7\examples\ble_peripheral\ble_app_beacon\pca10040\s132\arm5_no_packs\ble_app_beacon_pca10040_s132.uvprojx

In the attached example the only differences compared to the Nordics original beacon example are the following:

1. Jlink monitor mode code added
2. Use MicroLIB is not selected
3. the sd_ble_version_get code is added to show the issue
4. getSDversion function added

The code changes are the following:

//==============================================================================

uint32_t getSDversion(void)
{
    uint32_t SDver = 0xFFFFFFFF;
    uint32_t ret;
    ble_version_t p_version = {0};
    ret = sd_ble_version_get(&p_version);
    if (ret == NRF_SUCCESS)
    {
        SDver = p_version.version_number * 1000000 + p_version.subversion_number;
    }
    return SDver;
}

//==============================================================================

int main(void)
{

//------------------------------    
    NVIC_SetPriority(DebugMonitor_IRQn, _PRIO_SD_LOW);
//------------------------------    

    // Initialize.
    log_init();
    timers_init();
    leds_init();
    ble_stack_init();
//------------------------------    
    NRF_LOG_INFO("testing.\r\n");
    while(1)
    {
        uint32_t SDversion = getSDversion();
        NRF_LOG_INFO("SD version: %d", SDversion);
        NRF_LOG_PROCESS();
    }
//------------------------------    
    advertising_init();
    advertising_start();

    // Start execution.
    NRF_LOG_INFO("Beacon example started.");

    // Enter main loop.
    for (;; )
    {
        if (NRF_LOG_PROCESS() == false)
        {
            power_manage();
        }
    }
}
//==============================================================================

Running the code without any breakpoint or with a breakpoint at line 9 "if (ret == NRF_SUCCESS)",

the expected RTT prints are correct:

<info> app: testing.

<info> app: SD version: 9000157
<info> app: SD version: 9000157
<info> app: SD version: 9000157
<info> app: SD version: 9000157


Running the code with a breakpoint at line 8 "ret = sd_ble_version_get(&p_version);"
gives wrong RTT prints :

<info> app: testing.

<info> app: SD version: 0
<info> app: SD version: 0
<info> app: SD version: 0



If I will make only one of the following changes, then the debugging is working as
expected and the RTT prints are also correct:

1. disable the jlink monitor mode by changing in the JLinkSettings.ini the following line
MonModeDebug = 0

2. make the getSDversion -> ble_version_t p_version local variable static
static ble_version_t p_version = {0};

3. changing the Option for Target->Target->Use MicroLIB to ON
(In another project this will not make any change)

These error seems to be related with the SD calls of the nordic SDK and the Jlink monitor mode.

Is this an issue of incompatibility of jlink monitor mode with the nRF52 SDK?
Any ideas how to solve this issue?

Thanks
Athanasios

ble_app_beacon_monitor_issue.zip

Related