NordicPlayground / nRF51-ble-bcast-mesh

Other
323 stars 121 forks source link

sd_ble_uuid_vs_add returns NRF_ERROR_INVALID_ADDR #172

Closed tomasra closed 7 years ago

tomasra commented 7 years ago

I'm trying to run BLE_Gateway example on PCA10040 development board using SDK v12.2.0 and S132 v3.0.0 softdevice. After adapting the existing makefile for nRF52, building and flashing the firmware, it ends up in error loop with all board leds being lit.

Debugging showed that sd_ble_uuid_vs_add returns NRF_ERROR_INVALID_ADDR at the following location:

(gdb) bt
#0  sd_ble_uuid_vs_add (p_vs_uuid=0x275f8 <m_mesh_base_uuid>, p_uuid_type=0x20001dcc <m_mesh_base_uuid_type> "")
    at /opt/nRF5_SDK_12.2.0/components/softdevice/s132/headers/ble.h:557
#1  0x00022114 in mesh_gatt_init (access_address=2391391958, channel=38 '&', interval_min_ms=100) at ../../../rbc_mesh/src/mesh_gatt.c:367
#2  0x000204ea in rbc_mesh_init (init_params=...) at ../../../rbc_mesh/src/rbc_mesh.c:139
#3  0x0001fa1a in main () at ../main.c:254

Compiler flags used in makefile and related to this example:

CFLAGS += -D NORDIC_SDK_VERSION=12
CFLAGS += -D RAM_R1_BASE=0x20003000 
CFLAGS += -D NRF_SD_BLE_API_VERSION=3
CFLAGS += $(DEBUG_FLAGS)
CFLAGS += -D NRF52
CFLAGS += -D NRF52832
CFLAGS += -D BLE_STACK_SUPPORT_REQD
CFLAGS += -D S132
CFLAGS += -D SOFTDEVICE_PRESENT
CFLAGS += -D $(TARGET_BOARD)

I tried flashing the provided binary (rbc_gateway_example_serial_nRF52832_xxAA.hex) - this also causes all leds to light up, likely indicating the same issue.

tomasra commented 7 years ago

Turned out that this was caused by default linker script RAM settings adjusted for zero BLE peripherals:

MEMORY
{
  FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000
  RAM (rwx) :  ORIGIN = 0x200019c0, LENGTH = 0xe640 
}

It was solved after setting RAM layout for 1 peripheral link (see app_ram_base.h in SDK):

MEMORY
{
  FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000
  RAM (rwx) :  ORIGIN = 0x200021b8, LENGTH = 0xde48
}