Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

244 linhas
7.8 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief WINC1500 SPI Flash.
  6. *
  7. * Copyright (c) 2016-2018 Atmel Corporation. All rights reserved.
  8. *
  9. * \asf_license_start
  10. *
  11. * \page License
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. *
  19. * 2. Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. *
  23. * 3. The name of Atmel may not be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  27. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  28. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  29. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  30. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  34. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  35. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * \asf_license_stop
  39. *
  40. */
  41. /**
  42. * @file spi_flash_map.h
  43. * @brief This module contains spi flash CONTENT
  44. * @author M.S.M
  45. * @date 17 SEPT 2013
  46. * @version 1.0
  47. */
  48. #ifndef __SPI_FLASH_MAP_H__
  49. #define __SPI_FLASH_MAP_H__
  50. #define FLASH_MAP_VER_0 (0)
  51. #define FLASH_MAP_VER_1 (1)
  52. #define FLASH_MAP_VER_2 (2)
  53. #define FLASH_MAP_VER_3 (3)
  54. #define FLASH_MAP_VERSION FLASH_MAP_VER_3
  55. //#define DOWNLOAD_ROLLBACK
  56. //#define OTA_GEN
  57. #define _PROGRAM_POWER_SAVE_
  58. /* =======*=======*=======*=======*=======
  59. * General Sizes for Flash Memory
  60. * =======*=======*=======*=======*=======
  61. */
  62. #define FLASH_START_ADDR (0UL)
  63. /*!<Starting Address of Flash Memory
  64. *
  65. */
  66. #define FLASH_BLOCK_SIZE (32 * 1024UL)
  67. /*!<Block Size in Flash Memory
  68. */
  69. #define FLASH_SECTOR_SZ (4 * 1024UL)
  70. /*!<Sector Size in Flash Memory
  71. */
  72. #define FLASH_PAGE_SZ (256)
  73. /*!<Page Size in Flash Memory
  74. */
  75. #define FLASH_2M_TOTAL_SZ (256 * 1024UL)
  76. /*!<Total Size of 2M Flash Memory
  77. */
  78. #define FLASH_4M_TOTAL_SZ (512 * 1024UL)
  79. /*!<Total Size of 4M Flash Memory
  80. */
  81. #define FLASH_8M_TOTAL_SZ (1024 * 1024UL)
  82. /*!<Total Size of 8M Flash Memory
  83. */
  84. /*
  85. * Detailed Sizes and locations for Flash Memory:
  86. * ____________________ ___________ ___________________________ _______________________________________________
  87. * | Starting Address | Size | Location's Name | Description |
  88. * |____________________|___________|___________________________|_______________________________________________|
  89. * | 0 K | 4 K | Boot Firmware | Firmware to select which version to run |
  90. * | 4 K | 8 K | Control Section | Structured data used by Boot firmware |
  91. * | 12 K | 4 K | PLL+GAIN : | LookUp Table for PLL and Gain calculations |
  92. * | | | PLL Size = 1K | PLL |
  93. * | | | GAIN Size = 3K | Gain configuration |
  94. * | 16 K | 4 K | CERTIFICATE | X.509 Certificate storage |
  95. * | 20 K | 8 K | TLS Server | TLS Server Private Key and certificates |
  96. * | 28 K | 8 K | HTTP Files | Files used with Provisioning Mode |
  97. * | 36 K | 4 K | Connection Parameters | Parameters for success connection to AP |
  98. * | 40 K | 236 K | Main Firmware/program | Main Firmware to run WiFi Chip |
  99. * | 276 K | 236 K | OTA Firmware | OTA firmware |
  100. * | 512 K Total flash size |
  101. * |____________________|___________|___________________________|_______________________________________________|
  102. *
  103. *
  104. * *Keys for Comments with each MACRO:
  105. * "L:xxxK" -means-> location :xxxK
  106. * "S:xxxK" -means-> Size is :xxxK
  107. */
  108. /*
  109. * Boot Firmware: which used to select which firmware to run
  110. *
  111. */
  112. #define M2M_BOOT_FIRMWARE_STARTING_ADDR (FLASH_START_ADDR)
  113. #define M2M_BOOT_FIRMWARE_FLASH_SZ (FLASH_SECTOR_SZ)
  114. /*
  115. * Control Section: which used by Boot firmware
  116. *
  117. */
  118. #define M2M_CONTROL_FLASH_OFFSET (M2M_BOOT_FIRMWARE_STARTING_ADDR + M2M_BOOT_FIRMWARE_FLASH_SZ)
  119. #define M2M_CONTROL_FLASH_BKP_OFFSET (M2M_CONTROL_FLASH_OFFSET + FLASH_SECTOR_SZ)
  120. #define M2M_CONTROL_FLASH_SEC_SZ (FLASH_SECTOR_SZ)
  121. #define M2M_CONTROL_FLASH_TOTAL_SZ (FLASH_SECTOR_SZ * 2)
  122. /*
  123. * LUT for PLL and TX Gain settings:
  124. *
  125. */
  126. #define M2M_PLL_FLASH_OFFSET (M2M_CONTROL_FLASH_OFFSET + M2M_CONTROL_FLASH_TOTAL_SZ)
  127. #define M2M_PLL_FLASH_SZ (1024 * 1)
  128. #define M2M_GAIN_FLASH_OFFSET (M2M_PLL_FLASH_OFFSET + M2M_PLL_FLASH_SZ)
  129. #define M2M_GAIN_FLASH_SZ (M2M_CONFIG_SECT_TOTAL_SZ - M2M_PLL_FLASH_SZ)
  130. #define M2M_CONFIG_SECT_TOTAL_SZ (FLASH_SECTOR_SZ)
  131. /*
  132. * Certificate:
  133. *
  134. */
  135. #define M2M_TLS_ROOTCER_FLASH_OFFSET (M2M_PLL_FLASH_OFFSET + M2M_CONFIG_SECT_TOTAL_SZ)
  136. #define M2M_TLS_ROOTCER_FLASH_SIZE (FLASH_SECTOR_SZ * 1)
  137. /*
  138. * Scratch:
  139. *
  140. */
  141. #define M2M_TLS_FLASH_SESSION_CACHE_OFFSET (M2M_TLS_FLASH_ROOTCERT_CACHE_OFFSET + M2M_TLS_FLASH_ROOTCERT_CACHE_SIZE)
  142. #define M2M_TLS_FLASH_SESSION_CACHE_SIZE (FLASH_SECTOR_SZ * 1)
  143. /*
  144. * reserved section
  145. *
  146. */
  147. #define M2M_TLS_SERVER_FLASH_OFFSET (M2M_TLS_ROOTCER_FLASH_OFFSET + M2M_TLS_ROOTCER_FLASH_SIZE)
  148. #define M2M_TLS_SERVER_FLASH_SIZE (FLASH_SECTOR_SZ * 2)
  149. /*
  150. * HTTP Files
  151. *
  152. */
  153. #define M2M_HTTP_MEM_FLASH_OFFSET (M2M_RESERVED_FLASH_OFFSET + M2M_RESERVED_FLASH_SZ)
  154. #define M2M_HTTP_MEM_FLASH_SZ (FLASH_SECTOR_SZ * 2)
  155. /*
  156. * Saved Connection Parameters:
  157. *
  158. */
  159. #define M2M_CACHED_CONNS_FLASH_OFFSET (M2M_HTTP_MEM_FLASH_OFFSET + M2M_HTTP_MEM_FLASH_SZ)
  160. #define M2M_CACHED_CONNS_FLASH_SZ (FLASH_SECTOR_SZ * 1)
  161. /*
  162. *
  163. * Common section size
  164. */
  165. #define M2M_COMMON_DATA_SEC \
  166. (M2M_BOOT_FIRMWARE_FLASH_SZ + M2M_CONTROL_FLASH_TOTAL_SZ + M2M_CONFIG_SECT_TOTAL_SZ \
  167. + M2M_TLS_FLASH_ROOTCERT_CACHE_SIZE + M2M_TLS_FLASH_SESSION_CACHE_SIZE + M2M_HTTP_MEM_FLASH_SZ \
  168. + M2M_CACHED_CONNS_FLASH_SZ + M2M_RESERVED_FLASH_SZ)
  169. /*
  170. *
  171. * OTA image1 Offset
  172. */
  173. #define M2M_OTA_IMAGE1_OFFSET (M2M_CACHED_CONNS_FLASH_OFFSET + M2M_CACHED_CONNS_FLASH_SZ)
  174. /*
  175. * Firmware Offset
  176. *
  177. */
  178. #if (defined _FIRMWARE_) || (defined OTA_GEN)
  179. #define M2M_FIRMWARE_FLASH_OFFSET (0UL)
  180. #else
  181. #if (defined DOWNLOAD_ROLLBACK)
  182. #define M2M_FIRMWARE_FLASH_OFFSET (M2M_OTA_IMAGE2_OFFSET)
  183. #else
  184. #define M2M_FIRMWARE_FLASH_OFFSET (M2M_OTA_IMAGE1_OFFSET)
  185. #endif
  186. #endif
  187. /*
  188. *
  189. * Firmware
  190. */
  191. #define M2M_FIRMWARE_FLASH_SZ (236 * 1024UL)
  192. /**
  193. *
  194. * OTA image Size
  195. */
  196. #define OTA_IMAGE_SIZE (M2M_FIRMWARE_FLASH_SZ)
  197. /**
  198. *
  199. * Flash Total size
  200. */
  201. #define FLASH_IMAGE1_CONTENT_SZ (M2M_COMMON_DATA_SEC + OTA_IMAGE_SIZE)
  202. /**
  203. *
  204. * OTA image 2 offset
  205. */
  206. #define M2M_OTA_IMAGE2_OFFSET (FLASH_IMAGE1_CONTENT_SZ)
  207. /*
  208. * App(Cortus App 4M): App. which runs over firmware
  209. *
  210. */
  211. #define M2M_APP_4M_MEM_FLASH_SZ (FLASH_SECTOR_SZ * 16)
  212. #define M2M_APP_4M_MEM_FLASH_OFFSET (FLASH_4M_TOTAL_SZ - M2M_APP_4M_MEM_FLASH_SZ)
  213. #define M2M_APP_8M_MEM_FLASH_OFFSET (M2M_OTA_IMAGE2_OFFSET + OTA_IMAGE_SIZE)
  214. #define M2M_APP_8M_MEM_FLASH_SZ (FLASH_SECTOR_SZ * 32)
  215. #define M2M_APP_OTA_MEM_FLASH_OFFSET (M2M_APP_8M_MEM_FLASH_OFFSET + M2M_APP_8M_MEM_FLASH_SZ)
  216. /* Check if total size of content
  217. * don't exceed total size of memory allowed
  218. **/
  219. #if (M2M_COMMON_DATA_SEC + (OTA_IMAGE_SIZE * 2) > FLASH_4M_TOTAL_SZ)
  220. #error "Excced 4M Flash Size"
  221. #endif /* (FLASH_CONTENT_SZ > FLASH_TOTAL_SZ) */
  222. #endif /* __SPI_FLASH_MAP_H__ */