sd_softdevice_enable returns nothing

Hi Guys,

I know there are a lot if topicks about issue with "sd_softdevice_enable". I read them all and nothing help me. I'm using Eclipse IDE.

Im using a nRF52840-DK, pca10056

First I program the softdevice (S140) using nRFgo Studio and then debug in eclipse.

This is my debug config:

Linker File:

/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xda000
  RAM (rwx) :  ORIGIN = 0x200022e0, LENGTH = 0x3dd20
}

GROUP (
    libc_nano.a
    libm.a
    libgcc.a
)

_eheap = ORIGIN(RAM) + LENGTH(RAM) - 4;

SECTIONS
{
  .fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } > RAM
} INSERT AFTER .data;
SECTIONS
{
  .pwr_mgmt_data :
  {
    PROVIDE(__start_pwr_mgmt_data = .);
    KEEP(*(SORT(.pwr_mgmt_data*)))
    PROVIDE(__stop_pwr_mgmt_data = .);
  } > FLASH
  .rodata.host_cmd_handlers : ALIGN(4)
  {
    __host_cmd_handlers_start = .;
    KEEP(*(.host_cmd_handlers))/* Host command handlers section */
    __host_cmd_handlers_end = .;
  } >FLASH
} INSERT AFTER .text
SECTIONS
{
  . = ALIGN(4);
  .mem_section_dummy_ram :
  {
  }
  .cli_sorted_cmd_ptrs :
  {
    PROVIDE(__start_cli_sorted_cmd_ptrs = .);
    KEEP(*(.cli_sorted_cmd_ptrs))
    PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
  } > RAM
  .fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } > RAM
  .log_dynamic_data :
  {
    PROVIDE(__start_log_dynamic_data = .);
    KEEP(*(SORT(.log_dynamic_data*)))
    PROVIDE(__stop_log_dynamic_data = .);
  } > RAM
  .log_filter_data :
  {
    PROVIDE(__start_log_filter_data = .);
    KEEP(*(SORT(.log_filter_data*)))
    PROVIDE(__stop_log_filter_data = .);
  } > RAM
} INSERT AFTER .data;

SECTIONS
{
  .mem_section_dummy_rom :
  {
  }
  .sdh_ble_observers :
  {
    PROVIDE(__start_sdh_ble_observers = .);
    KEEP(*(SORT(.sdh_ble_observers*)))
    PROVIDE(__stop_sdh_ble_observers = .);
  } > FLASH
  .sdh_soc_observers :
  {
    PROVIDE(__start_sdh_soc_observers = .);
    KEEP(*(SORT(.sdh_soc_observers*)))
    PROVIDE(__stop_sdh_soc_observers = .);
  } > FLASH
  .sdh_req_observers :
  {
    PROVIDE(__start_sdh_req_observers = .);
    KEEP(*(SORT(.sdh_req_observers*)))
    PROVIDE(__stop_sdh_req_observers = .);
  } > FLASH
  .sdh_state_observers :
  {
    PROVIDE(__start_sdh_state_observers = .);
    KEEP(*(SORT(.sdh_state_observers*)))
    PROVIDE(__stop_sdh_state_observers = .);
  } > FLASH
  .sdh_stack_observers :
  {
    PROVIDE(__start_sdh_stack_observers = .);
    KEEP(*(SORT(.sdh_stack_observers*)))
    PROVIDE(__stop_sdh_stack_observers = .);
  } > FLASH
  .nrf_queue :
  {
    PROVIDE(__start_nrf_queue = .);
    KEEP(*(.nrf_queue))
    PROVIDE(__stop_nrf_queue = .);
  } > FLASH
    .cli_command :
  {
    PROVIDE(__start_cli_command = .);
    KEEP(*(.cli_command))
    PROVIDE(__stop_cli_command = .);
  } > FLASH
  .crypto_data :
  {
    PROVIDE(__start_crypto_data = .);
    KEEP(*(SORT(.crypto_data*)))
    PROVIDE(__stop_crypto_data = .);
  } > FLASH
  .pwr_mgmt_data :
  {
    PROVIDE(__start_pwr_mgmt_data = .);
    KEEP(*(SORT(.pwr_mgmt_data*)))
    PROVIDE(__stop_pwr_mgmt_data = .);
  } > FLASH
  .log_const_data :
  {
    PROVIDE(__start_log_const_data = .);
    KEEP(*(SORT(.log_const_data*)))
    PROVIDE(__stop_log_const_data = .);
  } > FLASH
  .log_backends :
  {
    PROVIDE(__start_log_backends = .);
    KEEP(*(SORT(.log_backends*)))
    PROVIDE(__stop_log_backends = .);
  } > FLASH
    .nrf_balloc :
  {
    PROVIDE(__start_nrf_balloc = .);
    KEEP(*(.nrf_balloc))
    PROVIDE(__stop_nrf_balloc = .);
  } > FLASH
} INSERT AFTER .text

INCLUDE "nrf52_common.ld"

Make file:

CPU = cortex_m4
LOG := itm

  
CFLAGS +=\
	-mcpu=cortex-m4\
	-mthumb -mabi=aapcs\
 	-ffunction-sections -fdata-sections -fno-strict-aliasing\
 	-fno-builtin --short-enums \
	-Wno-expansion-to-defined \
	-Wno-unused-parameter

# SDK definitions
CFLAGS +=\
	-DBOARD_PCA10056\
	-DCONFIG_GPIO_AS_PINRESET\
	-DNRF52840_XXAA\
	-D__STARTUP_CONFIG \
 	-DMALLOC_PROVIDED \
 	-DFPC_MALLOC \
 	-DBSP_SIMPLE \
 	-Wa,--defsym,_STARTUP_CONFIG=1 \
 	-DUART_CMDS \

CFLAGS +=\
	-DUSE_HAL_DRIVER \
	-DARM_MATH_CM4\
	-MP -MD

# Define FS storage type: RAM_STORAGE or NVM_STORAGE
CFLAGS +=\
    -DRAM_STORAGE

NHAL := $(DEPTH)../hal/nordic
SDK_ROOT := $(NHAL)/sdk

# Linker flags
LDFILE = $(NHAL)/spi_gcc_nrf52.ld
TEMPLATE_PATH := $(SDK_ROOT)/modules/nrfx/mdk

LDFLAGS += -T $(LDFILE) -L $(TEMPLATE_PATH)

LDLAGS +=\
    -mthumb -mabi=aapcs\
	-mcpu=cortex-m4\
	-L $(TEMPLATE_PATH) 

LDFLAGS +=\
	-lc -lgcc \

AR_LIBS +=\
	$(NHAL)/CMSIS/dsp/GCC/libarm_cortexM4lf_math.a 

HAL_SRCS += \
  $(SDK_ROOT)/components/boards/boards.c \
  $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_rtt.c \
  $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
  $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_uart.c \
  $(SDK_ROOT)/components/libraries/log/src/nrf_log_default_backends.c \
  $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
  $(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \
  $(SDK_ROOT)/components/libraries/button/app_button.c \
  $(SDK_ROOT)/components/libraries/util/app_error.c \
  $(SDK_ROOT)/components/libraries/util/app_error_handler_gcc.c \
  $(SDK_ROOT)/components/libraries/util/app_error_weak.c \
  $(SDK_ROOT)/components/libraries/util/app_util_platform.c \
  $(SDK_ROOT)/components/libraries/util/nrf_assert.c \
  $(SDK_ROOT)/components/libraries/fifo/app_fifo.c \
  $(SDK_ROOT)/components/libraries/uart/app_uart_fifo.c \
  $(SDK_ROOT)/components/libraries/scheduler/app_scheduler.c \
  $(SDK_ROOT)/components/libraries/timer/app_timer.c \
  $(SDK_ROOT)/components/libraries/atomic/nrf_atomic.c \
  $(SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \
  $(SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \
  $(SDK_ROOT)/components/libraries/ringbuf/nrf_ringbuf.c \
  $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \
  $(SDK_ROOT)/components/libraries/bsp/bsp.c \
  $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_spi.c \
  $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_uart.c \
  $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_gpiote.c \
  $(SDK_ROOT)/modules/nrfx/drivers/src/prs/nrfx_prs.c \
  $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_spi.c \
  $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_spim.c \
  $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uart.c \
  $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c \
  $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_timer.c \
  $(SDK_ROOT)/modules/nrfx/soc/nrfx_atomic.c \
  $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52840.c \
  $(SDK_ROOT)/modules/nrfx/hal/nrf_nvmc.c \
  $(SDK_ROOT)/external/fprintf/nrf_fprintf.c \
  $(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \
  $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
  $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
  $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
  $(SDK_ROOT)/components/ble/ble_services/ble_lbs/ble_lbs.c \
  $(SDK_ROOT)/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c \
  $(SDK_ROOT)/components/ble/nrf_ble_gatt/nrf_ble_gatt.c \
  $(SDK_ROOT)/components/ble/nrf_ble_qwr/nrf_ble_qwr.c \
  $(SDK_ROOT)/components/ble/common/ble_advdata.c \
  $(SDK_ROOT)/components/ble/common/ble_srv_common.c \
  $(SDK_ROOT)/components/ble/common/ble_conn_params.c \
  $(SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \
  $(SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \
  $(SDK_ROOT)/components/softdevice/common/nrf_sdh.c \
  $(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \
  $(SDK_ROOT)/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c \
#  $(PROJ_DIR)/main.c \
   	  
VPATH += $(dir $(HAL_SRCS))
C_SRCS += $(notdir $(HAL_SRCS))

# Source Folders
VPATH += $(NHAL)/src/

# C Sources
C_SRCS += $(notdir $(wildcard $(NHAL)/src/*.c))

# S Sources
S_SRCS += $(NHAL)/src/gcc_startup_nrf52840.S 

# Includes
C_INC +=\
	-I$(NHAL)/config \
	-I$(NHAL)/inc \
	-I$(NHAL)/CMSIS/Include \
	-I$(DEPTH)../bep_lib/req_interface/inc \
	-I$(DEPTH)../bep_lib/inc \
	-I$(SDK_ROOT)/components \
	-I$(SDK_ROOT)/components/libraries/scheduler \
	-I$(SDK_ROOT)/components/libraries/timer \
	-I$(SDK_ROOT)/components/libraries/strerror \
	-I$(SDK_ROOT)/components/toolchain/cmsis/include \
	-I$(SDK_ROOT)/components/libraries/util \
	-I$(SDK_ROOT)/components/libraries/balloc \
	-I$(SDK_ROOT)/components/libraries/ringbuf \
	-I$(SDK_ROOT)/components/libraries/fifo \
	-I$(SDK_ROOT)/components/libraries/bsp \
	-I$(SDK_ROOT)/components/libraries/log \
	-I$(SDK_ROOT)/components/libraries/uart \
	-I$(SDK_ROOT)/components/libraries/button \
	-I$(SDK_ROOT)/components/libraries/delay \
	-I$(SDK_ROOT)/components/libraries/experimental_section_vars \
	-I$(SDK_ROOT)/integration/nrfx/legacy \
	-I$(SDK_ROOT)/components/libraries/delay \
	-I$(SDK_ROOT)/integration/nrfx \
	-I$(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \
	-I$(SDK_ROOT)/external/segger_rtt \
	-I$(SDK_ROOT)/components/boards \
	-I$(SDK_ROOT)/components/libraries/memobj \
	-I$(SDK_ROOT)/modules/nrfx/drivers/include \
	-I$(SDK_ROOT)/components/libraries/log/src \
	-I$(SDK_ROOT)/external/fprintf \
	-I$(SDK_ROOT)/components/libraries/atomic \
	-I$(SDK_ROOT)/modules/nrfx \
	-I$(SDK_ROOT)/modules/nrfx/hal \
	-I$(SDK_ROOT)/modules/nrfx/mdk \
	-I$(SDK_ROOT)/components/softdevice/s140/headers \
	-I$(SDK_ROOT)/components/softdevice/common \
	-I$(SDK_ROOT)/components/ble/common \
	-I$(SDK_ROOT)/components/ble/ble_services/ble_lbs \
	-I$(SDK_ROOT)/components/ble/nrf_ble_gatt \
	-I$(SDK_ROOT)/components/ble/nrf_ble_qwr \
	-I$(SDK_ROOT)/components/libraries/pwr_mgmt \
	-I$(SDK_ROOT)/components/libraries/mutex \
	-I$(SDK_ROOT)/components/libraries/hardfault \
	-I$(SDK_ROOT)/components/libraries/hardfault/nrf52/handler \

Clock config

And this is where it just restarts

I there a way find out whats returning??

Parents
  • Hi,

    The typical reason for sd_softdevice_enable() should normally always return except if you configure it to use a 32.768 kHz crystal but that is not present on the board. As you write that you use a DK that should not be a problem, though, as all DKs have the crystal.

    And this is where it just restarts

    Do you men that the device resets, and not just that sd_softdevice_enable() never returns? If so, something must be causing the reset. Do you for instance have an error or assert handler that runs, which does a soft reset?

    PS: You can upload images here using Insert -> Image/video/file, so there is no need to use an external service for that.

Reply
  • Hi,

    The typical reason for sd_softdevice_enable() should normally always return except if you configure it to use a 32.768 kHz crystal but that is not present on the board. As you write that you use a DK that should not be a problem, though, as all DKs have the crystal.

    And this is where it just restarts

    Do you men that the device resets, and not just that sd_softdevice_enable() never returns? If so, something must be causing the reset. Do you for instance have an error or assert handler that runs, which does a soft reset?

    PS: You can upload images here using Insert -> Image/video/file, so there is no need to use an external service for that.

Children
  • I have placed multiple breakpoints to get more info but the code just doesn't go pass sd_softdevice_enable(), the just

    restarts and gets back to ble_stack_init()

    Could it be that I also have to program the softdevice when debugging?

    or is it okay to just do it before?

  • ArshKhan said:
    Could it be that I also have to program the softdevice when debugging?

    Programming the SoftDevice from before is no problem, as long as it (or parts of it) is not deleted when you program/start debugging the application.

    I am not familiar with using Eclipse as IDE in this context, and that is highly configurable so I cannot say how this works on your end or how you have configured it. One thing which sometimes cause problems when using unsupported IDEs / debuggers is that the default configuration is sometimes to start execution at the start address of the application, and not address 0. Could that be the case here? it is key that execution starts form address 0, to initialize the MBR and SoftDevice, even though your app starts at a different address (right after the SoftDevice).

Related