spi_flash_map.h
Go to the documentation of this file.
1 
35 #ifndef __SPI_FLASH_MAP_H__
36 #define __SPI_FLASH_MAP_H__
37 
38 //#define DOWNLOAD_ROLLBACK
39 //#define OTA_GEN
40 #define _PROGRAM_POWER_SAVE_
41 #define BT_IMAGE_PRESENT
42 
43 /* =======*=======*=======*=======*=======
44  * General Sizes for Flash Memory
45  * =======*=======*=======*=======*=======
46  */
47 
48 #define FLASH_START_ADDR (0UL)
49 
52 #define FLASH_BLOCK_SIZE (32 * 1024UL)
53 
55 #define FLASH_SECTOR_SZ (4 * 1024UL)
56 
58 #define FLASH_PAGE_SZ (256)
59 
62 #define FLASH_2M_TOTAL_SZ (256 * 1024UL)
63 
65 #define FLASH_4M_TOTAL_SZ (512 * 1024UL)
66 
68 #define FLASH_8M_TOTAL_SZ (1024 * 1024UL)
69 
72 /*
73  * Detailed Sizes and locations for 8M Flash Memory:
74  * ____________________ ___________ ___________________________ _______________________________________________
75  * | Starting Address | Size | Location's Name | Description |
76  * |____________________|___________|___________________________|_______________________________________________|
77  * | 0 K | 4 K | Boot Firmware | Firmware to select which version to run |
78  * | 4 K | 8 K | Control Section | Structured data used by Boot firmware |
79  * | 8 K | 4 K | Backup | Generic sector backup |
80  * | 12 K | 8 K | PLL+GAIN : | LookUp Table for PLL and Gain calculations |
81  * | | | PLL Size = 2K | PLL |
82  * | | | GAIN Size = 6K | Gain configuration |
83  * | 20 K | 4 K | TLS CERTIFICATE | X.509 Root certificate storage |
84  * | 24 K | 8 K | TLS Server | TLS Server Private Key and certificates |
85  * | 32 K | 4 K | Connection Parameters | Parameters for success connection to AP |
86  * | 36 K | 8 K | Program Firmware | Downloader firmware |
87  * | 44 K | 296 K | Main Firmware | Main Firmware to run WiFi Chip |
88  * | 340 K | 8 K | HTTP Files | Files used with Provisioning Mode |
89  * | 348 K | 0 K | PS_Firmware | Power Save Firmware (Unused) |
90  * | 348 K | 160 K | BT Firmware | BT Firmware for BT Cortus |
91  * | 508 K | 4 K | Host control section | Structured data used by Host driver |
92  * | 512 K | 472 K | OTA | OTA image |
93  * | | | Program Firmware | |
94  * | | | Main Firmware | |
95  * | | | HTTP Files | |
96  * | | | BT Firmware | |
97  * | 984 K | 40 K | Empty | Unused |
98  * |____________________|___________|___________________________|_______________________________________________|
99  *
100  *
101  */
102 
103 /*
104  * Boot Firmware: used to select which firmware to run
105  */
106 #define M2M_BOOT_FIRMWARE_STARTING_ADDR (FLASH_START_ADDR)
107 #define M2M_BOOT_FIRMWARE_FLASH_SZ (FLASH_SECTOR_SZ * 1)
108 
109 /*
110  * Control Section: used by Boot firmware
111  */
112 #define M2M_CONTROL_FLASH_OFFSET (M2M_BOOT_FIRMWARE_STARTING_ADDR + M2M_BOOT_FIRMWARE_FLASH_SZ)
113 #define M2M_CONTROL_FLASH_SZ (FLASH_SECTOR_SZ * 1)
114 
115 /*
116  * Generic Sector Backup: used as backup in case of interruption during sector read-erase-write
117  */
118 #define M2M_BACKUP_FLASH_OFFSET (M2M_CONTROL_FLASH_OFFSET + M2M_CONTROL_FLASH_SZ)
119 #define M2M_BACKUP_FLASH_SZ (FLASH_SECTOR_SZ * 1)
120 
121 /*
122  * LUT for PLL and TX Gain settings
123  */
124 #define M2M_PLL_FLASH_OFFSET (M2M_BACKUP_FLASH_OFFSET + M2M_BACKUP_FLASH_SZ)
125 #define M2M_PLL_MAGIC_NUMBER_FLASH_SZ (2*4) // 2 32bit values
126 #define M2M_PLL_WIFI_CHAN_FLASH_OFFSET (M2M_PLL_FLASH_OFFSET + M2M_PLL_MAGIC_NUMBER_FLASH_SZ)
127 #define M2M_PLL_WIFI_CHAN_FLASH_SZ (14*8*4) // Wifi Channels 1 to 14 inclusive, 8 32bit values for each channel.
128 #define M2M_PLL_FREQ_FLASH_OFFSET (M2M_PLL_WIFI_CHAN_FLASH_OFFSET + M2M_PLL_WIFI_CHAN_FLASH_SZ)
129 #define M2M_PLL_FREQ_FLASH_SZ ((1+84)*4) // Frequencies 2401 to 2484MHz inclusive, also 1920 used for cpll compensate.
130 #define M2M_PLL_FLASH_SZ (1024 * 2)
131 #define M2M_GAIN_FLASH_OFFSET (M2M_PLL_FLASH_OFFSET + M2M_PLL_FLASH_SZ)
132 #define M2M_GAIN_FLASH_SZ (M2M_CONFIG_SECT_TOTAL_SZ - M2M_PLL_FLASH_SZ)
133 #define M2M_CONFIG_SECT_TOTAL_SZ (FLASH_SECTOR_SZ * 2)
134 
135 /*
136  * TLS Certificates
137  */
138 #define M2M_TLS_ROOTCER_FLASH_OFFSET (M2M_PLL_FLASH_OFFSET + M2M_CONFIG_SECT_TOTAL_SZ)
139 #define M2M_TLS_ROOTCER_FLASH_SZ (FLASH_SECTOR_SZ * 1)
140 #define M2M_TLS_ROOTCER_FLASH_SIG {0x01,0xF1,0x02,0xF2,0x03,0xF3,0x04,0xF4,0x05,0xF5,0x06,0xF6,0x07,0xF7,0x08,0xF8}
141 #define M2M_TLS_ROOTCER_FLASH_SIG_LENGTH 16
142 
145 /*
146  * TLS Server Key Files
147  */
148 #define M2M_TLS_SERVER_FLASH_OFFSET (M2M_TLS_ROOTCER_FLASH_OFFSET + M2M_TLS_ROOTCER_FLASH_SZ)
149 #define M2M_TLS_SERVER_FLASH_SZ (FLASH_SECTOR_SZ * 2)
150 #define M2M_TLS_SERVER_FLASH_SIG
151 
152 /*
153  * Saved Connection Parameters
154  */
155 #define M2M_CACHED_CONNS_FLASH_OFFSET (M2M_TLS_SERVER_FLASH_OFFSET + M2M_TLS_SERVER_FLASH_SZ)
156 #define M2M_CACHED_CONNS_FLASH_SZ (FLASH_SECTOR_SZ * 1)
157 #define M2M_CACHED_CONNS_FLASH_SIG
158 
159 /*
160  *
161  * OTA image1 Offset (Firmware offset)
162  */
163 #define M2M_OTA_IMAGE1_OFFSET (M2M_CACHED_CONNS_FLASH_OFFSET + M2M_CACHED_CONNS_FLASH_SZ)
164 
165 /*
166  * Common section size
167  */
168 #define FLASH_COMMON_SZ (\
169  M2M_BOOT_FIRMWARE_FLASH_SZ +\
170  M2M_CONTROL_FLASH_SZ +\
171  M2M_BACKUP_FLASH_SZ +\
172  M2M_CONFIG_SECT_TOTAL_SZ +\
173  M2M_TLS_ROOTCER_FLASH_SZ +\
174  M2M_TLS_SERVER_FLASH_SZ +\
175  M2M_CACHED_CONNS_FLASH_SZ )
176 
177 /*
178  * Check addition
179  */
180 #if (FLASH_COMMON_SZ != M2M_OTA_IMAGE1_OFFSET)
181 #error "Common Size Mismatch"
182 #endif
183 
184 /*
185  * Host Control Section
186  */
187 #define HOST_CONTROL_FLASH_OFFSET (M2M_OTA_IMAGE1_OFFSET + OTA_IMAGE_SIZE)
188 #define HOST_CONTROL_FLASH_SZ (FLASH_SECTOR_SZ * 1)
189 #define HOST_CONTROL_FLASH_SIG 0x414f5354
190 
195 #define M2M_OTA_IMAGE2_OFFSET (FLASH_4M_TOTAL_SZ)
196 
197 /*
198  * Firmware (including downloader firmware)
199  */
200 #if (defined _FIRMWARE_)||(defined OTA_GEN)
201 #define M2M_FIRMWARE_FLASH_OFFSET (0UL)
202 #else
203 #if (defined DOWNLOAD_ROLLBACK)
204 #define M2M_FIRMWARE_FLASH_OFFSET (M2M_OTA_IMAGE2_OFFSET)
205 #else
206 #define M2M_FIRMWARE_FLASH_OFFSET (M2M_OTA_IMAGE1_OFFSET)
207 #endif
208 #endif
209 #ifdef _PROGRAM_POWER_SAVE_
210 #define M2M_PROGRAM_FLASH_SZ (8 * 1024UL) /* downloader firmware */
211 #else
212 #define M2M_PROGRAM_FLASH_SZ (0UL)
213 #endif /* _PROGRAM_POWER_SAVE_ */
214 #define M2M_FIRMWARE_FLASH_SZ (304 * 1024UL) /* downloader firmware and main firmware */
215 
216 /*
217  * HTTP Files
218  */
219 #define M2M_HTTP_MEM_FLASH_OFFSET (M2M_FIRMWARE_FLASH_OFFSET + M2M_FIRMWARE_FLASH_SZ)
220 #define M2M_HTTP_MEM_FLASH_SZ (FLASH_SECTOR_SZ * 2)
221 
222 /*
223  * ps_Firmware(Power Save Firmware): App. which runs for power saving purpose
224  */
225 #define M2M_PS_FIRMWARE_FLASH_OFFSET (M2M_HTTP_MEM_FLASH_OFFSET + M2M_HTTP_MEM_FLASH_SZ)
226 #define M2M_PS_FIRMWARE_FLASH_SZ (FLASH_SECTOR_SZ * 0)
227 
228 /*
229  * BT(Bluetooth Firmware): BT/BLE firmware to run on the BT cortus
230  */
231 #define M2M_BT_FIRMWARE_FLASH_OFFSET (M2M_PS_FIRMWARE_FLASH_OFFSET + M2M_PS_FIRMWARE_FLASH_SZ)
232 #ifdef BT_IMAGE_PRESENT
233 #define M2M_BT_FIRMWARE_FLASH_SZ (160 * 1024UL)
234 #else
235 #define M2M_BT_FIRMWARE_FLASH_SZ (0)
236 #endif
237 
238 
239 /*
240  * OTA image size
241  */
242 #define OTA_IMAGE_SIZE (\
243  M2M_FIRMWARE_FLASH_SZ +\
244  M2M_HTTP_MEM_FLASH_SZ +\
245  M2M_PS_FIRMWARE_FLASH_SZ +\
246  M2M_BT_FIRMWARE_FLASH_SZ )
247 
248 /*
249  * Check addition
250  */
251 #if ((M2M_FIRMWARE_FLASH_OFFSET + OTA_IMAGE_SIZE) != (M2M_BT_FIRMWARE_FLASH_OFFSET + M2M_BT_FIRMWARE_FLASH_SZ))
252 #error "OTA Size Mismatch"
253 #endif
254 
255 
256 /*
257  * Check that total size of content
258  * does not exceed total size of memory allocated
259  */
260 #if ((FLASH_COMMON_SZ + OTA_IMAGE_SIZE + HOST_CONTROL_FLASH_SZ) > M2M_OTA_IMAGE2_OFFSET)
261 #error "Exceed Flash Size"
262 #endif /* ((FLASH_COMMON_SZ + OTA_IMAGE_SIZE + HOST_CONTROL_FLASH_SZ) > M2M_OTA_IMAGE2_OFFSET) */
263 #if ((M2M_OTA_IMAGE2_OFFSET + OTA_IMAGE_SIZE) > FLASH_8M_TOTAL_SZ)
264 #error "OTA Exceed Flash Size"
265 #endif /* ((M2M_OTA_IMAGE2_OFFSET + OTA_IMAGE_SIZE) > FLASH_8M_TOTAL_SZ) */
266 
267 #endif /* __SPI_FLASH_MAP_H__ */


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:05