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

nrf51822 s130 hardfault error

My old question

SDK: 12.1.0

SOFTDEVICE: s130

CHIP: nrf51822_xxac 256KB flash, 32KB ram

I have used to store application data in flash using sd_flash_write and erase functions.

I get the application data communicating smart phone by ble.

First connection always success in connecting and writing the data in flash.

But, Second connection has always failed writing the data. --> hardfault error occur or stuck somewhere.

so I run gdb. at this error, I get message "Program received signal SIGTRAP, Trace/breakpoint trap.".

pic is info register.

what does mean pc value 0xfffffffe? Is it softdevice error?

this error can be prevented by deleting sd_flash_write and erase functions. so I think this problem is related on flash write and erase functions.

should I use fstorage library?

What should I start with to track my error?

Parents
  • Hi,

    In GDB, try to use "where full" command to get a stack trace. It may show the last function call that caused the hardfault if you're lucky. 

    what does mean pc value 0xfffffffe? Is it softdevice error?

    I'm not sure what it means to be honest. It should have been the address of your hardfault handler. I'd suggest that you read out the flash memory before and after the failure, then compare the content to verify that you haven't erased the application's vector table, etc. 

    Reading memory with nrfjprog:

    nrfjprog --memrd 0x0 --n  0x40000 > flash.txt

  • thanks for your reply! I checked "where full" command.

    why this error occur? It is related on function conn_params_negotiation in on_conn_params_update.

    could you help me track this error?

  • The event value should have been '0'  (BLE_CONN_PARAMS_EVT_FAILED so something is wrong. Did you try to read out flash?

    I guess the function pointer is invalid (m_conn_params_config.evt_handler) since the next frame is at 0x..FF00.  If you want you can try verify this by placing a breakpoint at line 215 in ble_conn_params.c then print out the value.

    1. b ble_conn_params.c:215

    2. print  m_conn_params_config.evt_handler

Reply
  • The event value should have been '0'  (BLE_CONN_PARAMS_EVT_FAILED so something is wrong. Did you try to read out flash?

    I guess the function pointer is invalid (m_conn_params_config.evt_handler) since the next frame is at 0x..FF00.  If you want you can try verify this by placing a breakpoint at line 215 in ble_conn_params.c then print out the value.

    1. b ble_conn_params.c:215

    2. print  m_conn_params_config.evt_handler

Children
  • 212 line in ble_conn_params.c file
    
    // Notify the application that the procedure has succeded
    if (m_conn_params_config.evt_handler != NULL)
    {
        ble_conn_params_evt_t evt;
        evt.evt_type = BLE_CONN_PARAMS_EVT_SUCCEEDED;
        NRF_LOG_RAW_INFO("m_conn_params_config.evt_handler: %X\r\n", (uint32_t) m_conn_params_config.evt_handler);
        NRF_LOG_FLUSH();
        if (m_conn_params_config.evt_handler == (uint32_t*) 0x257A9) {
            m_conn_params_config.evt_handler(&evt);
        }
    }

    I get address of function m_conn_params_config.evt_handler: 0x257A9. To make sure function address I add if statement. but same.

    first connection print debug string "m_conn_params_config.evt_handler: 0x257A9. " two times. but second connection doesn't print anything in ble_conn_params.c file.

    #0 0xfffffffe in ?? ()
    No symbol table info available.
    #1 <signal handler called>
    No symbol table info available.
    #2 0xffffff00 in ?? ()
    No symbol table info available.

    I think.. I have to track these stack address...

    How do you think about?

    and attached flash readout file.

    8712.flash.txt

  • _maibi said:
    I get address of function m_conn_params_config.evt_handler: 0x257A9.

    It looks like a valid address, so my assumption was wrong. Can you upload the flash content before and after the first connection? I.e., a flash dump of when it works, and another when it get the hardfault? 

     

  • very strange behavior. the error suddenly disappear. I just re-compile and test repeatedly.

    I have been making first and second flash dump files. but... this error never happen..  bother me for several days..

    this is related on my old question. only gcc has error but keil. and repeatedly compile with keil. sometimes similar error occur too.

    It is very confusing. Certainly there is a hidden problem.

    Is it possible that something is wrong with using the sd_flash functions?

    Or Could it be a problem caused by a wrong cast?

Related