From 41c509a76114b3b801d4169d44f73e710516605c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sat, 23 Jul 2022 12:57:57 +0200 Subject: [PATCH] dfu: add logging --- examples/device/dfu_freertos/src/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/device/dfu_freertos/src/main.c b/examples/device/dfu_freertos/src/main.c index 6813a57a6..69d0bb0ec 100644 --- a/examples/device/dfu_freertos/src/main.c +++ b/examples/device/dfu_freertos/src/main.c @@ -39,6 +39,7 @@ #include "freertos/queue.h" #include "freertos/task.h" #include "freertos/timers.h" + #include "esp_log.h" #define USBD_STACK_SIZE 4096 #else @@ -52,6 +53,8 @@ #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1) #endif +static const char* TAG = "DFU"; + //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF PROTYPES //--------------------------------------------------------------------+ @@ -106,6 +109,8 @@ int main(void) vTaskStartScheduler(); #endif + ESP_LOGI(TAG, "DFU mode"); + return 0; } @@ -194,9 +199,11 @@ uint32_t tud_dfu_get_timeout_cb(uint8_t alt, uint8_t state) void tud_dfu_download_cb(uint8_t alt, uint16_t block_num, uint8_t const* data, uint16_t length) { esp_err_t rc; + ESP_LOGD(TAG, "download, alt=%u block=%u", alt, block_num); if (alt > 0) { + ESP_LOGW(TAG, "download to invalid alt %u", alt); tud_dfu_finish_flashing(DFU_STATUS_ERR_ADDRESS); return; } @@ -212,6 +219,7 @@ void tud_dfu_manifest_cb(uint8_t alt) { (void) alt; esp_err_t rc; + ESP_LOGI(TAG, "download completed, enter manifestation"); // flashing op for manifest is complete without error // Application can perform checksum, should it fail, use appropriate status such as errVERIFY. @@ -226,6 +234,7 @@ uint16_t tud_dfu_upload_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint1 uint16_t xfer_len = 0; if (alt > 0) { + ESP_LOGW(TAG, "upload unknown alt %u", alt); return 0; } @@ -236,11 +245,13 @@ uint16_t tud_dfu_upload_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint1 void tud_dfu_abort_cb(uint8_t alt) { (void) alt; + ESP_LOGI(TAG, "host aborted transfer"); } // Invoked when a DFU_DETACH request is received void tud_dfu_detach_cb(void) { + ESP_LOGI(TAG, "host detach -> reboot"); esp_restart(); }