This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 8111e161f tinyusb/dfu: Use cputimer for delayed reset
8111e161f is described below
commit 8111e161fced55401ec6b53f25bf7804971be359
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Sat Jun 8 15:57:12 2024 +0200
tinyusb/dfu: Use cputimer for delayed reset
Delayed reset after download was using callout before that
was not working in bootloader.
Now same functionality is activate via cputimer in bootloader.
Default timout before reboot increased to 2s to aviod
Windows dfu-util error message after update.
Signed-off-by: Jerzy Kasenberg <[email protected]>
---
hw/usb/tinyusb/dfu/src/dfu.c | 6 ++++++
hw/usb/tinyusb/dfu/syscfg.yml | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/usb/tinyusb/dfu/src/dfu.c b/hw/usb/tinyusb/dfu/src/dfu.c
index 030332f0a..445214923 100644
--- a/hw/usb/tinyusb/dfu/src/dfu.c
+++ b/hw/usb/tinyusb/dfu/src/dfu.c
@@ -146,6 +146,7 @@ tud_dfu_manifest_cb(uint8_t alt)
tud_dfu_finish_flashing(DFU_STATUS_OK);
#if MYNEWT_VAL(USBD_DFU_RESET_AFTER_DOWNLOAD)
+#if MYNEWT_VAL(OS_SCHEDULING)
/*
* Device should reboot after download is complete.
* It should be done after final DFU_GETSTATUS. But this event is not
@@ -155,6 +156,11 @@ tud_dfu_manifest_cb(uint8_t alt)
*/
os_callout_init(&delayed_reset_callout, os_eventq_dflt_get(),
delayed_reset_cb, NULL);
os_callout_reset(&delayed_reset_callout,
os_time_ms_to_ticks32(MYNEWT_VAL(USBD_DFU_RESET_TIMEOUT)));
+#else
+ static struct hal_timer reboot_timer;
+ os_cputime_timer_init(&reboot_timer, (hal_timer_cb)delayed_reset_cb, NULL);
+ os_cputime_timer_relative(&reboot_timer,
MYNEWT_VAL(USBD_DFU_RESET_TIMEOUT) * 1000);
+#endif
#endif
}
diff --git a/hw/usb/tinyusb/dfu/syscfg.yml b/hw/usb/tinyusb/dfu/syscfg.yml
index 95229aa44..40c246b06 100644
--- a/hw/usb/tinyusb/dfu/syscfg.yml
+++ b/hw/usb/tinyusb/dfu/syscfg.yml
@@ -68,7 +68,7 @@ syscfg.defs:
Some messages are not propagated to DFU user code (they are
internally processed by
TinyUSB stack) and rebooting just after download is finished while
does not make
any harm to DFU process, confuses DFU utilities.
- value: 1000
+ value: 2000
USBD_DFU_DETACH_TIMEOUT:
description: >
Time, in milliseconds, that the device will wait after receipt of
the