fw.h 1.6 KB

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