calling sd_ble_gap_whitelist_set crashes my application

working with a nrf52833, soft device 140.


I am trying to setup a whitelist with a known addresses before I start scanning.

I am calling the following code before my main while loop starts but after I enable the SD:

   ret_code_t err_code;
   ble_gap_addr_t whitelist_addrs[2] = {
      {.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC, .addr = {0xE8, 0xEB, 0x1B, 0x93, 0xCD, 0xC2}},
      {.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC, .addr = {0xC2, 0xCD, 0x93, 0x1B, 0xEB, 0xE8}}
  };

  uint32_t addr_count = sizeof(whitelist_addrs) / sizeof(ble_gap_addr_t);
  err_code = c(whitelist_addrs,addr_count );
   APP_ERROR_CHECK(err_code);
with this code my board stops working. after I call this while debugging my application stops functioning. the debugger stops at the following location and I do not get any diagnostics information in the debug termina.



if I sett the second parameter of sd_ble_gap_whitelist_set to 0 I get the "NRF_ERROR_DATA_SIZE" message
if I put an invalid address in the first parameter of sd_ble_gap_whitelist_set I get the "NRF_ERROR_INVALID_ADDR] "
any idea why this would crash my application? is there something that I have not configured?
Parents
  • Hello,

    Segger embedded studio enables a breakpoint on hardfault by default, which causes the program to halt at address 0xA60 in the MBR. You can disable the breakpoint to allow execution to reach the hardfault handler in the application.

    The reason for the fault exception in this cases is that sd_ble_gap_whitelist_set() expects a pointer to an array of pointers to the ble_gap_addr_t structures. Please try with the code below.

        ble_gap_addr_t whitelist_addrs[2] = {
            {.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC, .addr = {0xE8, 0xEB, 0x1B, 0x93, 0xCD, 0xC2}},
            {.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC, .addr = {0xC2, 0xCD, 0x93, 0x1B, 0xEB, 0xE8}}};
    
        
        uint32_t addr_count = sizeof(whitelist_addrs) / sizeof(ble_gap_addr_t);
        
        const ble_gap_addr_t * whitelist_ptrs[] = 
        {
        	&whitelist_addrs[0],
        	&whitelist_addrs[1]
        };  
        
        err_code = sd_ble_gap_whitelist_set(whitelist_ptrs, addr_count);
        APP_ERROR_CHECK(err_code);

    Best regards,

    Vidar

Reply
  • Hello,

    Segger embedded studio enables a breakpoint on hardfault by default, which causes the program to halt at address 0xA60 in the MBR. You can disable the breakpoint to allow execution to reach the hardfault handler in the application.

    The reason for the fault exception in this cases is that sd_ble_gap_whitelist_set() expects a pointer to an array of pointers to the ble_gap_addr_t structures. Please try with the code below.

        ble_gap_addr_t whitelist_addrs[2] = {
            {.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC, .addr = {0xE8, 0xEB, 0x1B, 0x93, 0xCD, 0xC2}},
            {.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC, .addr = {0xC2, 0xCD, 0x93, 0x1B, 0xEB, 0xE8}}};
    
        
        uint32_t addr_count = sizeof(whitelist_addrs) / sizeof(ble_gap_addr_t);
        
        const ble_gap_addr_t * whitelist_ptrs[] = 
        {
        	&whitelist_addrs[0],
        	&whitelist_addrs[1]
        };  
        
        err_code = sd_ble_gap_whitelist_set(whitelist_ptrs, addr_count);
        APP_ERROR_CHECK(err_code);

    Best regards,

    Vidar

Children
No Data
Related