dfu: upload returns partition data

This commit is contained in:
King Kévin 2022-07-23 13:01:23 +02:00
parent 41c509a761
commit 4a53aab483
1 changed files with 12 additions and 0 deletions

View File

@ -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;
}