From 152213692bdaad29710c87ba862ea02a26bb8f91 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Mon, 5 Dec 2022 18:40:12 +0100 Subject: [PATCH] sys/riotboot: add tinyUSB DFU support --- sys/riotboot/tinyusb_dfu.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sys/riotboot/tinyusb_dfu.c diff --git a/sys/riotboot/tinyusb_dfu.c b/sys/riotboot/tinyusb_dfu.c new file mode 100644 index 0000000000..afb31ffed9 --- /dev/null +++ b/sys/riotboot/tinyusb_dfu.c @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 Gunar Schorcht + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup sys_riotboot_usb_dfu + * @ingroup pkg_tinyusb_dfu + * @{ + * @file tinyUSB Device Firmware Upgrade initialization for riotboot + * + * @author Gunar Schorcht + * @} + */ + +#include "riotboot/magic.h" + +#include "tinyusb.h" +#include "tinyusb_dfu.h" + +#define ENABLE_DEBUG 0 +#include "debug.h" + +extern void tinyusb_dfu_init(void); + +void riotboot_usb_dfu_init(unsigned forced) +{ + uint32_t *reset_addr = (uint32_t *)RIOTBOOT_MAGIC_ADDR; + + if (forced == 1 || *reset_addr == RIOTBOOT_MAGIC_NUMBER) { + *reset_addr = 0; + tinyusb_setup(); + tinyusb_dfu_init(); + } +}