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>
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
#ifndef OTA_UART_H
|
|
#define OTA_UART_H
|
|
|
|
#include "esp_err.h"
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#define OTA_UART_HOST_CHUNK_SIZE 200u
|
|
#define OTA_UART_FLASH_BLOCK_SIZE 4096u
|
|
|
|
/** OtaStatusPayload.status values (device → host). */
|
|
typedef enum {
|
|
OTA_UART_ST_PREPARING = 1,
|
|
OTA_UART_ST_READY = 2,
|
|
OTA_UART_ST_BLOCK_ACK = 3,
|
|
OTA_UART_ST_SUCCESS = 4,
|
|
OTA_UART_ST_FAILED = 5,
|
|
} ota_uart_status_t;
|
|
|
|
typedef enum {
|
|
OTA_FEED_OK = 0,
|
|
OTA_FEED_BLOCK_WRITTEN,
|
|
OTA_FEED_ERROR,
|
|
} ota_feed_result_t;
|
|
|
|
bool ota_uart_is_active(void);
|
|
|
|
/** 0/1 while session active, else -1. */
|
|
int ota_uart_target_slot(void);
|
|
|
|
/** Begin OTA on the inactive app partition (esp_ota_begin). Returns target slot 0/1. */
|
|
int ota_uart_prepare(uint32_t total_size);
|
|
|
|
void ota_uart_abort(void);
|
|
|
|
/** Append up to 200 bytes; flushes 4 KiB blocks to flash when full. */
|
|
ota_feed_result_t ota_uart_feed(const uint8_t *data, size_t len);
|
|
|
|
uint32_t ota_uart_bytes_written(void);
|
|
|
|
/** Flush remainder, esp_ota_end, set boot partition on success. */
|
|
esp_err_t ota_uart_finish(bool *success_out);
|
|
|
|
#endif
|