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

Hard fault when adding service UUID to softdevice S132

Hi, I get a hard fault when I try to add an own UUID to the softdevice S132. I'm using Eclipse with GCC compiler, Rigado BMD350 eval board with the nRF52832 chip on it. As project template I use the ble_peripherals_template from the SDK 14.2.0 and went through the beginners tutorial BLE services.

When I add the own_service_init function in the service_init in main.c (see the tutorial) the controller runs into hard fault. Without the own_service routine the device connects perfectly to a cell phone. I debugged it with the debugger on the eval board and I can run the programm to the point where the Service and the vendor specific UUID must be added to the softdevices UUID list. I searched the internet and found out that the memory allocated for the softdevice is to short in the linker script (I read this in the documentation of the softdevice v5.0). I changed the linker script,m but that didn't help also. The line of code is where the hard fault is caused is the following:

err_code = sd_ble_uuid_vs_add(&base_uuid, &service_uuid.type);

I'm guessing that my application can't call the function in the softdevice, but I'm not quite sure.

Can anybody help or give an advice where to look or what I've done wrong?

Thanks in advance everybody!!!

Parents
  • Hi,

    I tested your code and think I found the issue. In addition to incrementing NRF_SDH_BLE_VS_UUID_COUNT you need to allocate more RAM to the Softdevice. The way to figure out how to do this is to use a serial terminal when you debug your project. When your code executes nrf_sdh_ble_enable() these messages are printed out:

    Then open your linker script and edit the RAM sizes accordingly:

    To make debugging easier you should also use optimization level -O0 (instead of the default -O3) and define

    CFLAGS += -DDEBUG

    in the C flags in your Makefile.

    EDIT: After I made these changes to your code it seemed to work. Note that you will probably have to make more changes to RAM sizes as you expand your project with more services and characteristics and if you tweak the Softdevice link and bandwidth settings. So be aware of that.

Reply
  • Hi,

    I tested your code and think I found the issue. In addition to incrementing NRF_SDH_BLE_VS_UUID_COUNT you need to allocate more RAM to the Softdevice. The way to figure out how to do this is to use a serial terminal when you debug your project. When your code executes nrf_sdh_ble_enable() these messages are printed out:

    Then open your linker script and edit the RAM sizes accordingly:

    To make debugging easier you should also use optimization level -O0 (instead of the default -O3) and define

    CFLAGS += -DDEBUG

    in the C flags in your Makefile.

    EDIT: After I made these changes to your code it seemed to work. Note that you will probably have to make more changes to RAM sizes as you expand your project with more services and characteristics and if you tweak the Softdevice link and bandwidth settings. So be aware of that.

Children
Related