Balance side (uart_ota.c): downloads io-firmware.bin from Gitea to RAM, computes SHA256, then streams to IO over UART1 (GPIO17/18, 460800 baud) as OTA_BEGIN/OTA_DATA/OTA_END frames with CRC8 + per-chunk ACK/retry (×3). IO side (uart_ota_recv.c): receives frames, writes to inactive OTA partition via esp_ota_write, verifies SHA256 on OTA_END, sets boot partition, reboots. IO board main.c + CMakeLists.txt scaffold included. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1.1 KiB
C
43 lines
1.1 KiB
C
/* main.c — ESP32-S3 IO board app_main */
|
|
|
|
#include "uart_ota_recv.h"
|
|
#include "config.h"
|
|
#include "esp_log.h"
|
|
#include "esp_ota_ops.h"
|
|
#include "driver/uart.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
|
|
static const char *TAG = "io_main";
|
|
|
|
static void uart_init(void)
|
|
{
|
|
uart_config_t cfg = {
|
|
.baud_rate = IO_UART_BAUD,
|
|
.data_bits = UART_DATA_8_BITS,
|
|
.parity = UART_PARITY_DISABLE,
|
|
.stop_bits = UART_STOP_BITS_1,
|
|
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
|
};
|
|
uart_param_config(IO_UART_PORT, &cfg);
|
|
uart_set_pin(IO_UART_PORT, IO_UART_TX_GPIO, IO_UART_RX_GPIO,
|
|
UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
|
uart_driver_install(IO_UART_PORT, 4096, 0, 0, NULL, 0);
|
|
}
|
|
|
|
void app_main(void)
|
|
{
|
|
ESP_LOGI(TAG, "ESP32-S3 IO v%s starting", IO_FW_VERSION);
|
|
|
|
/* Mark running image valid (OTA rollback support) */
|
|
esp_ota_mark_app_valid_cancel_rollback();
|
|
|
|
uart_init();
|
|
uart_ota_recv_init();
|
|
|
|
/* IO board main loop placeholder — RC/motor/sensor tasks added in later beads */
|
|
while (1) {
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
}
|
|
}
|