sd_softdevice_enable() Returns Error Code 8 (NRF_ERROR_INVALID_STATE)

I am currently developing firmware on Qorvo's DWM3001C module, which integrates the Nordic nRF52833. I am using nRF5 SDK 17.1.0 and the SoftDevice S140.

My base project (provided by Qorvo) works correctly without BLE functionality. However, after integrating BLE by adding ble_stack_init() at the very beginning of main(), the call to:

ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler);

inside nrf_sdh_enable_request() returns error code 8, which corresponds to NRF_ERROR_INVALID_STATE.

I have confirmed the following:

  • ble_stack_init() is the first function in main() – no other initialization happens before this call.

  • SoftDevice has been correctly flashed using nrfjprog.

  • The project uses the correct SoftDevice for the nRF52833 (S140 v7.2.0).

  • The application ran fine before adding BLE functionality.

  • Clock configuration appears valid.

  • Flash and RAM are allocated properly for the SoftDevice (e.g., FLASH_START = 0x27000, RAM_START = 0x20002AE8).

  • The issue persists even with the logging system disabled.

  • SDK configuration file sdk_config.h has been tailored for BLE and SoftDevice usage.

Attached: My sdk_config.h file for your review.

Given that BLE initialization is the first step in main() and all memory and SoftDevice flashing procedures appear correct, what could be the likely causes for sd_softdevice_enable() to return NRF_ERROR_INVALID_STATE (8) in this scenario?

Any guidance or suggestions for additional checks would be greatly appreciated. Thank you very much.

3377.sdk_config.zip

Parents
  • Error code says SD was already enabled.

    Maybe you have another code path that enabled it, maybe you have a bootloader present that forgot to disable SD before switching to the app.

  • Thank you for the answer. Just want to add that this can also happen if the debugger forces execution to start at FLASH_START instead of address 0x0. This leads to the Softdevice not being initialized on startup, thus not being in a valid state when the app tries to enable it. Do you see the same error if you reset the board (power cycle or pin reset)?

  • I am not using a bootloader, and I have already implemented a check to ensure that the SoftDevice is only enabled once:

    if (!nrf_sdh_is_enabled()) { NRF_LOG_INFO("Enabling SoftDevice..."); err_code = nrf_sdh_enable_request(); APP_ERROR_CHECK(err_code); } else { NRF_LOG_WARNING("SoftDevice already enabled"); }

    Despite this, the issue still persists.
    Even after a full power cycle, the same behavior occurs — the call to sd_softdevice_enable() returns NRF_ERROR_INVALID_STATE (8).

    I've double-checked all memory and clock configurations, and ensured that BLE initialization happens at the very start of main(), before any other modules are initialized.

    At this point, I'm sincerely out of ideas.
    Is there any other reason that could cause this error under these conditions?

    Any insight or guidance would be deeply appreciated. I'm truly desperate to resolve this.

    Thank you

  • Can you provide a minimal version of your project that would allow me to reproduce the problem here? 

  • I sincerely apologize for the delayed response as I was on personal leave. Attached is the project I am currently testing. I would appreciate it if you could review it and provide your feedback. Thank you very much for your continued support.

Reply Children
Related