This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Debugging App Error Handler and can't set breakpoint in main.c

Hi,

I have a nrf52840-DK board connected to an upstream nrf52840-DK board as well as another downstream nrf52840-DK board.

This setup will run fine for a couple of hours and then the middle board will throw an App Error handler and perform a soft reset. It will then connect back with it's neighours and run for a couple of hours before throwing the same error again.

Is this an error thrown by the soft device or my application code?

As can be seen from the message printout, it wasn't helpful for me to pinpoint the cause.
Any idea what 0x62D means? I am sure I don't have so many lines of code as reported.

I was trying to do a breakpoint and examine the call stack but for some strange reason, I can't set a breakpoint in main.c where the app_error_fault_handler() was defined, reason given by VS code "No source file named main.c". I am able to set and break at other breakpoints in other source modules.

nrf52840-DK

SDK 15.2

softdevice S140

VS Code with Segger JLinkGDBServerCL.exe

Will be helpful if the community can suggest some possible causes and probably some work around or different approach to hunt down the error cause.

Thank you.

Parents
  • Hi,

    This is what the default app_error_fault_handler looks like in the nRF5 SDK v15,

    /**
     * Function is implemented as weak so that it can be overwritten by custom application error handler
     * when needed.
     */
    __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    {
        __disable_irq();
        NRF_LOG_FINAL_FLUSH();
    
    #ifndef DEBUG
        NRF_LOG_ERROR("Fatal error");
    #else
        switch (id)
        {
    #if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT
            case NRF_FAULT_ID_SD_ASSERT:
                NRF_LOG_ERROR("SOFTDEVICE: ASSERTION FAILED");
                break;
            case NRF_FAULT_ID_APP_MEMACC:
                NRF_LOG_ERROR("SOFTDEVICE: INVALID MEMORY ACCESS");
                break;
    #endif
            case NRF_FAULT_ID_SDK_ASSERT:
            {
                assert_info_t * p_info = (assert_info_t *)info;
                NRF_LOG_ERROR("ASSERTION FAILED at %s:%u",
                              p_info->p_file_name,
                              p_info->line_num);
                break;
            }
            case NRF_FAULT_ID_SDK_ERROR:
            {
                error_info_t * p_info = (error_info_t *)info;
                NRF_LOG_ERROR("ERROR %u [%s] at %s:%u\r\nPC at: 0x%08x",
                              p_info->err_code,
                              nrf_strerror_get(p_info->err_code),
                              p_info->p_file_name,
                              p_info->line_num,
                              pc);
                 NRF_LOG_ERROR("End of error report");
                break;
            }
            default:
                NRF_LOG_ERROR("UNKNOWN FAULT at 0x%08X", pc);
                break;
        }
    #endif
    
        NRF_BREAKPOINT_COND;
        // On assert, the system can only recover with a reset.
    
    #ifndef DEBUG
        NRF_LOG_WARNING("System reset");
        NVIC_SystemReset();
    #else
        app_error_save_and_stop(id, pc, info);
    #endif // DEBUG
    }

    NRF_FAULT_ID_SD_ASSERT is ID 1, so looks like you are getting a SoftDevice assert.

    1) Could you print the pc value you get in app_error_fault_handler() ?

    2) What version of SD S140 are you using?

  • Thanks Sigurd for coming back.

    I will print pc value but will take a while to update the post with this value as we are running some extehded test at the moment.

    The version of SD S140 is 6.1.0, s140_nrf52_6.1.0_softdevice.hex to be more precise.

    While waiting, do you know why the filename and line number are "scrambled" in the printout and also why I cannot set breakpoint in main.c

  • JasonGeo said:
    I will print pc value but will take a while to update the post with this value as we are running some extehded test at the moment.

    Ok.

    JasonGeo said:
    do you know why the filename and line number are "scrambled" in the printout

    I don't think these fields are valid/populated when it comes to SD asserts.

    JasonGeo said:
    I cannot set breakpoint in main.c

    I have not used nRF5-SDK in VS code before, but it could be some configuration issue in VS code. It could also be that you need to build your code with different compiler optimization settings.

  • Hi Sigurd,

    I've got the value of PC when exception occurred.

    PC=0x17660

Reply Children
No Data
Related