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

app_error_fault_handler missing p_file_name and line_num

I am trying to debug an app error in my code. I have an app_error_fault_handler that starts like this:

extern "C" void app_error_fault_handler(uint32_t id, uint32_t pc,
                                        uint32_t info) {
  if (id == NRF_FAULT_ID_SDK_ERROR) {
    error_info_t* err_info = (error_info_t*)info;
    LOG_E("Fatal Error in file %s, line %d", (const char*)err_info->p_file_name,
          err_info->line_num);
    switch (err_info->err_code) {
      case NRF_ERROR_SVC_HANDLER_MISSING:
        LOG_E("Error Code: NRF_ERROR_SVC_HANDLER_MISSING");
        break;
But, the "Fatal Error in file..." line doesn't show the file name and line number. I use this fault handler on other systems, and I've seen the file name and line number before.
The err_code in the error_info_t struct is NRF_ERROR_INVALID_STATE though (which is the value 8), so it doesn't seem like the error_info_t is empty.
Why aren't the file name and line num fields populated? I feel like I might be missing something simple.
Here's the output:
00> <error> app: Fatal Error in file , line 0
00> <error> app: Error Code: NRF_ERROR_INVALID_STATE
Parents
  • What SDK version is this? Why not use the default app_error_fault_handler() ?

    from SDK 16.0:

    __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
    }

  • i'm using a modified SDK 14.2. My handler just hooks into my own logging libraries, and has extra waits for debugging purposes. When I replace my handler with the default one from SDK16.0 (with minor modifications), it still doesn't solve my problem. I get the error:

    00> <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at :0

    As you can see, the file name and line number are still empty, and I don't see anything in the error handler that would help with that.

Reply
  • i'm using a modified SDK 14.2. My handler just hooks into my own logging libraries, and has extra waits for debugging purposes. When I replace my handler with the default one from SDK16.0 (with minor modifications), it still doesn't solve my problem. I get the error:

    00> <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at :0

    As you can see, the file name and line number are still empty, and I don't see anything in the error handler that would help with that.

Children
Related