nRF9160 modem hard fault debugging

  • Hello,

My nRF9160 hard faults (i think?) when issuing a command to the modem, specifically this line:

query_modem("AT+CGSN", imei_buf, sizeof(imei_buf));

which then calls ncs function:

/**
 * @brief Send a formatted AT command to the modem
 *	  and receive the response into the supplied buffer.
 *
 * @param buf Buffer to receive the response into.
 * @param len Buffer length.
 * @param fmt Command format.
 * @param ... Format arguments.
 *
 * @retval  0 On "OK" responses.
 * @returns A positive value On "ERROR", "+CME ERROR", and "+CMS ERROR" responses.
 *	    The type of error can be distinguished using @c nrf_modem_at_err_type.
 *	    The error value can be retrieved using @c nrf_modem_at_err.
 * @retval -NRF_EPERM The Modem library is not initialized.
 * @retval -NRF_EFAULT @c buf or @c fmt are @c NULL.
 * @retval -NRF_ENOMEM Not enough shared memory for this request.
 * @retval -NRF_E2BIG The response is larger than the supplied buffer @c buf.
 * @retval -NRF_EINVAL If @c len is zero.
 */
int nrf_modem_at_cmd(void *buf, size_t len, const char *fmt, ...);

This leads to I think is a hard fault and the board resets, the modem never returns any values, so I can't see what is happening.

NCS 1.9.1

mfw 1.3.2

What might cause this?

How can I debug this?

Thank you

Parents
  • Hi,

     

    Do you have a log or similar showing what happens?

    If a fault condition occurs, you'll usually see a printout on the terminal.

     

    Kind regards,

    Håkon

  • Hi, thank you for your reaponse.

    I run RTT Viewer and it does not show any logs when the device resets. I only see my debug prints which prints just before the above mentioned function.

  • Hi,

     

    Could you try one of these solutions?

    1. Switch over the UART based logging. This should print any fault scenarios (if present).

    2. Enter debug mode, set a breakpoint at the function "z_arm_fatal_error", and if that breakpoint hits: share the content of either "esf_copy" of "esf"?

     

    Kind regards,

    Håkon

  • This is what I can extract from when the debugger hits the breakpoint in VS Code:


    0x20002ea0 <z_interrupt_stacks+1984>

  • Hi,

     

    If you convert the decimal numbers to hex, specifically the contents of LR and PC, you should be able to do a lookup of the addresses using arm-none-eabi-addr2line:

    LR: arm-none-eabi-addr2line -e path/to/build/zephyr/zephyr.elf 0x4a17b

    PC: arm-none-eabi-addr2line -e path/to/build/zephyr/zephyr.elf 0x27326

     

    Content of R2, 537000870 (0x2001fba6), is in the RAM and must be checked in the build/zephyr/zephyr.map file manually to see which section/thread/etc that this might be.

     

    Could you post the output of the above?

     

    Kind regards,

    Håkon

  • Thank you, this is the output:

    LR: ncs/v1.9.1/zephyr/include/arch/arm/aarch32/asm_inline_gcc.h:95
    PC: ncs/v1.9.1/zephyr/include/drivers/adc.h:386

    I got R2 hex 0xD this time i ran it, and in the zephyr.map I got 8 occurences for this value:

     .rodata.lwm2m_engine_delete_obj_inst.str1.1
                    0x00000000        0xd zephyr/subsys/net/lib/lwm2m/libsubsys__net__lib__lwm2m.a(lwm2m_engine.c.obj)
                    
    .rodata.str1.1
                    0x00058cf4        0xd zephyr/libzephyr.a(stream_flash.c.obj)
                    
    .rodata.cmd_read.str1.1
                    0x0005d6b3        0xd zephyr/drivers/flash/libdrivers__flash.a(flash_shell.c.obj)
                    
    .rodata.str1.1
                    0x0005da85        0xd modules/nrf/lib/nrf_modem_lib/lib..__nrf__lib__nrf_modem_lib.a(nrf91_sockets.c.obj)
                    
    .rodata.fota_update_counter_update.str1.1
                    0x0005fcbd        0xd modules/nrf/subsys/net/lib/lwm2m_client_utils/lib..__nrf__subsys__net__lib__lwm2m_client_utils.a(settings.c.obj)
                    
    .rodata.str1.1
                    0x00060328        0xe modules/nrf/subsys/net/lib/lwm2m_client_utils/lib..__nrf__subsys__net__lib__lwm2m_client_utils.a(lwm2m_device.c.obj)
                                      0xd (size before relaxing)
                                      
                                      
     .rodata.str1.1
                    0x00060c47        0xd modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a(bootutil_public.c.obj)
                    
    .rodata._dtoa_r.str1.1
                    0x00061de4        0xd c:/Users/Robert/ncs/v1.9.1/toolchain/opt/arm-none-eabi/lib/thumb/v8-m.main/nofp\libc_nano.a(lib_a-dtoa.o)
                                      0xf (size before relaxing)

Reply
  • Thank you, this is the output:

    LR: ncs/v1.9.1/zephyr/include/arch/arm/aarch32/asm_inline_gcc.h:95
    PC: ncs/v1.9.1/zephyr/include/drivers/adc.h:386

    I got R2 hex 0xD this time i ran it, and in the zephyr.map I got 8 occurences for this value:

     .rodata.lwm2m_engine_delete_obj_inst.str1.1
                    0x00000000        0xd zephyr/subsys/net/lib/lwm2m/libsubsys__net__lib__lwm2m.a(lwm2m_engine.c.obj)
                    
    .rodata.str1.1
                    0x00058cf4        0xd zephyr/libzephyr.a(stream_flash.c.obj)
                    
    .rodata.cmd_read.str1.1
                    0x0005d6b3        0xd zephyr/drivers/flash/libdrivers__flash.a(flash_shell.c.obj)
                    
    .rodata.str1.1
                    0x0005da85        0xd modules/nrf/lib/nrf_modem_lib/lib..__nrf__lib__nrf_modem_lib.a(nrf91_sockets.c.obj)
                    
    .rodata.fota_update_counter_update.str1.1
                    0x0005fcbd        0xd modules/nrf/subsys/net/lib/lwm2m_client_utils/lib..__nrf__subsys__net__lib__lwm2m_client_utils.a(settings.c.obj)
                    
    .rodata.str1.1
                    0x00060328        0xe modules/nrf/subsys/net/lib/lwm2m_client_utils/lib..__nrf__subsys__net__lib__lwm2m_client_utils.a(lwm2m_device.c.obj)
                                      0xd (size before relaxing)
                                      
                                      
     .rodata.str1.1
                    0x00060c47        0xd modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a(bootutil_public.c.obj)
                    
    .rodata._dtoa_r.str1.1
                    0x00061de4        0xd c:/Users/Robert/ncs/v1.9.1/toolchain/opt/arm-none-eabi/lib/thumb/v8-m.main/nofp\libc_nano.a(lib_a-dtoa.o)
                                      0xf (size before relaxing)

Children
Related