How to use the trigger library to program the nRF52840 dongle

Sorry but I find the documentation useless. I don't even know where to start. It could be I have not found the correct documentation which is not surprising.

The best I have is this: https://devzone.nordicsemi.com/f/nordic-q-a/77254/nrf52840-dongle-pca10059-dfu-trigger-library/332347#332347

but I have no idea how this even started.

Right now the project works. I can use the reset button to flash the dongle and it works. Its a BTLE peripheral that a cycle power client connects to at which time the device starts a scanner and gets data from an unconnectable advertisement from a bike and notifies the data to the client. The USB is used only as a source of power. The project uses SoftDevice for BTLE and flash writes and not the SDK.

Now I want to add the overhead to be able program the dongle without touching the reset button. I don't know where to start. It's clear I have to add lots of h-files and c-files to the project. However, where do I find the steps that document how one adds this functionality to an existing project?

  • What methods do I need to call and when?
  • What configuration parameters do I need to set outside of sdk_config.h?
  • What configuration parameters do I need to set in sdk_config.h?
  • Where are these methods and h-files located so I can pull/configure my project?

One final question, how much overhead does this add? Will it greatly increase the size of my executable project?

When and if this ever gets completed, would that mean I can flash the dongle directly from Keil or Segger or do I still need nRF_Connect that I use now where I have to press the reset button?

Parents Reply Children
  • I don't know how to add it into my project. No clue even how to start. It probably requires configuring a lot of h-files (via the IDE) and including c-files into my project. No documentation anywhere that I can find. Piecemeal stuff scattered about but no way to piece it together.

  • I see. I suggest you start with the main things:

    • Use the <SDK>\examples\connectivity\ble_connectivity\pca10059\ser_s140_usb_hci\ example project that matches your toolchain as reference, so that you have an example where all required files and configurations are present.
    • Update your application code to include nrf_dfu_trigger_usb.h and call nrf_dfu_trigger_usb_init() during initialization. This is the only change needed in your code apart from sdk_config.h
    • Modify your sdk_config.h, copying in the two NRF_DFU_TRIGGER_* configurations from <SDK>\examples\connectivity\ble_connectivity\pca10059\ser_s140_usb_hci\config\sdk_config.h. Adapt to your application.
    • Add missing include paths to your project. If you have a USB project your probably have most from before, but make sure you add ../../../../../../components/libraries/bootloader/dfu and ../../../../../../components/libraries/usbd/class/nrf_dfu_trigger (relative path may differ in your project).
    • Add ../../../../../../components/libraries/bootloader/dfu/nrf_dfu_trigger_usb.c and ../../../../../../components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.c to your project.

    If you still miss somethings you should get sensible errors/warnings from the tools so that you can correct.

  • This is absurd!! I am adding file after file and every time there are more and more undefined symbols.

    I have had to add many config items in the sdk_config.h file and there are only more undefined references.

    Catch this!!

    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol app_usbd_nrf_dfu_trigger_class_methods (referred from nrf_dfu_trigger_usb.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrf_drv_power_init (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrf_drv_power_usbevt_init (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrf_drv_power_usbevt_uninit (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_active_irq_config (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_disable (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_enable (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_disable (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_dtoggle_clear (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_enable (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_enable_check (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_handled_transfer (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_stall (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_stall_clear (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_transfer (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_force_bus_wakeup (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_init (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_is_enabled (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_is_initialized (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_start (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_stop (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_suspend (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_suspend_irq_config (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_uninit (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_wakeup_req (referred from app_usbd.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_max_packet_size_get (referred from app_usbd_core.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_ep_stall_check (referred from app_usbd_core.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_feeder_buffer_get (referred from app_usbd_core.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_last_setup_dir_get (referred from app_usbd_core.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_setup_clear (referred from app_usbd_core.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_setup_data_clear (referred from app_usbd_core.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_setup_get (referred from app_usbd_core.o).
    .\_build\nrf52840_xxaa.axf: Error: L6218E: Undefined symbol nrfx_usbd_setup_stall (referred from app_usbd_core.o).

    By the time this is done my 10K project is going to be 100K. Is this for real? How big is the overhead here? Building that project gives a size of more than 70K. I thought it would be adding two methods and a few source files and two config lines.

    I can't even find half of these undefined symbols. They are all over the place in the SDK

    Everywhere I see this Macro

    NRF_MODULE_ENABLED(...)

    The code after it is disabled. More config items copied into the sdk_config.h file and still more undefined references but some of those disables become enabled.

    DO I have to copy the entire sdk_config.h file into mine and then include every c-file in the project into mine?

  • Hi,

    There is not that much to say really, other than that yes, there are a log of dependencies, and if you want to use the USB DFU trigger library you need to add them all.  If your project use USB allready they will probably not add too much. If it does not, then there is quite a bit.

    If you refer to the example I suggested, you can use that as a reference. Or you can base what you do on build warnings/error. Looking at the log you posted you can check which files those symbols are defined in, and make sure you add related .c files and include paths. And also remember to enable the relevant parts of sdk_config.h. I suggest you copy large sections of the example sdk_config.h, yes. Not necessarily everything, but for instance if adding USB copy the whole section, and then adapt afterwards if needed. That is much more efficient than picking single configuration defines at a time.

    This is a bit of tedious work, but this is how the nRF5 SDK is organized and so it is just how it is when you work with it (the nRF Connect SDK is better in this regard, as such tasks are automated by the build system there).

  • My original project used no USB. Its a BTLE project which advertises as a cycle power and heart rate service. When connected it starts scanning for non connectable advertisements sent by a stationary exercise bike. It decodes the advertisement and notifies the connected client the power, crank, and heart rate data.

    The project uses the LEDs, SoftDevice for BTLE and flash writes and not much else besides all the necessary files for the board and other hardware support like the RTC. There are probably files I don't need still in the project but I have no idea what many of them do. I have tried to get rid of all superfluous material but I am sure I am no where close.

    The compiled image according to Keil (with logging disabled) is 10K. It's pretty small which is nice.

    It does not use any USB.

    Building the example project cited above gives 70K according to Keil. That alone is frightening. I have the size limited version of Keil but have been using it since it is better at finding potential problems with its warnings. I have my project in Segger as well when I need intense logging at Debug level with 0 optimization which makes the code image just over the limit for Keil.

    As far as porting over the files from the cited project are concerned it would be nice to know from some documentation what files are necessary and where they are and what sdk_config options are necessary and what they are. Finding the source files once you have their names is a task in itself. Every time I added one I would get new undefined references sometime due to missing sdk_config settings and sometimes due to missing c-files or both. The c-files are scattered across several different directories as I soon learned. At least the h-files are easier to find since they are listed in the Keil config and extra h-files do not cost on the final build size or efficiency.

    After several hours of adding, searching, rebuilding, and just continuing to get new errors I figured I must be on the wrong track. Probably added files I didn't need which required more unneeded files etc. I was adding files without usbd or trigger in the names.

    I am making a desperate call for documentation. From what is out there, it sounded easy as adding a few methods and a reference to a library.

Related