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

sd_ble_gap_device_identities_set hardfault

SDK15.0 whitelist hardfault

when setting the sd_ble_gap_device_identities_set using the iOS nrfConnect the non DK board hardfaults.

On an android device all works fine.

Any ideas of where to start.  The whitelist code from the PM_EVT_PEER_DATA_UPDATE_SUCCEEDED event is straight out of ble_peripheral_hids_keyboard.

static uint32_t          m_whitelist_peer_cnt = 0;                      /**< Number of peers currently in the whitelist. */
static pm_peer_id_t      m_whitelist_peers[1];                       /**< List of peers currently in the whitelist. */

                if ((p_evt->params.peer_data_update_succeeded.flash_changed)
                        && (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING))
                {
                    //NRF_LOG_WARNING("New Bond, add the peer to the whitelist if possible");
                    //NRF_LOG_WARNING("\tm_whitelist_peer_cnt %d, MAX_PEERS_WLIST %d", m_whitelist_peer_cnt + 1, NRF_SDH_BLE_PERIPHERAL_LINK_COUNT);
                    // Note: You should check on what kind of white list policy your application should use.
                    if (m_whitelist_peer_cnt < 1)
                    {
                            // Bonded to a new peer, add it to the whitelist.
                            m_whitelist_peers[m_whitelist_peer_cnt++] = p_evt->peer_id;

                            // The whitelist has been modified, update it in the Peer Manager.
                            err_code = pm_device_identities_list_set(m_whitelist_peers, m_whitelist_peer_cnt);
                            if (err_code != NRF_ERROR_NOT_SUPPORTED)
                            {
                                APP_ERROR_CHECK(err_code);
                            }

                            err_code = pm_whitelist_set(m_whitelist_peers, m_whitelist_peer_cnt);
                            APP_ERROR_CHECK(err_code);
                    }
                }

I am looking thru the iOS Accessory Design guildelines and can not find a reason as to what I need to be looking at

Thanks for any help you might give.

Parents Reply Children
  • Hi,

    You need to set HARDFAULT_HANDLER_ENABLED to 1 in sdk_config.h, and define DEBUG and DEBUG_NRF in your Makefile. You also need to add hardfault_handler_gcc.c in addition to hardfault_implementation.c. Then enable logging if you have not, and you should get a printout similar to this:

    <error> hardfault: HARD FAULT at 0x00031CC4
    <error> hardfault:   R0:  0x00050003  R1:  0xE000E100  R2:  0x00100000  R3:  0xBADEBA11
    <error> hardfault:   R12: 0xFFFFFFFF  LR:  0x00028165  PSR: 0x01000000
    <error> hardfault: Cause: Data bus error (PC value stacked for the exception return points to the instruction that caused the fault).
    <error> hardfault: Bus Fault Address: 0xBADEBA11

    Looking at the PC from the output from when you called "nrfjprog --readregs" it seems the PC is within the application (0x0003C11A is above the SoftDevice). What is there if you check the .mapfile or check with arm-none-eabi-addr2line?

Related