This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Watchdog reset during bootloader dfu

Hello,

I am working on using the open_bootloader with our application and running into a problem.

We are using the GP_REG to jump from our application back to the bootloader to perform DFU, Our application uses the watchdog timer upon for monitoring  It appears that if we attempt to jump back to the bootloader for DFU the watchdog continues to run and hard resets the board as soon as the bootloader starts.  I know that is what is causing the reset in the bootloader because if we don't start the watchdog in our application there is no issue performing DFU.

I saw this post https://devzone.nordicsemi.com/f/nordic-q-a/3143/how-to-disable-the-wdt-watchdog-timer and attempted to do the same with no success.

I guess my question are:

1- Is there a way to disable the watchdog in our application before we attempt the DFU?

2- Is there a way to configure the open_bootloader to utilizes the watchdog or do we have to create our own bootloader?

Thanks

Omid

  • Hi Einar

    Another question related to loading the bootloader.

    I have a nrf52840 Dongle and I need to update its bootloader with the one I just built.  I generated a boot loader package successfully using nrfutil as following command:

    nrfutil pkg generate --debug-mode --hw-version 52 --bootloader ./open_bootloader_usb_mbr_pca10059_debug.hex --sd-id 0xCA bootloader.zip

    When I attempt to load this new bootloader I get an error: here is the complete output:

    ~/gitlabRepo/ble-fw-sd/dongle ᐅ nrfutil dfu usb-serial -p /dev/ttyACM1 -pkg ./bootloader.zip

    Traceback (most recent call last):
    File "/home/nikola/.local/bin/nrfutil", line 33, in <module>
    sys.exit(load_entry_point('nrfutil==6.1.0', 'console_scripts', 'nrfutil')())
    File "/usr/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
    File "/usr/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
    File "/usr/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/usr/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/usr/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File "/usr/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
    File "/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/__main__.py", line 1014, in usb_serial
    do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, serial_number, False,
    File "/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/__main__.py", line 970, in do_serial
    dfu.dfu_send_images()
    File "/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu.py", line 123, in dfu_send_images
    self._dfu_send_image(self.manifest.bootloader)
    File "/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu.py", line 95, in _dfu_send_image
    self.dfu_transport.send_init_packet(data)
    File "/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 256, in send_init_packet
    self.__execute()
    File "/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 421, in __execute
    self.__get_response(DfuTransportSerial.OP_CODE['Execute'])
    File "/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 502, in __get_response
    raise NordicSemiException('Extended Error 0x{:02X}: {}'.format(resp[3], data))
    pc_ble_driver_py.exceptions.NordicSemiException: Extended Error 0x08: The init packet does not contain a signature, but this bootloader requires all updates to have one.

    Obviously the current bootloader requires that the new bootloader have a signature.

    Is there a way to package my new bootloader so we can get the correct or expected signature?

    Thanks

  • Hi,

    OmidAthari said:
    Is there a way to package my new bootloader so we can get the correct or expected signature?

    The bootloader that the nRF52840 dongle ships with requires bootloader updates to be signed. (This is to prevent customers from accidentally bricking it). We do not distribute that key, so f you need to replace the bootloader on the dongle you need to do that via SWD the first time, programming it with a bootloader with your own public key. Please note that there are some pitfalls using SWD and the dongle, described in the last part of the nRF52840 dongle programming tutorial.

  • Hi Omid and Einar

    I wanted to share that I experienced the exact same issue as originally reported by Omid and the fix was as Einar suggested.

    When entering DFU mode from the application, using GPREGRET register, DFU mode would successfully enter but the device would reset shortly thereafter.

    I was able to determine that the reason for the reset was a watchdog timeout. The application starts the watchdog. Temporarily not starting the watchdog in the application would solve the reset problem after entering DFU. I didn't expect this as the loop_forever() function in the bootloader is supposed to feed the watchdog, and it was clearly not doing so, despite LFCLK running.

    By including the suggested line below in the bootloader main.c to trigger the clock task, the bootloader then starts feeding the watchdog, resolving my issue:

            nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART);

    This applies to SDK 17.0.2 on an nRF52840.

Related