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 Reply Children
  • When you increase the number of vendor-specific UUIDs, the softdevice needs more RAM. Your application is crashing when initializing because you haven't updated the linker script to reflect the new RAM regions.

    If you enable the debug output you should be able to see how you need to adjust the RAM size and start address. If you can't see it simply add 16 bytes to the start and subtract 16 from the size per each new UUID you add.

  • I believe this is probably the solution. However, I have never worked with linker files before. Where might this file be located? Also, I'm working in the 14.2 SDK for reference.

  • 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:

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

  • 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.

Related