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

sd_ble_uuid_vs_add error code 4

Hello All,

I have looked around for answers to my specific issue, however I did not seem to find one that aided me enough to fix my issue.

I have created a BLE profile with BDS and utilized the Nordic plugin to generate the code. Everything seemed to work out well, but I have an issue when initializing my custom service.

The code breaks down when attempting to add a custome base UUID. This is the snippet of code from my service .c file. I traced the code and this is where it breaks.

ble_uuid128_t bds_base_uuid = {{0xD0, 0x70, 0x1F, 0x19, 0x94, 0xB8, 0xF2, 0x86, 0xF5, 0x4A, 0xF5, 0xFF, 0x00, 0x00, 0x84, 0x56}};
uint8_t uuid_type;
err_code = sd_ble_uuid_vs_add(&bds_base_uuid, &uuid_type); <----- Right here.
if (err_code != NRF_SUCCESS)
{
return err_code;
}

My first thought is that I needed to modify the main.c file in this location:

// YOUR_JOB: Use UUIDs for service(s) used in your application.
static ble_uuid_t m_adv_uuids[] = /**< Universally unique service identifiers. */
{
{BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}
};

But I cannot seem to figure out the correct way.

Here is a trace of my locals from the execution right after the error code is generated. 

If anyone can point me in the right direction or tell me what easy thing is missing I'd very much appreciate it!

Thanks!

Adam

Parents
  • Hi,

    sd_ble_uuid_vs_add will return this error if there are no more free slots for VS UUIDs.

    Which SDK are you using? For newer SDKs, go to sdk_config.h and set "#define NRF_SDH_BLE_VS_UUID_COUNT 2". Think this should solve your issue.

  • Unfortunately that did not work for me, and worse now it will not get as far in the main function. It fails when calling ble_stack_init().

  • I work in Eclipse using GCC so I modify the files directly, but if you're using another IDE I think there's a menu where you can modify that. The linker files in the SDK are usually in a path like this SDK/examples/ble_peripheral/ble_app_hrs/pca10040/s132/armgcc/ble_app_hrs_gcc_nrf52.ld

    There you modify this:

  • I actually just found the file. I modified the linker file as such:

    MEMORY
    {
    UNPLACED_SECTIONS (wx) : ORIGIN = 0x100000000, LENGTH = 0
    RAM (wx) : ORIGIN = 0x20000016, LENGTH = 0x0000FFEA
    FLASH (wx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
    }

    Where the original RAM origin was at 0x20000000 and Length was 0x00010000.

    I'm using Seeger embedded studio for reference.

    It seems that when I rebuild the file it gets automatically regenerated with the default values, overwriting my changes. But then it crashes before it even enters the main.

  • Yes well, that linker file won't work. You need to reserve some flash and some RAM for the softdevice. Your program doesn't start at 0x00000000, but more likely at 0x0001F000 or something like that. Anyway, there must be a menu somewhere in the IDE where you can specify the memory regions for your application.

  • Here is how you can change it with Segger Embedded Studio:

    youtu.be/uP8RYgYGRvI

  • I just found this: devzone.nordicsemi.com/.../segger-embedded-studio-blog-post-rev2-deprecated

    Apparently it's under Project properties -> Linker -> Section placement macros

Reply Children
  • Thank you guys so much! I modified the linker and added in the 16 bytes to RAM start and removed 16 bytes from RAM size and it worked. I've never been so happy about a blinking light.

  • Glad to help! Btw, your memory settings are still wrong, 16 bytes more is 0x10 not 0x16 ;) It works because you have allocated more memory than needed, but just so you know.

  • Yeah, I saw that once I posted. Fixed already. Smiley