Trigger library does not work

After a painful sequence here

https://devzone.nordicsemi.com/f/nordic-q-a/80283/how-to-use-the-trigger-library-to-program-the-nrf52840-dongle

I managed to merge the projects and insert all those c-files and h-files and tried to match all the correct items in the sdk_config.h file (perhaps the hardest part) into the project to support the single function added to my project nrf_dfu_trigger_usb_init().

It finally built with no undefined references and I was able to use nRF Connect to install SoftDevice and my trigger-usb loaded application onto the dongle. Though the application worked fine, nRF Connect gave the message

Nordic DFU Trigger Interface was not found. Please physically reset the device.

I have no idea how to test this and why it should fail. Since there is not much I have to do with respect to writing code (add one h-file and one init method), if you can get all the dependencies right so the project builds, what could go wrong? The only thing I can think of is the sdk_config.h file. There are all kinds of things in there mostly undocumented and I have no idea what they do.

Since my original project did not use USB in any way, I assumed the share option would be off. The example project \examples\connectivity\ble_connectivity\pca10059\ser_s140_usb_hci had it set to shared, but I do not know what it is sharing it with.

Has anyone ever gotten this to work with their BTLE-SoftDevice application?

In the connectivity sdk_config.h file the following items are enabled:

sdk_config.h(151) : #define BLE_DTM_ENABLED 1
sdk_config.h(209) : #define NRFX_CLOCK_ENABLED 1
sdk_config.h(294) : #define NRFX_POWER_ENABLED 1
sdk_config.h(334) : #define NRFX_PRS_ENABLED 1
sdk_config.h(368) : #define NRFX_PRS_BOX_4_ENABLED 1
sdk_config.h(428) : #define NRFX_SYSTICK_ENABLED 1
sdk_config.h(434) : #define NRFX_UARTE_ENABLED 1
sdk_config.h(560) : #define NRFX_UART_ENABLED 1
sdk_config.h(681) : #define NRFX_USBD_ENABLED 1
sdk_config.h(746) : #define NRF_CLOCK_ENABLED 1
sdk_config.h(789) : #define POWER_ENABLED 1
sdk_config.h(832) : #define SYSTICK_ENABLED 1
sdk_config.h(838) : #define UART_ENABLED 1
sdk_config.h(915) : #define UART0_ENABLED 1
sdk_config.h(938) : #define USBD_ENABLED 1
sdk_config.h(1001) : #define APP_SCHEDULER_ENABLED 1
sdk_config.h(1022) : #define APP_TIMER_ENABLED 1
sdk_config.h(1117) : #define APP_USBD_ENABLED 1
sdk_config.h(1388) : #define APP_USBD_NRF_DFU_TRIGGER_ENABLED 1
sdk_config.h(1395) : #define CRC16_ENABLED 1
sdk_config.h(1401) : #define NRF_BALLOC_ENABLED 1
sdk_config.h(1458) : #define NRF_MEMOBJ_ENABLED 1
sdk_config.h(1464) : #define NRF_QUEUE_ENABLED 1
sdk_config.h(1479) : #define NRF_SECTION_ITER_ENABLED 1
sdk_config.h(1486) : #define NRF_SORTLIST_ENABLED 1
sdk_config.h(1493) : #define NRF_STRERROR_ENABLED 1
sdk_config.h(1503) : #define APP_USBD_CDC_ACM_ENABLED 1
sdk_config.h(1526) : #define NRF_FPRINTF_ENABLED 1
sdk_config.h(1533) : #define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 1
sdk_config.h(4212) : #define NRF_SDH_BLE_LOG_ENABLED 1
sdk_config.h(4263) : #define NRF_SDH_LOG_ENABLED 1
sdk_config.h(4314) : #define NRF_SDH_SOC_LOG_ENABLED 1
sdk_config.h(4467) : #define PM_LOG_ENABLED 1
sdk_config.h(4584) : #define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1
sdk_config.h(4646) : #define NRF_SDH_BLE_ENABLED 1
sdk_config.h(5127) : #define NRF_SDH_ENABLED 1
sdk_config.h(5295) : #define NRF_SDH_SOC_ENABLED 1

Some I understand, most I do not. Which of these MUST be enabled in order for the trigger to work?

  • NOW I see that you didn't remove the entire wait loop, just the ble event poller

    So trying it out it half-worked. I get this error

    Error while probing usb device at bus.address 1.16: undefined. Please check that a libusb-compatible kernel driver is bound to this device, see https://github.com/NordicSemiconductor/pc-nrfconnect-launcher/blob/master/doc/win32-usb-troubleshoot.md

    I reinsert the dongle and this is what I get:

    10:21:30.829	Application data folder: C:\Users\brian\AppData\Roaming\nrfconnect\pc-nrfconnect-programmer
    10:21:30.926	Using nrfjprog library 10.12.1, pc-nrfjprog-js 1.7.6
    10:21:32.740	Error while probing usb device at bus.address 1.16: undefined. Please check that a libusb-compatible kernel driver is bound to this device, see https://github.com/NordicSemiconductor/pc-nrfconnect-launcher/blob/master/doc/win32-usb-troubleshoot.md
    10:24:52.174	Error while probing usb device at bus.address 1.17: undefined. Please check that a libusb-compatible kernel driver is bound to this device, see https://github.com/NordicSemiconductor/pc-nrfconnect-launcher/blob/master/doc/win32-usb-troubleshoot.md
    10:25:03.921	Using USB SDFU protocol to communicate with target
    10:25:08.927	Error when calling version command: Error: Error message: Timeout while reading from serial transport. See https://github.com/NordicSemiconductor/pc-nrfconnect-launcher/blob/master/doc/serial-timeout-troubleshoot.md
    10:25:08.928	Error when fetching device versions: TypeError: Cannot read property 'part' of undefined
    10:25:31.756	Using USB SDFU protocol to communicate with target
    10:25:36.760	Error when calling version command: Error: Error message: Timeout while reading from serial transport. See https://github.com/NordicSemiconductor/pc-nrfconnect-launcher/blob/master/doc/serial-timeout-troubleshoot.md
    10:25:36.761	Error when fetching device versions: TypeError: Cannot read property 'part' of undefined

    In that case I did not reload the LIBUSB. I am on Windows 10. Not sure what the issue is. It appears I have the right driver.

    On SES (the above was Keil) the install worked with no error BUT the application did not start. I am left with a blinking red LED. It should be a steady green LED showing it is advertising. That DOES happen in the Keil build.

    If I reinsert the dongle, the advertising starts. nRF COnnect sees the device, But selecting it causes the fleshing red LEDs and no memory map is shown. I need to reselect the device. Now a memory maps is shown but the device shown does not contain the CDC name any more. Just 'com port 4'. The memory map now shows and I can reinstall the program. It will get to the flashing red LED. If I reinstall again the dongle starts but the trigger interface dies. Now it is all messed up.

    Something is not quite right. NOt sure why it fails the way it does in KEIL except that it is a release mode whereas SES is debug mode. Huge difference in size!!!

    Why is the USB SHARED set? USB is used only by DFU, not by my application.

    Was able to test the dongle and the ble functionality is still good. However, its pretty clear what happens when trying to flash the dongle.

    1. Plug it in and the LED turns green - it is advertising
    2. The dongle is visible in the nRF Connect programmer as a com port and CDC DEMO 
    3. Click on the selection and the dongle fails to open but its still visible in the devices windw
    4. It now says only the COM port.
    5. Click on that and the address map is displayd.
    6. Now write the HEX files
    7. When done, there are somr RED LEDs being triggered, then green, and then flashing red.
    8. Re-insert the dongle and the LED turns green -  it is advertising and can be used.
    9. nFR Programmer mouse-over will show comport and USB CDC Demo as at the start.

    In Keil, the hex file does not work. After installation the Tigger library interface fails to install but the LED turns green. nFR Programmer can no longer find the device. Have been unable to get the Keil project to build a functioning HEX file. Don't know what's missing.

  • I assumed you were using the Segger project, so I didn't update the dependencies in the Keil project.

    brianreinhold said:
    On SES (the above was Keil) the install worked with no error BUT the application did not start. I am left with a blinking red LED. It should be a steady green LED showing it is advertising.

    It sounds like it is working as it is supposed to. The programmer app will make the dongle enter DFU mode when you connect, and again after DFU is completed.

    brianreinhold said:
    SES is debug mode. Huge difference in size!!!

    Yes, the debug build includes a bunch of ASSERT information such as file names and line numbers.

    brianreinhold said:
    Why is the USB SHARED set? USB is used only by DFU, not by my application.

    As mentioned previously, I had to include the CDC ACM class in addition to the DFU trigger to make Windows recognize the device.

    You can remove the bsp_board_led_* calls in cdc_acm_user_ev_handler() and usbd_user_ev_handler() to remove the LED indications for USB activity.

  • Okay, so the Trigger is working as it is supposed to.

    With this DFU-application installed on the Dongle

    • NRF Connect Programmer shows the dongle as Serial Port COM6 and USB: ... CDC DEMO
    • When I select the device, I see just Serial Port COM6. (I have gotten errors on the select sometimes and have to select again.)
    • When I install, I end up with a blinking red LED and still just Serial Port COM6
    • Click reset and everything is good - LED green for advertising. nrf connect programmer shows the CDC DEMO line as well. (Could re-insert the dongle instead.)

    This is correct behavior.

    I have tried to get Keil working and I cannot. I can't see what I am missing.

    There Programmer is giving me

    11:06:58.646	Waiting for device
    11:07:03.647	Reopen device failed: Timeout while waiting for device D10D9525AA48 to be attached and enumerated
    11:07:03.648	Nordic DFU Trigger Interface was not found.Please physically reset device.
    11:07:03.652	Device not found due to failure during DFU
    11:09:41.233	Using USB SDFU protocol to communicate with target
    11:09:41.240	Error when calling version command: Error: Error message: Response from DFU target did not start with 0x60
    11:09:41.241	Error when fetching device versions: TypeError: Cannot read property 'part' of undefined

  • OK, it should work with keil as well if you remove the BOARDS_WITH_USB_DFU_TRIGGER flag from the list of preprocessor symbols here:

    And then add the app_usbd_cdc_acm.c source:

  • Bummer, I had done all that and still got the same result. The one I forgot about the longest was the BOARDS_WITH_USB_DFU_TRIGGER preprocessor. The Keil has a horrible interface for editing the preprocessor variables.

    I must be messing up something else..

    I found it. For some reason when I added the app_usbd_cdc_acm.c it was not included in the build. I didn't catch the lack of an asterisk on the icon. I'm surprised the code even built - it did. But after doing that, I get the same behavior as with Segger.

    This problem is solved! (Not that I understand it all.)  I give you a big thanks!

    By the way, in release it is easily small enough to be built by the free size limted Keil version (all I have for Keil).

Related