dfu: add logging
This commit is contained in:
parent
5409b96dde
commit
41c509a761
|
@ -39,6 +39,7 @@
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/timers.h"
|
#include "freertos/timers.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
#define USBD_STACK_SIZE 4096
|
#define USBD_STACK_SIZE 4096
|
||||||
#else
|
#else
|
||||||
|
@ -52,6 +53,8 @@
|
||||||
#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1)
|
#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const char* TAG = "DFU";
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
// MACRO CONSTANT TYPEDEF PROTYPES
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -106,6 +109,8 @@ int main(void)
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "DFU mode");
|
||||||
|
|
||||||
return 0;
|
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)
|
void tud_dfu_download_cb(uint8_t alt, uint16_t block_num, uint8_t const* data, uint16_t length)
|
||||||
{
|
{
|
||||||
esp_err_t rc;
|
esp_err_t rc;
|
||||||
|
ESP_LOGD(TAG, "download, alt=%u block=%u", alt, block_num);
|
||||||
|
|
||||||
if (alt > 0)
|
if (alt > 0)
|
||||||
{
|
{
|
||||||
|
ESP_LOGW(TAG, "download to invalid alt %u", alt);
|
||||||
tud_dfu_finish_flashing(DFU_STATUS_ERR_ADDRESS);
|
tud_dfu_finish_flashing(DFU_STATUS_ERR_ADDRESS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -212,6 +219,7 @@ void tud_dfu_manifest_cb(uint8_t alt)
|
||||||
{
|
{
|
||||||
(void) alt;
|
(void) alt;
|
||||||
esp_err_t rc;
|
esp_err_t rc;
|
||||||
|
ESP_LOGI(TAG, "download completed, enter manifestation");
|
||||||
|
|
||||||
// flashing op for manifest is complete without error
|
// flashing op for manifest is complete without error
|
||||||
// Application can perform checksum, should it fail, use appropriate status such as errVERIFY.
|
// 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;
|
uint16_t xfer_len = 0;
|
||||||
|
|
||||||
if (alt > 0) {
|
if (alt > 0) {
|
||||||
|
ESP_LOGW(TAG, "upload unknown alt %u", alt);
|
||||||
return 0;
|
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 tud_dfu_abort_cb(uint8_t alt)
|
||||||
{
|
{
|
||||||
(void) alt;
|
(void) alt;
|
||||||
|
ESP_LOGI(TAG, "host aborted transfer");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoked when a DFU_DETACH request is received
|
// Invoked when a DFU_DETACH request is received
|
||||||
void tud_dfu_detach_cb(void)
|
void tud_dfu_detach_cb(void)
|
||||||
{
|
{
|
||||||
|
ESP_LOGI(TAG, "host detach -> reboot");
|
||||||
esp_restart();
|
esp_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue