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

nRF52840 Dongle, PCA10059 DFU Trigger library

Hello I'm trying to implement the DFU Trigger library into my project. to get following function:

" When the trigger library is added to an application, it allows a connected USB host to remotely tell the app to reboot into the bootloader to allow it to be updated via DFU. When asked to enter bootloader mode, it pulls its own reset pin using the GPIO pin BSP_SELF_PINRESET_PIN (by default, only available on PCA10059). As a consequence, the library requires the following:

  • a GPIO pin connected to the RESET pin which is true for the PCA10059 dongle,
  • a bootloader that enters DFU mode on pin reset. "

I want to load Firmware updates to the Dongle without pressing the reset button.

In the main.c I've addded following code, I wasn't sure if i had to add some defines in the sdk_config.h:

#include "nrf_dfu_trigger_usb.h"
#include "app_usbd.h"
#include "boards.h"
#define BOARDS_WITH_USB_DFU_TRIGGER  1
#define NRF_DFU_TRIGGER_USB_INTERFACE_NUM 1
#define NRF_DFU_TRIGGER_USB_USB_SHARED 1
#define BOARD_PCA10059 1
#define BSP_INIT_NONE    0
#define BSP_INIT_LEDS    (1 << 0
#define BSP_INIT_BUTTONS (1 << 1)
const app_usbd_config_t * usbd_config = NULL;
...
int main(int argcchar *argv[])
{
    app_usbd_init(usbd_config);
    bsp_board_init(BSP_INIT_LEDS);
...
}
ERROR:
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: build/nrf_dfu_trigger_usb.c.o: in function `nrf_dfu_trigger_usb_init':
/workspaces/./third_party/NordicSemiconductor/components/libraries/usb/nrf_dfu_trigger_usb.c:221: undefined reference to `app_usbd_class_append'
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: build/nrf_dfu_trigger_usb.c.o:(.rodata.m_app_dfu+0x4): undefined reference to `app_usbd_nrf_dfu_trigger_class_methods'
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: build/main.c.o: in function `main':
/./app/main.c:174: undefined reference to `app_usbd_init'
collect2: error: ld returned 1 exit status
Makefile:360: recipe for target 'build' failed
make: *** [build] Error 1

I've added following librarys to my makefile:

  $(NORDIC_ROOT)/components/libraries/usb/app_usbd.c \
  $(NORDIC_ROOT)/components/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.c \
  $(NORDIC_ROOT)/components/libraries/usb/app_usbd_string_desc.c \
  $(NORDIC_ROOT)/components/libraries/usb/nrf_dfu_trigger_usb.c \
  $(NORDIC_ROOT)/components/libraries/usb/app_usbd_nrf_dfu_trigger.c \
...
  -I$(NORDIC_ROOT)/config \
  -I$(NORDIC_ROOT)/components/libraries/usb \
  -I$(NORDIC_ROOT)/components/libraries/block_dev \
  -I$(NORDIC_ROOT)/components/libraries/usb/config \
  -I$(NORDIC_ROOT)/components/libraries/usb/class \
  -I$(NORDIC_ROOT)/components/libraries/usb/class/cdc \
Any advices ? Slight smile
  • Hi,

    Have you enabled app_usbd library in your sdk_config.h file?

    // <e> APP_USBD_ENABLED - app_usbd - USB Device library
    //==========================================================
    #ifndef APP_USBD_ENABLED
    #define APP_USBD_ENABLED 1
    #endif

    Best regards,
    Jørgen

  • Hello no i have not.

    I've also set 

    #define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1

    I've enabled it now and got following error:


    In file included from ./third_party/NordicSemiconductor/components/libraries/util/sdk_macros.h:52,
    from ./third_party/NordicSemiconductor/components/libraries/util/sdk_common.h:62,
    from ./third_party/NordicSemiconductor/components/libraries/usb/app_usbd.c:40:
    ./third_party/NordicSemiconductor/components/libraries/usb/app_usbd.c: In function 'app_usbd_power_events_enable':
    ./third_party/NordicSemiconductor/components/libraries/usb/app_usbd.c:953:54: error: 'USBD_CONFIG_IRQ_PRIORITY' undeclared (first use in this function); did you mean 'CLOCK_CONFIG_IRQ_PRIORITY'?
    953 | ASSERT((!APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || (USBD_CONFIG_IRQ_PRIORITY == POWER_CONFIG_IRQ_PRIORITY));
    | ^~~~~~~~~~~~~~~~~~~~~~~~
    ./third_party/NordicSemiconductor/components/libraries/util/nrf_assert.h:106:9: note: in definition of macro 'ASSERT'
    106 | if (expr) \
    | ^~~~
    ./third_party/NordicSemiconductor/components/libraries/usb/app_usbd.c:953:54: note: each undeclared identifier is reported only once for each function it appears in
    953 | ASSERT((!APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || (USBD_CONFIG_IRQ_PRIORITY == POWER_CONFIG_IRQ_PRIORITY));
    | ^~~~~~~~~~~~~~~~~~~~~~~~
    ./third_party/NordicSemiconductor/components/libraries/util/nrf_assert.h:106:9: note: in definition of macro 'ASSERT'
    106 | if (expr) \
    | ^~~~
    ./third_party/NordicSemiconductor/components/libraries/usb/app_usbd.c:953:82: error: 'POWER_CONFIG_IRQ_PRIORITY' undeclared (first use in this function); did you mean 'GPIOTE_CONFIG_IRQ_PRIORITY'?
    953 | ASSERT((!APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || (USBD_CONFIG_IRQ_PRIORITY == POWER_CONFIG_IRQ_PRIORITY));
    | ^~~~~~~~~~~~~~~~~~~~~~~~~
    ./third_party/NordicSemiconductor/components/libraries/util/nrf_assert.h:106:9: note: in definition of macro 'ASSERT'
    106 | if (expr) \
    | ^~~~
    ./third_party/NordicSemiconductor/components/libraries/usb/app_usbd.c: In function 'app_usbd_event_execute':
    ./third_party/NordicSemiconductor/components/libraries/usb/app_usbd.c:1068:12: error: 'USBD_CONFIG_IRQ_PRIORITY' undeclared (first use in this function); did you mean 'CLOCK_CONFIG_IRQ_PRIORITY'?
    1068 | ASSERT(USBD_CONFIG_IRQ_PRIORITY <= current_int_priority_get());
    | ^~~~~~~~~~~~~~~~~~~~~~~~
    ./third_party/NordicSemiconductor/components/libraries/util/nrf_assert.h:106:9: note: in definition of macro 'ASSERT'
    106 | if (expr) \
    | ^~~~

  • I still have following problem, do you have any ideas?

    /opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: build/nrf_dfu_trigger_usb.c.o:(.rodata.m_app_dfu+0x4): undefined reference to `app_usbd_nrf_dfu_trigger_class_methods'
    collect2: error: ld returned 1 exit status
    Makefile:361: recipe for target 'build' failed

    And when it finaly work, how can i trigger the dongle to get into bootloader mode? I'm using Nrfutil and NRF connect desktop to load the firmware.

  • You need to include and set the sdk_config.h configuration parameters correctly. In this case, it looks like USBD_CONFIG_IRQ_PRIORITY is not defined. You can check the APP_USBD examples, and copy relevant configs for APP_USBD and USBD parts.

  • Uyl,

    Did you get this to work? I am trying to do the same thing, program the nRF52840 dongle without pressing the reset button. I have dongles that are in a sealed cover and do not have access to the reset button. I don't even know how to start. Where did you find the documentation to get off the ground? Maybe there isn't any? I certainly have not found anything but documentation has always been difficult to find on the Nordic sites.

    I cannot even find the trigger library... of course I don't know what it is called in the SDK or if it even exists in the SDK. My current project uses SoftDevice and BTLE. It does not use the SDK for Bluetooth; just SoftDevice.

    I guess it does not exist in the SDK in any obvious form - I tried adding 

    #include "nrf_dfu_trigger_usb.h" in an example BTLE project (BPS) and the compiler could not find the file.

    Did you find an example project where this is implemented?

    Thanks,

    Brian

Related