2
0

fwimg.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Common firmware image format
  3. */
  4. #ifndef FWIMG_H
  5. #define FWIMG_H
  6. #include <inttypes.h>
  7. /*
  8. * Firmware chunk header.
  9. */
  10. #define FW_MAGIC_V1 0x7a07fbd6
  11. #define FW_MAGIC_V2 0xa924ed0b
  12. #define FW_HDR_LEN_V1 16
  13. #define FW_HDR_LEN_V2 32
  14. struct fw_header {
  15. /* All versions */
  16. uint32_t magic; /* Magic number */
  17. uint16_t type; /* Content type */
  18. uint16_t flags; /* Content flags */
  19. uint32_t len; /* Content length (excluding header) */
  20. uint32_t addr; /* Address or similar */
  21. /* v2 only */
  22. uint32_t vmatch; /* Flags to match */
  23. uint32_t vmask; /* Mask of flags to match */
  24. uint16_t vmin; /* Minimum version match */
  25. uint16_t vmax; /* Maximum version match */
  26. uint32_t resv; /* For future use */
  27. };
  28. enum fw_data_type {
  29. FDT_END, /* End of stream */
  30. FDT_DATA, /* FPGA firmware ata to be flashed */
  31. FDT_TARGET, /* Subsystem string (must match) */
  32. FDT_NOTE, /* Version: XXXXX or similar */
  33. FDT_ESP_OTA, /* ESP32 OTA image */
  34. FDT_FPGA_INIT, /* FPGA bitstream for update */
  35. FDT_ESP_PART, /* ESP32 partition table */
  36. FDT_ESP_SYS, /* ESP32 boot loader, OTA control, etc */
  37. FDT_ESP_TOOL, /* esptool.py options for serial flashing */
  38. FDT_BOARDINFO /* Board information flash address */
  39. };
  40. enum fw_data_flags {
  41. FDF_OPTIONAL = 0x0001, /* Ignore if chunk data type unknown */
  42. FDF_PRETARGET = 0x0002 /* Matching FDT_TARGET not required (yet) */
  43. };
  44. /*
  45. * Additional error codes beyond those defined in zlib
  46. */
  47. #define FWUPDATE_ERR_IN_PROGRESS (-10)
  48. #define FWUPDATE_ERR_BAD_CHUNK (-11)
  49. #define FWUPDATE_ERR_ERASE_FAILED (-12)
  50. #define FWUPDATE_ERR_PROGRAM_FAILED (-13)
  51. #define FWUPDATE_ERR_WRITE_PROTECT (-14)
  52. #define FWUPDATE_ERR_NOT_READY (-15)
  53. #define FWUPDATE_ERR_FPGA_JTAG (-16)
  54. #define FWUPDATE_ERR_FPGA_MISMATCH (-17)
  55. #define FWUPDATE_ERR_FPGA_FAILED (-18)
  56. #define FWUPDATE_ERR_UNKNOWN (-19)
  57. #define FWUPDATE_ERR_ESP_NO_PARTITION (-20)
  58. #define FWUPDATE_ERR_ESP_BAD_OTA (-21)
  59. #define FWUPDATE_ERR_ESP_FLASH_FAILED (-22)
  60. #define FWUPDATE_ERR_ESP_BAD_DATA (-23)
  61. #define FWUPDATE_ERR_CONFIG_READ (-24)
  62. #define FWUPDATE_ERR_CONFIG_SAVE (-25)
  63. #define FWUPDATE_ERR_NOT_MINE (-26)
  64. #endif /* FW_H */