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

nRF Dongle stops after impementing ble_nus

Hi,

I have created a project with nRF52840 DK  that reads sensors data and transmits them with BLE UART to my smartphone. Everything works fine.

Then, I tried to do the same thing with the nRF Dongle. Initially, I took the ble_app_template example and modified the .emProject file and flash_placement.xml file

as mentioned in the guides shown in the following links :

https://devzone.nordicsemi.com/tutorials/b/getting-started/posts/nrf52840-dongle-programming-tutorial

https://www.novelbits.io/nrf52840-usb-dongle-tutorial-2/

The dongle started advertising (blinking green LED) and  my smartphone could recognize it as I expected . So far so good.

Next I initialized the ble_nus the same way it is implemented in the ble_app_uart example for the DK. I also enabled the app_uart and app_fifo in the sdk_config (since NUS needs them enabled).

When I built and uploaded the .hex and softdevice files with nRF Connect GUI to the Dongle it could not advertise. The green LED was not blinking and I could not Identify the dongle peripheral from my smartphone as before.

I connected the dongle to the nRF52 DK  (P19 connector) and started a debug session. I noticed that an error occurs when the program reaches to services_init() function, inside the ble_nus_init() function, at the characteristic_add() function. At this point the function returns an error (0x00000004) and the characteristic is not added. Then the program goes to app_error_fault_handler and halts .

I cannot understand what I do wrong here. Any ideas?

Thank you for your time.

  • the function returns an error (0x00000004)

    Have you looked-up the meaning of that error?

  • Actually, this is what I get after the code halts

    and this is what I get when ble_nus_init() is executed

    If I interpret correctly, the error 0x00000004 is located in nordic_common.h :

    (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0004) ///< Mutex conditional initialization failed

    What does it mean?

  • I have created a project with nRF52840 DK ... Everything works fine. Then, I tried to do the same thing with the nRF Dongle. Initially, I took the ble_app_template example

    Rather than start again from scratch, why don't you just modify your working example for the dongle?

    It should just be a matter of suitably defining the external connections ...

  • I did what you say. I took the working example I implemented in the DK and modified it for the dongle. It had the same result and then I decided to start from scratch to see where the issue occurs

  • Only a couple of items have to be changed, maybe check to see if you have these. I don't recall having to make any changes to flash or memory placement.

    // LED definitions for PCA10059
    // Each LED color is considered a separate LED
    #define LEDS_NUMBER    4
    
    #define LED1_G         NRF_GPIO_PIN_MAP(0,6)
    #define LED2_R         NRF_GPIO_PIN_MAP(0,8)
    #define LED2_G         NRF_GPIO_PIN_MAP(1,9)
    #define LED2_B         NRF_GPIO_PIN_MAP(0,12)
    
    #define LED_1          LED1_G
    #define LED_2          LED2_R
    #define LED_3          LED2_G
    #define LED_4          LED2_B
    
    #define LEDS_ACTIVE_STATE 0
    
    #define LEDS_LIST { LED_1, LED_2, LED_3, LED_4 }
    
    #define LEDS_INV_MASK  LEDS_MASK
    
    #define BSP_LED_0      LED_1
    #define BSP_LED_1      LED_2
    #define BSP_LED_2      LED_3
    #define BSP_LED_3      LED_4
    
    // There is only one button for the application
    // as the second button is used for a RESET.
    #define BUTTONS_NUMBER 1
    
    #define BUTTON_1       NRF_GPIO_PIN_MAP(1,6)
    #define BUTTON_PULL    NRF_GPIO_PIN_PULLUP
    
    #define BUTTONS_ACTIVE_STATE 0
    
    #define BUTTONS_LIST { BUTTON_1 }
    
    #define BSP_BUTTON_0   BUTTON_1
    
    #define BSP_SELF_PINRESET_PIN NRF_GPIO_PIN_MAP(0,19)

    They are in the separate file "pca10059.h" which is included by specifying BOARD_PCA10059 instead of BOARD_PCA10056 in the project C++ pre-processor.. If you have this already, ignore my answer (posting as fyi for others).

Related