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

Debugging problem using NRF_LOG

Hi,

I'm using NRF_LOG for debugging. SDK version is 12.3.0.

I want print error code, File name, Line number.

Error code is printed fine but, file name and line number are not.

Printed like this:

image description

Code is like this :

image description

Am I wrong about using NRF_LOG?

Thanks for reading my question.

Parents
  • This is the modified error fault handler that I use in SDK 12.3.0:

    __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    {
        static error_info_t  * p_error_info;
        p_error_info = (error_info_t*)info;
        NRF_LOG_ERROR("Error: ID: %d, PC: 0x%X\n\r", id, pc);
        NRF_LOG_ERROR("Error: Code: 0x%04X (%d), Line: %d, File: %s\n\r", p_error_info->err_code, p_error_info->err_code, p_error_info->line_num, (uint32_t)p_error_info->p_file_name);
        NRF_LOG_FINAL_FLUSH();
        
        // On assert, the system can only recover with a reset.
    #ifndef DEBUG
        NVIC_SystemReset();
    #else
        app_error_save_and_stop(id, pc, info);
    #endif // DEBUG
    }
    

    Can you try something similar?

  • I changed the code slightly. I tested this in SDK 12.3.0.

  • Thanks for your example. I just noticed that %0 formatters don't work in 12.3.0 in SEGGER ES. 
    So NRF_LOG_ERROR("Error: Code: 0x%04X (%d), Line: %d, File: %s\n\r", p_error_info->err_code, p_error_info->err_code, p_error_info->line_num, (uint32_t)p_error_info->p_file_name);

    Will hang. I went with

    NRF_LOG_ERROR("Error: Code: 0x%X (%d), Line: %d, File: %s\n\r", p_error_info->err_code, p_error_info->err_code, p_error_info->line_num, (uint32_t)p_error_info->p_file_name);

Reply
  • Thanks for your example. I just noticed that %0 formatters don't work in 12.3.0 in SEGGER ES. 
    So NRF_LOG_ERROR("Error: Code: 0x%04X (%d), Line: %d, File: %s\n\r", p_error_info->err_code, p_error_info->err_code, p_error_info->line_num, (uint32_t)p_error_info->p_file_name);

    Will hang. I went with

    NRF_LOG_ERROR("Error: Code: 0x%X (%d), Line: %d, File: %s\n\r", p_error_info->err_code, p_error_info->err_code, p_error_info->line_num, (uint32_t)p_error_info->p_file_name);

Children
No Data
Related