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

Migrating to SDK15, crashing at advertising_init()

I'm trying to migrate from SDK12 to SDK15, but my code always crashes at advertising_init() and goes to NRF_BREAKPOINT_COND. Even when I directly use the example from the service tutorial https://devzone.nordicsemi.com/tutorials/b/bluetooth-low-energy/posts/ble-services-a-beginners-tutorial. I'm wondering what's the issue in this case?

Also how do I define DEBUG here? I added CFLAGS += DDEBUG in makefile, but it didn't trigger the switch error ID part in app_error_default_handler function in app_error_weak.c.

I'm using Eclipse with both DK52 and DK52840. Any help is appreciated. Thanks.

Parents Reply
  • Try CFLAGS += -DDEBUG

    Yes, I'm using this. I missed - in my typing.

    Also remove compiler optimization (to get expected debug results), OPT = -O0 -g3 , CFLAGS += $(OPT)

    I see OPT = -O3 -g3 and CFLAGS += $(OPT) in the makefile. Should I comment them out? It doesn't seem to run through after commenting out, it shows No source available for "main() at 0x30f62"

    Try commenting out that line, //NRF_BREAKPOINT_COND;

    There is no stopping at app_error_weak any more, but I couldn't find the device on my phone. Probably there is still error?

Children
  • xhr0428 said:
    Should I comment them out?

    No,  change OPT = -O3 -g3 to OPT = -O0 -g3 

    xhr0428 said:
    There is no stopping at app_error_weak any more, but I couldn't find the device on my phone. Probably there is still error?

     Do you have logging enabled? (NRF_LOG_ENABLED 1 in sdk_config.h), with either UART or Segger RTT backend(NRF_LOG_BACKEND_UART_ENABLED,NRF_LOG_BACKEND_RTT_ENABLED ) ?

    Then the error code will be printed over the enabled backend.

    If it's not being printed, let the code run, and read out the CPU register values with nrfjprog --readregs

  • There is printout. It's Error 4 [NRF_ERROR_NO_MEM] at sd_ble_gatts_service_add. 

  • Ok, then try to increase the value of NRF_SDH_BLE_VS_UUID_COUNT in sdk_config.h

    If that does not work, then try to increase NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE in sdk_config.h

    Note that when you do these changes, you will likely need to allocate more RAM to the SoftDevice.

  • I changed NRF_SDH_BLE_VS_UUID_COUNT to 1.

    NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE is 1408 by itself. What size should I use for it?

    Here is the error message I see now.

    0> <warning> nrf_sdh_ble: Insufficient RAM allocated for the SoftDevice.
    0> <warning> nrf_sdh_ble: Change the RAM start location from 0x20002218 to 0x20002220.
    0> <warning> nrf_sdh_ble: Maximum RAM size for application is 0xDDE0.
    0> <error> nrf_sdh_ble: sd_ble_enable() returned NRF_ERROR_NO_MEM.
    0> <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at ../../../main.c:570
    0> PC at: 0x00030D29
    0> <error> app: End of error report

  • Now you need to allocate more RAM to the SoftDevice. You can change this in the linker file (.ld). You can find this file in the same folder as the makefile.

    You should change it, so you have the following:

    MEMORY
    {
    FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000
    RAM (rwx) : ORIGIN = 0x20002220, LENGTH = 0xDDE0
    }

Related