Merge pull request #17051 from bergzand/pr/riotboot_dfu/ztimer
riotboot_dfu: use ztimer instead of xtimer
This commit is contained in:
commit
aa4383104f
@ -5,7 +5,8 @@ APPLICATION = riotboot_dfu
|
||||
USEMODULE += riotboot_usb_dfu
|
||||
|
||||
# Use xtimer for scheduled reboot
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_auto_init
|
||||
|
||||
# USB device vendor and product ID
|
||||
# pid.codes test VID/PID, not globally unique
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "panic.h"
|
||||
#include "riotboot/slot.h"
|
||||
#include "riotboot/usb_dfu.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#include "bootloader_selection.h"
|
||||
|
||||
@ -70,6 +71,9 @@ void kernel_init(void)
|
||||
riotboot_slot_jump(slot);
|
||||
}
|
||||
|
||||
/* Init ztimer before starting DFU mode */
|
||||
ztimer_init();
|
||||
|
||||
/* Nothing to boot, stay in DFU mode to flash a slot */
|
||||
riotboot_usb_dfu_init(1);
|
||||
}
|
||||
|
||||
@ -690,6 +690,7 @@ endif
|
||||
ifneq (,$(filter riotboot_usb_dfu, $(USEMODULE)))
|
||||
USEMODULE += usbus_dfu
|
||||
USEMODULE += riotboot_flashwrite
|
||||
USEMODULE += ztimer_sec
|
||||
FEATURES_REQUIRED += no_idle_thread
|
||||
FEATURES_REQUIRED += periph_pm
|
||||
endif
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
#include "riotboot/magic.h"
|
||||
#include "riotboot/usb_dfu.h"
|
||||
#ifdef MODULE_RIOTBOOT_USB_DFU
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
#endif
|
||||
#include "periph/pm.h"
|
||||
|
||||
@ -48,7 +48,7 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler);
|
||||
|
||||
#ifdef MODULE_RIOTBOOT_USB_DFU
|
||||
static void _reboot(void *arg);
|
||||
static xtimer_t scheduled_reboot = { .callback=_reboot };
|
||||
static ztimer_t scheduled_reboot = { .callback=_reboot };
|
||||
#define REBOOT_DELAY 2
|
||||
#endif
|
||||
|
||||
@ -151,9 +151,6 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler)
|
||||
|
||||
/* attached alternate settings to their interface */
|
||||
usbus_add_interface_alt(&dfu->iface, &dfu->iface_alt_slot1);
|
||||
|
||||
/* Start xtimer for scheduled reboot after firmware upgrade */
|
||||
xtimer_init();
|
||||
#endif
|
||||
/* Add interface to the stack */
|
||||
usbus_add_interface(usbus, &dfu->iface);
|
||||
@ -217,7 +214,7 @@ static void _dfu_class_control_req(usbus_t *usbus, usbus_dfu_device_t *dfu, usb_
|
||||
/* Scheduled reboot, so we can answer back dfu-util before rebooting */
|
||||
dfu->dfu_state = USB_DFU_STATE_DFU_DL_IDLE;
|
||||
#ifdef MODULE_RIOTBOOT_USB_DFU
|
||||
xtimer_set(&scheduled_reboot, 1 * US_PER_SEC);
|
||||
ztimer_set(ZTIMER_SEC, &scheduled_reboot, 1);
|
||||
#endif
|
||||
}
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include "kernel_defines.h"
|
||||
#if IS_USED(MODULE_AUTO_INIT_ZTIMER)
|
||||
#if IS_USED(MODULE_AUTO_INIT_ZTIMER) || RIOTBOOT
|
||||
|
||||
#include "board.h"
|
||||
#include "ztimer.h"
|
||||
@ -302,4 +302,4 @@ void ztimer_init(void)
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#endif /* IS_USED(MODULE_AUTO_INIT_ZTIMER) */
|
||||
#endif /* IS_USED(MODULE_AUTO_INIT_ZTIMER) || RIOTBOOT*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user