Add UART OTA upload with A/B partition support.
Firmware buffers 200-byte chunks into 4 KiB blocks for esp_ota_write; goTool uploads with per-block ACK flow control and larger UART buffers to avoid stalls. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+21
-4
@@ -4,6 +4,7 @@
|
||||
#include "cmd_espnow_unicast_test.h"
|
||||
#include "cmd_client_info.h"
|
||||
#include "cmd_version.h"
|
||||
#include "cmd_ota.h"
|
||||
#include "esp_now_comm.h"
|
||||
#include "powerpod.h"
|
||||
#include "driver/gpio.h"
|
||||
@@ -50,6 +51,8 @@ static i2c_master_dev_handle_t io_expander;
|
||||
|
||||
static app_config_t app_config;
|
||||
|
||||
const app_config_t *app_config_get(void) { return &app_config; }
|
||||
|
||||
static QueueHandle_t cmd_queue;
|
||||
|
||||
uint8_t reverse_high_nibble_lut(uint8_t n) {
|
||||
@@ -123,16 +126,29 @@ void app_main(void) {
|
||||
}
|
||||
|
||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||
int ota_slot = -1;
|
||||
if (running != NULL) {
|
||||
if (running->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_0) {
|
||||
ota_slot = 0;
|
||||
} else if (running->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_1) {
|
||||
ota_slot = 1;
|
||||
}
|
||||
}
|
||||
|
||||
app_config.master = (master != 0);
|
||||
app_config.network = network;
|
||||
memcpy(app_config.running_partition, running->label,
|
||||
sizeof(app_config.running_partition));
|
||||
if (running != NULL) {
|
||||
memcpy(app_config.running_partition, running->label,
|
||||
sizeof(app_config.running_partition));
|
||||
} else {
|
||||
app_config.running_partition[0] = '\0';
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "RUNNING CONFIG:");
|
||||
ESP_LOGI(TAG, "Master: %d", app_config.master);
|
||||
ESP_LOGI(TAG, "Network: %d", app_config.network);
|
||||
ESP_LOGI(TAG, "Running Partition: %s", app_config.running_partition);
|
||||
ESP_LOGI(TAG, "Running Partition: %s (OTA slot %d)",
|
||||
app_config.running_partition, ota_slot);
|
||||
|
||||
err = esp_now_comm_init(&app_config);
|
||||
if (err != ESP_OK) {
|
||||
@@ -144,13 +160,14 @@ void app_main(void) {
|
||||
board_input_init();
|
||||
|
||||
if (app_config.master) {
|
||||
cmd_queue = xQueueCreate(10, sizeof(generic_msg_t));
|
||||
cmd_queue = xQueueCreate(64, sizeof(generic_msg_t));
|
||||
init_cmdHandler(cmd_queue);
|
||||
init_uart(cmd_queue);
|
||||
cmd_version_register();
|
||||
cmd_client_info_register();
|
||||
cmd_accel_deadzone_register();
|
||||
cmd_espnow_unicast_test_register();
|
||||
cmd_ota_register();
|
||||
}
|
||||
|
||||
uint8_t current_digit = 10;
|
||||
|
||||
Reference in New Issue
Block a user