From b842918d16977394b5ee822006adbf517ca4d0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Thu, 14 Feb 2019 18:59:32 +0100 Subject: [PATCH] set initial DFU state to ERROR if application is corrupt as specified in DFU standard Change-Id: Icd503a2d19f829eb43a83c28b526b73d595640f0 --- usb/class/dfu/device/dfudf.c | 1 - usb_dfu_main.c | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/usb/class/dfu/device/dfudf.c b/usb/class/dfu/device/dfudf.c index 8232979..223999a 100644 --- a/usb/class/dfu/device/dfudf.c +++ b/usb/class/dfu/device/dfudf.c @@ -306,7 +306,6 @@ int32_t dfudf_init(void) usbdc_register_function(&_dfudf); usbdc_register_handler(USBDC_HDL_REQ, &dfudf_req_h); - // TODO check if firmware is corrupted and set dfuERROR state if it is return ERR_NONE; } diff --git a/usb_dfu_main.c b/usb_dfu_main.c index 81b02f8..7fd54d3 100644 --- a/usb_dfu_main.c +++ b/usb_dfu_main.c @@ -101,6 +101,9 @@ int main(void) if (!check_force_dfu() && check_application()) { // application is valid start_application(); // start application } else { + if (!check_application()) { // if the application is corrupted the start DFU start should be dfuERROR + dfu_state = USB_DFU_STATE_DFU_ERROR; + } usb_dfu(); // start DFU bootloader } }