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

  • What I am currently trying to do is, everytime the USB dongle is plugged in it should enter the bootloader for 15 sec and then start the application. 

  • void otSysDfuMode(void)
    {
        #define BOOTLOADER_DFU_GPREGRET                 (0xB0)      
        #define BOOTLOADER_DFU_START_BIT_MASK           (0x01)  
        #define BOOTLOADER_DFU_START    (BOOTLOADER_DFU_GPREGRET | BOOTLOADER_DFU_START_BIT_MASK)      
        nrf_power_gpregret_set(BOOTLOADER_DFU_START);
        NVIC_SystemReset();
    }

    Hi Jorgen,

    With some changes in the function I was able to enter the DFU mode. But the problem I have now is it repeatedly enters the DFU mode for 15 sec and goes off, it is not moving to the application after trying the DFU once and after 15 sec start the application. 

    I know I have to make some changes so that it understands it, but I am not able to figure that out. 

    Kind regards,

    Tushar Diggewadi

  • Is there a valid application present?

    Have you debugged the bootloader to see where it fails to load the application? Does the device reset in the bootloader after the timeout and again start the DFU process?

  • Yes there is a valid application present. 

    Yes I had a long debug session. I set

    nrf_power_gpregret_set(BOOTLOADER_DFU_START);

    in my bootloader (main.c) so that the device should enter the DFU mode everytime it starts. But now it is in a loop. 

    As you asked, the device makes a reset after timeout and again starts the DFU.

    Where exactly I should use nrf_power_gpregret_set(BOOTLOADER_DFU_START) ? whether in bootloader main.c or in my application? Both ways if I do it I am going into a loop. 

    I just want the device to go into DFU for the first time on power up and then start the application.

  • 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);
    }

Reply
  • 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);
    }

Children
  • 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?

  • 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.

Related