1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #pragma once
- #include "common.h"
- #include <zlib.h>
- /*
- * Firmware chunk header.
- */
- #define FW_MAGIC 0x7a07fbd6
- struct fw_header {
- uint32_t magic; /* Magic number */
- uint16_t type; /* Content type */
- uint16_t flags; /* Content flags */
- uint32_t len; /* Content length (excluding header) */
- uint32_t addr; /* Address or similar */
- };
- enum fw_data_type {
- FDT_END, /* End of stream */
- FDT_DATA, /* FPGA firmware ata to be flashed */
- FDT_TARGET, /* Subsystem string (must match) */
- FDT_NOTE, /* Version: XXXXX or similar */
- FDT_ESP_OTA, /* ESP32 OTA image */
- FDT_FPGA_INIT /* FPGA bitstream for update */
- };
- enum fw_data_flags {
- FDF_OPTIONAL = 0x0001 /* Ignore if chunk data type unknown */
- };
- /*
- * Additional error codes
- */
- #define FWUPDATE_ERR_IN_PROGRESS (-10)
- #define FWUPDATE_ERR_BAD_CHUNK (-11)
- #define FWUPDATE_ERR_ERASE_FAILED (-12)
- #define FWUPDATE_ERR_PROGRAM_FAILED (-13)
- #define FWUPDATE_ERR_WRITE_PROTECT (-14)
- #define FWUPDATE_ERR_NOT_READY (-15)
- #define FWUPDATE_ERR_FPGA_JTAG (-16)
- #define FWUPDATE_ERR_FPGA_MISMATCH (-17)
- #define FWUPDATE_ERR_FPGA_FAILED (-18)
- #define FWUPDATE_ERR_UNKNOWN (-19)
- #define FWUPDATE_ERR_ESP_NO_PARTITION (-20)
- #define FWUPDATE_ERR_ESP_BAD_OTA (-21)
- #define FWUPDATE_ERR_ESP_FLASH_FAILED (-22)
- #define FWUPDATE_ERR_ESP_BAD_DATA (-23)
- #define FWUPDATE_ERR_CONFIG_READ (-24)
- #define FWUPDATE_ERR_CONFIG_SAVE (-25)
- extern_c int firmware_update(read_func_t read_func, token_t token);
- extern_c int esp_update(read_func_t read_func, token_t token, size_t size);
- extern_c const char *firmware_errstr(int err);
|