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

sd_ble_uuid_vs_add () returns err_code = 16 (#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address)

Hi, I am using nRF52832 with S132 softdevice and SDK version 11. I am getting bad memory address error code.

err_code = sd_ble_uuid_vs_add (&base_uuid, &ble_service->uuid_type);
if (err_code != NRF_SUCCESS){
SEGGER_RTT_printf(0, "err_code: %d \n", err_code);
return err_code;
}

Can anybody help me to figure out what could be the reason for such errors? Thank!

  • My best guesses would be that one or both of the parameters to sd_ble_uuid_vs_add is either NULL, or it is not 4 byte aligned. Easy enough to tell if you add the addresses to your SEGGER printf.

  • Thanks John for the comment, I defined base uuid like this

     #define BLE_UUID_BASE_UUID            		{0x5B, 0xB3, 0x03, 0x64, 0x0C, 0x16, 0x5D, 0x8A, 0x1B, 0x48, 0x84, 0x63, 0x00, 0x00, 0x1F, 0xC0} // 128-bit base UUID
    

    then in service.c file,

    ble_uuid128_t base_uuid = {BLE_UUID_BASE_UUID};
    

    When printed out uuid_type

    SEGGER_RTT_printf(0, "uuid_type: %d \n", ble_service->uuid_type); 
    

    I got uuid_type 0, it means invalid UUID type.

    #define BLE_UUID_TYPE_UNKNOWN       0x00 /**< Invalid UUID type. */
    

    What else could you guess? Do you need any more info? Thank you very much for your time.

  • Easy enough to tell if you add the addresses to your SEGGER printf What do you mean by this, base_uuid? or the address where this base uuid is getting stored

  • I was thinking you could show the two addresses being passed to sd_ble_uuid_vs_add like this:

    SEGGER_RTT_printf(0, "base_uuid addr = %x, ble_service addr = %x\n", &base_uuid, &ble_service);

  • Okay, hey I want to bring one more info, that may help you to understand the problem. I am not able to step into gap_params_init();. main() look likes this

    ble_stack_init();
      device_manager_init(true);
      gap_params_init();
      services_init();
      advertising_init();
      conn_params_init();
      // Start execution.
      err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
      APP_ERROR_CHECK(err_code);
    

    and gap_params_init()

    static void gap_params_init(void)
    {
        uint32_t                err_code;
        ble_gap_conn_params_t   gap_conn_params;  	        // Struct to store GAP connection parameters like max min connection interval etc
        ble_gap_conn_sec_mode_t sec_mode;     		// Struct to store security parameters
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
    
        // Store the device name and security mode in the SoftDevice. Our name is defined to "HelloWorld" in the beginning of this file
        err_code = sd_ble_gap_device_name_set(&sec_mode,
                                              (const uint8_t *)DEVICE_NAME,
                                              strlen(DEVICE_NAME));
        APP_ERROR_CHECK(err_code); // Check for errors
    
        // Always initialize all fields in structs to zero or you might get unexpected behaviour
        memset(&gap_conn_params, 0, sizeof(gap_conn_params));
    
        // Populate the GAP connection parameter struct
        gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
        gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
        gap_conn_params.slave_latency     = SLAVE_LATENCY;
        gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;
    
        // Set GAP Peripheral Preferred Connection Parameters
        // The device use these prefered values when negotiating connection terms with another device
        err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
        APP_ERROR_CHECK(err_code);
                                              
        // Set appearence                     
        sd_ble_gap_appearance_set(0);
        APP_ERROR_CHECK(err_code);                                          
    }
    

    As you asked in your last comment base_uuid address is 20002FBC. I can't tell you ble_service_uuid because I can't reach to that part of code, debugger stopped.

Related