This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Openthread: USB DFU Trigger library with Fanstel USB840F dongle

Hello,

I am currently using Fanstel dongle, where I am trying to trigger the USB DFU with nrf connect programmer (buttonless). The example which is provided works on the nrf52840 dongle but the same does not on Fanstel dongle because of different pin config on Fanstel. I am not able to trigger it with just changing the BSP_SELF_PINRESET_PIN (from 19 to 18). 

The application builds and runs on the Fanstel dongle but when I choose the device it does not send the device to DFU mode but gets stuck here,

11:17:07.112
Using nrf-device-lib-js version: 0.4.5
11:17:07.112
Using nrf-device-lib version: 0.11.0
11:17:07.112
Using nrfjprog DLL version: 10.15.1
11:17:07.113
Using JLink version: JLink_V7.64e
11:17:07.113
Installed JLink version does not match the provided version (V7.58b)
11:17:29.573
Using @nordicsemiconductor/nrf-device-lib-js to communicate with target via USB SDFU protocol

I exactly do not know how to move forward with it. I have tried many solutions provided here. I am using the OpenThread module (ot-nrf528xx). 

Kind regards,

Tushar Diggewadi

Parents
  • Hi,

    Changing BSP_SELF_PINRESET_PIN from 19 to 18 won't work, as P0.18 is the RESET pin itself. The USB DFU trigger library requires a different GPIO to be connected to the RESET pin, in order to enter the bootloader. On the nRF52840 Dongle, GPIO P0.19 is connected to P0.18/nRESET pin. As far as I can see, there is no such connections on the Fanstel USB840F schematics.

    Best regards,
    Jørgen

  • Hi Jorgen,

    Is it possible in anyway to trigger the DFU without pressing the buttons?

    Kind regards,

    Tushar

  • If you enabled NRF_BL_DFU_ENTER_METHOD_GPREGRET in the sdk_config.h file of the bootloader, you should not need to set/clear the register manually, this is handled in nrf_bootloader.c (dfu_enter_flags_clear()):

    if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &&
       ((nrf_power_gpregret_get() & BOOTLOADER_DFU_GPREGRET_MASK) == BOOTLOADER_DFU_GPREGRET)
            && (nrf_power_gpregret_get() & BOOTLOADER_DFU_START_BIT_MASK))
    {
        // Clear DFU mark in GPREGRET register.
        nrf_power_gpregret_set(nrf_power_gpregret_get() & ~BOOTLOADER_DFU_START);
    }

  • Yes I have enabled it in the sdk_config.h. But this does not send the device into DFU mode on every power up. Is it because my config for button press DFU is also enabled. Should I disable it?

    #ifndef NRF_BL_DFU_ENTER_METHOD_PINRESET
    #define NRF_BL_DFU_ENTER_METHOD_PINRESET 1
    #endif
    
    // <q> NRF_BL_DFU_ENTER_METHOD_GPREGRET  - Enter DFU mode when bit 0 is set in the NRF_POWER_GPREGRET register.
     
    
    #ifndef NRF_BL_DFU_ENTER_METHOD_GPREGRET
    #define NRF_BL_DFU_ENTER_METHOD_GPREGRET 1

  • static bool dfu_enter_check(void)
    {
        if (!app_is_valid(crc_on_valid_app_required()))
        {
            NRF_LOG_DEBUG("DFU mode because app is not valid.");
            return true;
        }
    
        if (NRF_BL_DFU_ENTER_METHOD_BUTTON &&
           (nrf_gpio_pin_read(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN) == 0))
        {
            NRF_LOG_DEBUG("DFU mode requested via button.");
            return true;
        }
    
        if (NRF_BL_DFU_ENTER_METHOD_PINRESET &&
           (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk))
        {
            NRF_LOG_DEBUG("DFU mode requested via pin-reset.");
            return true;
        }
    
        if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &&
           (nrf_power_gpregret_get() & BOOTLOADER_DFU_START))
        {
            NRF_LOG_DEBUG("DFU mode requested via GPREGRET.");
            return true;
        }
    
        if (NRF_BL_DFU_ENTER_METHOD_BUTTONLESS &&
           (s_dfu_settings.enter_buttonless_dfu == 1))
        {
            NRF_LOG_DEBUG("DFU mode requested via bootloader settings.");
            return true;
        }
    
        return false;
    }

    In this dfu_enter_check function if we not set the flag it will never enter the dfu... Is my understanding correct here?

  • Yes, if you do not want to enter the bootloader/DFU mode on pinreset, you should set NRF_BL_DFU_ENTER_METHOD_PINRESET to 0.

    If you do not set the flag in the GPREGRET register, and this is the only DFU_ENTER_METHOD you have activated, the DFU will not be entered (as long as there is a valid application present). As you can see from the top of  dfu_enter_check(), the DFU mode will be entered always if no valid application is detected.

  • Yes I understand what you are saying but this will be only the first time on power up. What I want is everytime I plug my dongle into a power source it should go into DFU mode for 15 seconds and then start the application. 

    Currently, it is not doing so. It enters th DFU mode when there is no application and NRF_BL_DFU_ENTER_METHOD_GPREGRET flag is set. But then when a valid application is there it will not enter the DFU. 

    I want it to enter everytime on power up and then start my application. If a valid application is there then we manually have to set the flag using nrf_power_gpregret_set(BOOTLOADER_DFU_START); to make it go into bootloader?

Reply
  • Yes I understand what you are saying but this will be only the first time on power up. What I want is everytime I plug my dongle into a power source it should go into DFU mode for 15 seconds and then start the application. 

    Currently, it is not doing so. It enters th DFU mode when there is no application and NRF_BL_DFU_ENTER_METHOD_GPREGRET flag is set. But then when a valid application is there it will not enter the DFU. 

    I want it to enter everytime on power up and then start my application. If a valid application is there then we manually have to set the flag using nrf_power_gpregret_set(BOOTLOADER_DFU_START); to make it go into bootloader?

Children
  • If you always want the bootloader to enter DFU mode, you can replace the call to dfu_enter_check() with "true". If you only want that to happen on power-on reset (not resets from application, wakeup from System OFF mode, etc), you can check the RESETREAS register to determine when to enter DFU mode.

  • Thank you so much for your answer. Checking the RESETREAS register does the trick for now. 

    uint32_t reset_reason = nrf_power_resetreas_get();
    
        if (reset_reason == 0x00000000)
        {
          nrf_power_gpregret_set(BOOTLOADER_DFU_START);
        }

    For information, I just added the above code in bootloader (main.c). The code checks whether its a Power on reset or a soft reset and sets the flag. 

Related