#pragma once #include "common.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_ERASE_FAILED (-7) #define FWUPDATE_ERR_PROGRAM_FAILED (-8) #define FWUPDATE_ERR_WRITE_PROTECT (-9) #define FWUPDATE_ERR_NOT_READY (-10) #define FWUPDATE_ERR_DETECT (-11) #define FWUPDATE_ERR_DEVICE_MISMATCH (-12) #define FWUPDATE_ERR_IN_PROGRESS (-13) extern_c int firmware_update(read_func_t read_func, token_t token); extern_c esp_err_t esp_update(read_func_t read_func, token_t token, size_t size);