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

Soft device_enable returns err code 2 .

I have taken ble_app_ancs_c_s130_pca10028 example and modified the application to run on our custom board. The custom board uses NRF51822 (NRF51 IC revision 3). The following two changes were made to the example.

1.change the target to nrf51822. 2.Changed the clock source to RC clock source as follows.

nrf_clock_lf_cfg_t rc_cfg = {

.source = NRF_CLOCK_LF_SRC_RC,
.rc_ctiv = 0, //
.rc_temp_ctiv = 0,
.xtal_accuracy =NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, };

The softdevice_enable function returns err_code 2. I also tried running the example available in nrf51822 example available in github link:

github.com/.../nRF51_SDK_v11
Tools: SDK11
version:2.0.0
softdevice: s130
Kiel version: 5.17
Please let me know what could be the possible reason for the error and how to resolve it.

Parents
  • I checked for the stack overflow error in assembly code, but nothing as such occurs. The reason for the error #2 was, I had by mistake commented the softdevice_handler initialization function, sorry for the confusion.

    Now the error I am facing is error 4 - No Memory for operation, for the below function sd_ble_enable(p_ble_enable_params, &app_ram_base);
    I tried increasing the RAM size to maximum 0x4000, but still I am facing the same error.

    Following is the ble_stack_init function.

    static void ble_stack_init(void) {
    nrf_clock_lf_cfg_t rc_cfg = { .source = NRF_CLOCK_LF_SRC_RC, .rc_ctiv = 0, .rc_temp_ctiv = 0, .xtal_accuracy =NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, }; SOFTDEVICE_HANDLER_INIT(&rc_cfg,NULL);

    ble_enable_params_t ble_enable_params;
    err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT,
                                                    &ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
    ble_enable_params.common_enable_params.vs_uuid_count = VENDOR_SPECIFIC_UUID_COUNT;
    //Check the ram settings against the used number of links
    CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);
    
    // Enable BLE stack.
    err_code = softdevice_enable(&ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    
    // Register with the SoftDevice handler module for System events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    

    }

Reply
  • I checked for the stack overflow error in assembly code, but nothing as such occurs. The reason for the error #2 was, I had by mistake commented the softdevice_handler initialization function, sorry for the confusion.

    Now the error I am facing is error 4 - No Memory for operation, for the below function sd_ble_enable(p_ble_enable_params, &app_ram_base);
    I tried increasing the RAM size to maximum 0x4000, but still I am facing the same error.

    Following is the ble_stack_init function.

    static void ble_stack_init(void) {
    nrf_clock_lf_cfg_t rc_cfg = { .source = NRF_CLOCK_LF_SRC_RC, .rc_ctiv = 0, .rc_temp_ctiv = 0, .xtal_accuracy =NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, }; SOFTDEVICE_HANDLER_INIT(&rc_cfg,NULL);

    ble_enable_params_t ble_enable_params;
    err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT,
                                                    &ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
    ble_enable_params.common_enable_params.vs_uuid_count = VENDOR_SPECIFIC_UUID_COUNT;
    //Check the ram settings against the used number of links
    CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);
    
    // Enable BLE stack.
    err_code = softdevice_enable(&ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    
    // Register with the SoftDevice handler module for System events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    

    }

Children
No Data
Related