diff --git a/examples/device/dfu_freertos/src/main.c b/examples/device/dfu_freertos/src/main.c index 69d0bb0ec..206f30dd4 100644 --- a/examples/device/dfu_freertos/src/main.c +++ b/examples/device/dfu_freertos/src/main.c @@ -40,6 +40,8 @@ #include "freertos/task.h" #include "freertos/timers.h" #include "esp_log.h" + #include "esp_partition.h" + #include "esp_ota_ops.h" #define USBD_STACK_SIZE 4096 #else @@ -238,6 +240,16 @@ uint16_t tud_dfu_upload_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint1 return 0; } + ESP_LOGD(TAG, "upload, alt=%u block=%u", alt, block_num); + const esp_partition_t * part = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL); + esp_err_t rc = esp_partition_read(part, block_num * CFG_TUD_DFU_XFER_BUFSIZE, data, length); + if (ESP_OK == rc) { + xfer_len = length; + } else { + xfer_len = 0; + ESP_LOGW(TAG, "reading flash failed"); + } + return xfer_len; }