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

HardFault on sd_ble_gap_device_name_set call on custom nrf51822 board

Hi,

I've developed an application and tested it on the evaluation kit. Now i'm trying to run it on a custom board with a nrf51822 chip on it. I've made modifications to exclude evaluation board specific code - removed any boards.h peripheral usage and changed the clock argument of SOFTDEVICE_HANDLER_INIT to the internal RC NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION enum.

Now when I debug the program(after the softdevice is programmed with nrfgo), it runs up to sd_ble_gap_device_name_set function call and then goes to hard fault handler. What could the problem be? The same code ran perfectly on a 10001 evaluation board.

The relevant gap parameter init snippet:

 uint32_t                err_code;
    ble_gap_conn_params_t   gap_conn_params;
    ble_gap_conn_sec_mode_t sec_mode;

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

    err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)DEVICE_NAME, strlen(DEVICE_NAME));
  • Hi Dmitri,

    How did you debug the application ? You would not be able to step walk through the code since the softdevice activity is not halted by the debugger.

    What you should do is to add a break point in the assert handler, and check for the error code and line, file name that cause the issue.

  • I debug the application through the SWD interface with a SEGGER J-Link Edu. I do have breakpoints in the error handlers, but none of them get activated. A step from the device_name_set function leaves the debugger running without activating any breakpoints and only once i press stop do i see that the program is in the hard fault handler.

    I've done some more testing and it seems that if i put breakpoints and press "run" in the debugger instead of any steps the program does seem to get further in before the hardfault handler kicks in(until the main idle loop even).

Related