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

BLE_NUS not working in BLE_APP_TEMPLATE SDK15.3 + SD132 6.1.1

Dear Nordic team,

I am using a NRF52832 and SDK15.3 + SD6.1.1 and Segger Embedded Studio to develop my code.

I started developing my code from the example "ble_app_template_pca10040_s132", and I am using the BAS and the NUS service. I use the PCA10040 to debug.

Everything goes fine if NUS Service is not initiliced. Once I initialice NUS (with no compilation errors and not warnings), I always get a hard fault.

The functions that fails is the ble_nus_init, that returns the error code 0x4, that means "no memory"

To debug further, I opened the ble_nus.c file and I noticed that the function call err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type) is who causes the error code 0x4.

I tryied to check the ble_app_uart example and it works prefectly. So I decided to set in my project the same memory linker RAM address and size that is used in the ble_app_uart example.

In other words, In my project I changed:

RAM_START = 0x20002218 to 0x20002a98

RAM_SIZE = 0xdde8 to 0xd568

But it does not work.

I know that this topic has been commented in other threads of the forum, but they did not help my. By reading them and applying here their answers, I can say that nrf_sdh_ble_enable(&ram_start) does not throws any error nor warning. Also I have check other ram setups as RAM_START = 0x20003000 RAM_SIZE = 0xd000 and it not works.

Could you help me , please?

Thanks in advance,

    Kind Regards

  • Hello,

    Just to avoid any future confusion:

    the fact that sd_ble_uuid_vs_add() returns != 0x00 and this is picked up by an APP_EROR_CHECK() is not a hardfault. A Hardfault is a corrupted memory on the chip. What you are seeing is that the error handler is triggered. 

    So, you try to add the NUS service, and sd_ble_uuid_vs_add returns 0x04, NRF_ERROR_NO_MEM.

    In your sdk_config.h file, there is a variable called NRF_SDH_BLE_VS_UUID_COUNT.

    This should match the number of services you have. If you have already added BAS, and you are trying to add the NUS, but NRF_SDH_BLE_VS_UUID_COUNT is set to 0, then this will return NRF_ERROR_NO_MEM.

    Try to increase NRF_SDH_BLE_VS_UUID_COUNT to 1. When you compile and flash your project, it will probably say something about RAM_START and RAM_SIZE in the log. This is because you changed some settings for the softdevice when you increased the NRF_SDH_BLE_VS_UUID_COUNT.

    Please note that the reason the battery service isn't affected by the NRF_SDH_BLE_VS_UUID_COUNT is because this is a standardized service, and hence it has a shorter UUID (doesn't require much space). Hence it is not a VS (vendor specific) service.

    If you later are encountering any NRF_ERROR_NO_MEM issues when trying to add the characteristics, then you may need to increase NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE as well. I don't remember the exact conditions when this occurs, but you can try this if you run into any issues.

    Best regards,

    Edvin

  • Hello Edvin,

    Yes you are right. By incrementing the variable NRF_SDH_BLE_VS_UUID_COUNT in the sdk_config file and applying the memory settings of the ble_app_uart, I was able to fix the problem. Now it works perfectly Slight smile

    Thanks a lot for your useful information and your support.

    Kind Regards,

               Caelus

Related