Nrf52840 dongle, NRF_ERROR_NO_MEM when trying to merge usbd_cdc_acm and ble_peripheral_uart (only NUS part) examples

Hello,

I am using the NRF52840 dongle, and for my project I need to be able to send/receive data from a RaspberryPi and also send/receive large strings between multiple dongles with BLE. I decided to use a NUS service for the BLE communication, now implementing a NUS peripheral and will add afterwards the functionality for behaving as a central simultaneously.

I have successfully implemented the USB communication, and merging it with the BLE peripheral HRS example was also successful. Additionally I am aware that the dongle is not intended for development and a DK should be used instead. Currently I am unable to order one and am stuck with the dongles. To circumvent this, when my code is not working, I write the faulty parts in the main function and execute them in segments to debug it. I do this after the USB communication is compiled so that I can also get feedback on what is being run and find different parameter values. Each segment is run after a press of the dongle's button.

Now to the issue at hand: I am initially trying to implement a NUS peripheral service, using the code from ble_peripheral_uart and excluding the uart parts from it. Using the debugging mentioned earlier, I segmented the example's init functions, and found that the dongle stops working after calling ble_stack_init. To find out more I took the code from ble_stack_init and wrote it in the main function in segments. The error came from running nrf_sdh_ble_enable, so I wrote its code in the main function as well.

I found that I get error code 4 (NRF_ERROR_NO_MEM ) when I run sd_ble_enable and I also managed to print the Log Warnings with the suggestions for changing the RAM start location and RAM size. Even after I change these values in the Project options->Linker I still get the same error. The changes are also registered successfully as the ram_start value from nrf_sdh_ble_default_cfg_set is the same as the RAM_START value I changed in Linker.

I saw also that SoftDevice must be less than 64kB so I also changed:

  • NRF_SDH_BLE_GAP_EVENT_LENGTH to 6 (from 320)
  • NRF_SDH_BLE_GATT_MAX_MTU_SIZE to 150 (from 270)
  • NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE to 2816 (from 1408),

but I still get the same error, even after changing RAM start and size to the newly suggested values. I also tried different values to no avail for:

  • PM_LESC_ENABLED, PM_RA_PROTECTION_ENABLED, CRC16_ENABLED, FDS_ENABLED, MEM_MANAGER_ENABLED, NRF_FSTORAGE_ENABLED, PEER_MANAGER_ENABLED and PM_CENTRAL_ENABLED

I am attaching my project, in case you want to check my code, project settings, or sdk_config. Although I had to hardcode the addresses in User Include Directories when implementing the USB code as it was not working with ../../.. . 

dongle_usb_crc_acm.zip

Related