fw_header.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #ifndef __FW_HEADER_H__
  2. #define __FW_HEADER_H__
  3. #include "stdint.h"
  4. #include "stdio.h"
  5. struct __attribute__((packed, aligned(4))) spi_flash_cfg_t {
  6. uint8_t ioMode; /*!< Serail flash interface mode,bit0-3:IF mode,bit4:unwrap */
  7. uint8_t cReadSupport; /*!< Support continuous read mode,bit0:continuous read mode support,bit1:read mode cfg */
  8. uint8_t clkDelay; /*!< SPI clock delay,bit0-3:delay,bit4-6:pad delay */
  9. uint8_t clkInvert; /*!< SPI clock phase invert,bit0:clck invert,bit1:rx invert,bit2-4:pad delay,bit5-7:pad delay */
  10. uint8_t resetEnCmd; /*!< Flash enable reset command */
  11. uint8_t resetCmd; /*!< Flash reset command */
  12. uint8_t resetCreadCmd; /*!< Flash reset continuous read command */
  13. uint8_t resetCreadCmdSize; /*!< Flash reset continuous read command size */
  14. uint8_t jedecIdCmd; /*!< JEDEC ID command */
  15. uint8_t jedecIdCmdDmyClk; /*!< JEDEC ID command dummy clock */
  16. uint8_t enter32BitsAddrCmd; /*!< Enter 32-bits addr command */
  17. uint8_t exit32BitsAddrCmd; /*!< Exit 32-bits addr command */
  18. uint8_t sectorSize; /*!< *1024bytes */
  19. uint8_t mid; /*!< Manufacturer ID */
  20. uint16_t pageSize; /*!< Page size */
  21. uint8_t chipEraseCmd; /*!< Chip erase cmd */
  22. uint8_t sectorEraseCmd; /*!< Sector erase command */
  23. uint8_t blk32EraseCmd; /*!< Block 32K erase command,some Micron not support */
  24. uint8_t blk64EraseCmd; /*!< Block 64K erase command */
  25. uint8_t writeEnableCmd; /*!< Need before every erase or program */
  26. uint8_t pageProgramCmd; /*!< Page program cmd */
  27. uint8_t qpageProgramCmd; /*!< QIO page program cmd */
  28. uint8_t qppAddrMode; /*!< QIO page program address mode */
  29. uint8_t fastReadCmd; /*!< Fast read command */
  30. uint8_t frDmyClk; /*!< Fast read command dummy clock */
  31. uint8_t qpiFastReadCmd; /*!< QPI fast read command */
  32. uint8_t qpiFrDmyClk; /*!< QPI fast read command dummy clock */
  33. uint8_t fastReadDoCmd; /*!< Fast read dual output command */
  34. uint8_t frDoDmyClk; /*!< Fast read dual output command dummy clock */
  35. uint8_t fastReadDioCmd; /*!< Fast read dual io comamnd */
  36. uint8_t frDioDmyClk; /*!< Fast read dual io command dummy clock */
  37. uint8_t fastReadQoCmd; /*!< Fast read quad output comamnd */
  38. uint8_t frQoDmyClk; /*!< Fast read quad output comamnd dummy clock */
  39. uint8_t fastReadQioCmd; /*!< Fast read quad io comamnd */
  40. uint8_t frQioDmyClk; /*!< Fast read quad io comamnd dummy clock */
  41. uint8_t qpiFastReadQioCmd; /*!< QPI fast read quad io comamnd */
  42. uint8_t qpiFrQioDmyClk; /*!< QPI fast read QIO dummy clock */
  43. uint8_t qpiPageProgramCmd; /*!< QPI program command */
  44. uint8_t writeVregEnableCmd; /*!< Enable write reg */
  45. uint8_t wrEnableIndex; /*!< Write enable register index */
  46. uint8_t qeIndex; /*!< Quad mode enable register index */
  47. uint8_t busyIndex; /*!< Busy status register index */
  48. uint8_t wrEnableBit; /*!< Write enable bit pos */
  49. uint8_t qeBit; /*!< Quad enable bit pos */
  50. uint8_t busyBit; /*!< Busy status bit pos */
  51. uint8_t wrEnableWriteRegLen; /*!< Register length of write enable */
  52. uint8_t wrEnableReadRegLen; /*!< Register length of write enable status */
  53. uint8_t qeWriteRegLen; /*!< Register length of contain quad enable */
  54. uint8_t qeReadRegLen; /*!< Register length of contain quad enable status */
  55. uint8_t releasePowerDown; /*!< Release power down command */
  56. uint8_t busyReadRegLen; /*!< Register length of contain busy status */
  57. uint8_t readRegCmd[4]; /*!< Read register command buffer */
  58. uint8_t writeRegCmd[4]; /*!< Write register command buffer */
  59. uint8_t enterQpi; /*!< Enter qpi command */
  60. uint8_t exitQpi; /*!< Exit qpi command */
  61. uint8_t cReadMode; /*!< Config data for continuous read mode */
  62. uint8_t cRExit; /*!< Config data for exit continuous read mode */
  63. uint8_t burstWrapCmd; /*!< Enable burst wrap command */
  64. uint8_t burstWrapCmdDmyClk; /*!< Enable burst wrap command dummy clock */
  65. uint8_t burstWrapDataMode; /*!< Data and address mode for this command */
  66. uint8_t burstWrapData; /*!< Data to enable burst wrap */
  67. uint8_t deBurstWrapCmd; /*!< Disable burst wrap command */
  68. uint8_t deBurstWrapCmdDmyClk; /*!< Disable burst wrap command dummy clock */
  69. uint8_t deBurstWrapDataMode; /*!< Data and address mode for this command */
  70. uint8_t deBurstWrapData; /*!< Data to disable burst wrap */
  71. uint16_t timeEsector; /*!< 4K erase time */
  72. uint16_t timeE32k; /*!< 32K erase time */
  73. uint16_t timeE64k; /*!< 64K erase time */
  74. uint16_t timePagePgm; /*!< Page program time */
  75. uint16_t timeCe; /*!< Chip erase time in ms */
  76. uint8_t pdDelay; /*!< Release power down command delay time for wake up */
  77. uint8_t qeData; /*!< QE set data */
  78. };
  79. struct __attribute__((packed, aligned(4))) boot_flash_cfg_t {
  80. uint32_t magiccode;
  81. struct spi_flash_cfg_t cfg;
  82. uint32_t crc32;
  83. };
  84. struct __attribute__((packed, aligned(4))) sys_clk_cfg_t {
  85. uint8_t xtal_type;
  86. uint8_t pll_clk;
  87. uint8_t hclk_div;
  88. uint8_t bclk_div;
  89. uint8_t flash_clk_type;
  90. uint8_t flash_clk_div;
  91. uint8_t rsvd[2];
  92. };
  93. struct __attribute__((packed, aligned(4))) boot_clk_cfg_t {
  94. uint32_t magiccode;
  95. struct sys_clk_cfg_t cfg;
  96. uint32_t crc32;
  97. };
  98. struct __attribute__((packed, aligned(4))) aesiv_cfg_t {
  99. uint8_t aesiv[16];
  100. uint32_t crc32;
  101. };
  102. struct __attribute__((packed, aligned(4))) pkey_cfg_t {
  103. uint8_t eckeyx[32]; /* ec key in boot header */
  104. uint8_t eckeyy[32]; /* ec key in boot header */
  105. uint32_t crc32;
  106. };
  107. struct __attribute__((packed, aligned(4))) sign_cfg_t {
  108. uint32_t sig_len;
  109. uint8_t signature[32];
  110. uint32_t crc32;
  111. };
  112. struct __attribute__((packed, aligned(4))) bootheader_t {
  113. uint32_t magiccode; /*'BFXP'*/
  114. uint32_t rivison;
  115. struct boot_flash_cfg_t flash_cfg;
  116. struct boot_clk_cfg_t clk_cfg;
  117. union __attribute__((packed, aligned(1))) {
  118. struct __attribute__((packed, aligned(1))) {
  119. uint32_t sign : 2; /* [1: 0] for sign */
  120. uint32_t encrypt_type : 2; /* [3: 2] for encrypt */
  121. uint32_t key_sel : 2; /* [5: 4] for key sel in boot interface */
  122. uint32_t rsvd_7_6 : 2; /* [7: 6] rsvd */
  123. uint32_t no_segment : 1; /* [8] no segment info */
  124. uint32_t cache_select : 1; /* [9] cache enable */
  125. uint32_t notload_in_bootrom : 1; /* [10] not load this img in bootrom */
  126. uint32_t aes_region_lock : 1; /* [11] aes region lock */
  127. uint32_t cache_way_disable : 4; /* [15: 12] cache way disable info */
  128. uint32_t crc_ignore : 1; /* [16] ignore crc */
  129. uint32_t hash_ignore : 1; /* [17] ignore hash */
  130. uint32_t halt_ap : 1; /* [18] halt ap */
  131. uint32_t boot2_enable : 1; /* [19] boot2 enable */
  132. uint32_t boot2_rollback : 1; /* [20] boot2 rollback */
  133. uint32_t rsvd_31_21 : 11; /* [31: 21] rsvd */
  134. } bval;
  135. uint32_t wval;
  136. } boot_cfg;
  137. union __attribute__((packed, aligned(1))) {
  138. uint32_t segment_cnt;
  139. uint32_t img_len;
  140. } img_segment_info;
  141. uint32_t rsvd0; /* rsvd */
  142. union __attribute__((packed, aligned(1))) {
  143. uint32_t ramaddr;
  144. uint32_t flashoffset;
  145. } img_start;
  146. uint32_t hash[32 / 4]; /*hash of the image*/
  147. uint32_t boot2_pt_table_0; /* address of partition table 0 */
  148. uint32_t boot2_pt_table_1; /* address of partition table 1 */
  149. uint32_t crc32;
  150. };
  151. #define BFLB_FW_LENGTH_OFFSET 120
  152. #define BFLB_FW_HASH_OFFSET 132
  153. #endif