Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

crash in ble_template_app (from nRF5 SDK 15.0.0)


I've installed the ble_template_app on the nrf52832DK and the nrf52840PDK and the Adafruit nrf52 Feather (almost the same as the nrf52832DK). I've modified the configuration enough to have Segger RTT logging enabled, but no changes to main.

I'm seeing the application run for a while (30 seconds to a handful of minutes) and then an "app: Fatal error" log message comes across the console . At that point, there's no interaction with the device available (I'm using the LightBlue Explorer too). Hit the reset button - starts over as I'd expect and then the same thing will happen.

The boards will crash whether or not I connect to them. I don't see any particular pattern of crashing a consistent time after a connect or disconnect event (which I see in the logs).

The stacktrace of the crash (captured in GDB) also seems odd to me:

#0 app_error_fault_handler (id=id@entry=16385, pc=pc@entry=0, info=info@entry=536935940)
at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_weak.c:56
#1 0x000273f0 in app_error_handler_bare (error_code= )
at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error.c:73
#2 0x0002d69e in ble_advertising_start (p_advertising=0x20002d78 ,
advertising_mode= )
at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/ble/ble_advertising/ble_advertising.c:663
#3 0x0002d8b2 in on_terminated (p_ble_evt= , p_ble_evt= ,
p_advertising=0x20002d78 )
at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/ble/ble_advertising/ble_advertising.c:146
#4 ble_advertising_on_ble_evt (p_ble_evt= , p_context=0x20002d78 )
at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/ble/ble_advertising/ble_advertising.c:687
#5 0x00031ad6 in nrf_sdh_ble_evts_poll (p_context= )
at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/softdevice/common/nrf_sdh_ble.c:307
#6 0x00031a82 in nrf_sdh_evts_poll ()
at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/softdevice/common/nrf_sdh.c:386
#7 SWI2_EGU2_IRQHandler ()
at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/softdevice/common/nrf_sdh.c:395
#8 0xffffffe8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

How does the app_error_handler get called from this code (file nRF5_SDK_15.0.0_a53641a/components/ble/ble_advertising/ble_advertising.c)

661 if (p_advertising->evt_handler != NULL)
662 {
663 p_advertising->evt_handler(p_advertising->adv_evt);
664 }

Parents
  • Hi David,

    Could you turn off Optimization and define DEBUG then post your RTT log. (also described here)

  • I removed -O3, added -DDEBUG.   Here's the RTT log

    <info> app: Debug logging for UART over RTT started.
    <error> app: ERROR 8198 [Unknown error code] at ../../../main.c:323
    PC at: 0x0002E7E5
    <error> app: End of error report

    and the results in the debugger:

    Breakpoint 1, app_error_fault_handler (id=16385, pc=190437, info=536935544)
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_weak.c:57
    57	    __disable_irq();
    (gdb) where
    #0  app_error_fault_handler (id=16385, pc=190437, info=536935544)
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_weak.c:57
    #1  0x00027950 in app_error_handler (error_code=16385, line_num=190437, p_file_name=0x2000fc78 "C\001")
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_handler_gcc.c:49
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)
    (gdb) list
    52	 * Function is implemented as weak so that it can be overwritten by custom application error handler
    53	 * when needed.
    54	 */
    55	__WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    56	{
    57	    __disable_irq();
    58	    NRF_LOG_FINAL_FLUSH();
    59	
    60	#ifndef DEBUG
    61	    NRF_LOG_ERROR("Fatal error");
    (gdb) p/x id
    $10 = 0x4001
    (gdb) p/x pc
    $11 = 0x2e7e5
    (gdb) p/x info
    $12 = 0x2000fc78
    (gdb) up
    #1  0x00027950 in app_error_handler (error_code=16385, line_num=190437, p_file_name=0x2000fc78 "C\001")
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_handler_gcc.c:49
    49	    __ASM volatile(
    (gdb) list
    44	#if defined (__CORTEX_M) && (__CORTEX_M == 0x04)
    45	void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) __attribute__(( naked ));
    46	
    47	void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name)
    48	{
    49	    __ASM volatile(
    50	
    51	    "push {lr}                      \n"
    52	
    53	    /* reserve space on stack for error_info_t struct - preserve 8byte stack aligment */
    (gdb) p error_code
    $13 = 16385
    (gdb) p line_num
    $14 = 190437
    (gdb) p *p_file_name
    $15 = 67 'C'
    (gdb) p p_file_name
    $16 = (const uint8_t *) 0x2000fc78 "C\001"
    (gdb) cont
    Continuing.
    
    Program received signal SIGTRAP, Trace/breakpoint trap.
    0x00027a62 in app_error_fault_handler (id=16385, pc=190437, info=536935544)
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_weak.c:99
    99	    NRF_BREAKPOINT_COND;
    (gdb) 
    

Reply
  • I removed -O3, added -DDEBUG.   Here's the RTT log

    <info> app: Debug logging for UART over RTT started.
    <error> app: ERROR 8198 [Unknown error code] at ../../../main.c:323
    PC at: 0x0002E7E5
    <error> app: End of error report

    and the results in the debugger:

    Breakpoint 1, app_error_fault_handler (id=16385, pc=190437, info=536935544)
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_weak.c:57
    57	    __disable_irq();
    (gdb) where
    #0  app_error_fault_handler (id=16385, pc=190437, info=536935544)
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_weak.c:57
    #1  0x00027950 in app_error_handler (error_code=16385, line_num=190437, p_file_name=0x2000fc78 "C\001")
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_handler_gcc.c:49
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)
    (gdb) list
    52	 * Function is implemented as weak so that it can be overwritten by custom application error handler
    53	 * when needed.
    54	 */
    55	__WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    56	{
    57	    __disable_irq();
    58	    NRF_LOG_FINAL_FLUSH();
    59	
    60	#ifndef DEBUG
    61	    NRF_LOG_ERROR("Fatal error");
    (gdb) p/x id
    $10 = 0x4001
    (gdb) p/x pc
    $11 = 0x2e7e5
    (gdb) p/x info
    $12 = 0x2000fc78
    (gdb) up
    #1  0x00027950 in app_error_handler (error_code=16385, line_num=190437, p_file_name=0x2000fc78 "C\001")
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_handler_gcc.c:49
    49	    __ASM volatile(
    (gdb) list
    44	#if defined (__CORTEX_M) && (__CORTEX_M == 0x04)
    45	void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) __attribute__(( naked ));
    46	
    47	void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name)
    48	{
    49	    __ASM volatile(
    50	
    51	    "push {lr}                      \n"
    52	
    53	    /* reserve space on stack for error_info_t struct - preserve 8byte stack aligment */
    (gdb) p error_code
    $13 = 16385
    (gdb) p line_num
    $14 = 190437
    (gdb) p *p_file_name
    $15 = 67 'C'
    (gdb) p p_file_name
    $16 = (const uint8_t *) 0x2000fc78 "C\001"
    (gdb) cont
    Continuing.
    
    Program received signal SIGTRAP, Trace/breakpoint trap.
    0x00027a62 in app_error_fault_handler (id=16385, pc=190437, info=536935544)
        at /Users/zoo/Programming/nordic/SDK/nRF5_SDK_15.0.0_a53641a/components/libraries/util/app_error_weak.c:99
    99	    NRF_BREAKPOINT_COND;
    (gdb) 
    

Children
No Data
Related