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

  • I think I understand it better now. One last question, Should I define this macro in app_config.h and call the functions related in my firmware application or make changes in the bootloader application? (Currently I am using the open bootloader from the examples. (\nrf5sdkforthreadv41\examples\dfu\open_bootloader\pca10059_usb)

  • You need to enable the GPREGRET enter method in the bootloader's sdk_config.h file, and you need to modify your application to write the GPREGRET register with the correct value (for instance based on the USB event), before resetting the chip.

  • I was able to enable GPREGRET enter method and rebuild bootloader and flash it onto the dongle. I have the default mbr 

    The created bootloader is 

    At start as I do not have the application flashed it re enters the bootloader every 15 seconds. (as I have set #define NRF_BL_DFU_INACTIVITY_TIMEOUT_MS 15000)

    In my application main.c, I added this function and call it in main()

    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)      
        sd_power_gpregret_clr(0,0xffffffff);
        sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
        NVIC_SystemReset();
    }

    But now nothing is running on the device. I cannot see the COM port. I am a bit confused on this part.

    It would be really helpful if you could guide me with this in detail. 

    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

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

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

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

Related