m2m_flash.c
Go to the documentation of this file.
1 
37 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
38 INCLUDES
39 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
42 #include "driver/source/nmflash.h"
43 #include "driver/source/m2m_hif.h"
45 #include "nmdrv.h"
46 
47 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
48 GLOBALS
49 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
51 static uint8 gau8ItemIdentifier[20] = {0};
52 
53 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
54 FUNCTIONS
55 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
56 #include "ISConstants.h"
57 #define malloc MALLOC
58 #define free FREE
59 
60 static sint8 transfer_init(void)
61 {
62  sint8 ret = FLASH_RETURN_OK;
63 
64  /* Check module was initialized. */
65  if (gu8Init == 0)
66  ret = FLASH_ERR_UNINIT;
67  return ret;
68 }
69 static sint8 init_access(void)
70 {
71  sint8 ret = FLASH_RETURN_OK;
72 
73  gu8Reset = 0;
76 
77  return ret;
78 }
79 static sint8 commit_access(tstrFlashAccess *pstrFlashAccess)
80 {
81  sint8 ret = FLASH_RETURN_OK;
82  sint8 status = M2M_ERR_FAIL;
83  tstrFlashAccessPersistent *pstrPersistentInfo = &pstrFlashAccess->strPersistentInfo;
84 
85  /*
86  * To begin with, flash is unchanged. Later, when first flash erase/write occurs, this flag
87  * will be cleared.
88  */
89  pstrPersistentInfo->u8ModeFlags |= FLASH_MODE_FLAGS_UNCHANGED;
90  if (pstrPersistentInfo->u8ModeFlags & FLASH_MODE_FLAGS_CS_SWITCH)
91  {
92  uint8 target = 0;
93  if (image_get_target(&target) != M2M_SUCCESS)
94  {
96  goto ERR;
97  }
98  if (target > 0)
99  pstrPersistentInfo->u8ModeFlags |= FLASH_MODE_FLAGS_CS_SWITCH_TARGET;
100  }
101 
102  status = spi_flash_read((uint8*)pstrPersistentInfo, HOST_CONTROL_FLASH_OFFSET, FLASH_SIG_STA_SZ);
103  if (status == M2M_SUCCESS)
104  {
105  if ((pstrPersistentInfo->u32Signature != FLASH_SIGNATURE) || (pstrPersistentInfo->enuTransferStatus != FLASH_STATUS_EMPTY))
107  }
108  if (status == M2M_SUCCESS)
109  {
110  pstrPersistentInfo->u32Signature = FLASH_SIGNATURE;
111  pstrPersistentInfo->enuTransferStatus = FLASH_STATUS_NOT_ACTIVE;
113  if (status == M2M_SUCCESS)
114  {
115  status = winc_flash_write_verify((uint8*)pstrPersistentInfo, HOST_CONTROL_FLASH_OFFSET, sizeof(tstrFlashAccessPersistent));
116  if (status == M2M_SUCCESS)
117  {
118  pstrPersistentInfo->enuTransferStatus = FLASH_STATUS_ACTIVE;
120  gu16LastAccessId = pstrPersistentInfo->u16AppId;
121  gu8Success = 0;
122  gu8Changed = 0;
123  }
124  }
125  }
126  if (status != M2M_SUCCESS)
127  {
128  ret = FLASH_ERR_WINC_ACCESS;
129  goto ERR;
130  }
131  ret = transfer_run(pstrFlashAccess);
132 ERR:
133  return ret;
134 }
136 {
137  sint8 ret = FLASH_RETURN_OK;
138  if (pfFn == NULL)
139  ret = FLASH_ERR_PARAM;
140  gpfAppFn = pfFn;
141  return ret;
142 }
143 static sint8 app_data_access(tenuFlashDataFnCtl enuCtl, void *pvStr)
144 {
145  tstrDataAccessInitParamsApp init_params_app;
146  tstrDataAccessParamsApp params_app;
147  switch (enuCtl)
148  {
150  {
151  tstrDataAccessInitParams *init_params = (tstrDataAccessInitParams*)pvStr;
152  init_params_app.u32TotalSize = init_params->u32TotalSize;
153  if (init_params->u8Flags & FLASH_FN_FLAGS_READ)
154  init_params_app.enuRW = FLASH_DATA_FN_READ;
155  else if (init_params->u8Flags & FLASH_FN_FLAGS_WRITE)
156  init_params_app.enuRW = FLASH_DATA_FN_WRITE;
157  pvStr = &init_params_app;
158  }
159  break;
160  case FLASH_DATA_FN_DATA:
161  {
162  tstrDataAccessParams *params = (tstrDataAccessParams*)pvStr;
163  params_app.pu8Data = params->pu8Buf + params->u32DataOffset;
164  params_app.u32DataSize = params->u32DataSize;
165  pvStr = &params_app;
166  }
167  break;
170  break;
171  }
172  return gpfAppFn(enuCtl, pvStr);
173 }
174 sint8 m2m_flash_readimage(uint8 enuImageId, uint16 u16Id, tpfDataAccessFn pfDestFn, uint32 u32DestSize)
175 {
176  sint8 ret = FLASH_RETURN_OK;
177 
178  M2M_INFO("FA RdImage %d\n", enuImageId);
179  ret = transfer_init();
180  if (ret < 0)
181  goto ERR;
182  ret = register_app_fn(pfDestFn);
183  if (ret < 0)
184  goto ERR;
185  if (u32DestSize < OTA_IMAGE_SIZE)
186  {
187  ret = FLASH_ERR_SIZE;
188  goto ERR;
189  }
190  if (enuImageId > FLASH_IMAGE_INACTIVE)
191  {
192  ret = FLASH_ERR_PARAM;
193  goto ERR;
194  }
195 
196  ret = init_access();
197  if (ret == FLASH_RETURN_OK)
198  {
199  /* Set parameters for whole transfer. */
200  tstrFlashAccess strFlashAccess;
201  m2m_memset((uint8*)&strFlashAccess, 0, sizeof(tstrFlashAccess));
202 
203  strFlashAccess.strPersistentInfo.u16AppId = u16Id;
204 
205  strFlashAccess.pfDestinationFn = app_data_access;
206  switch (enuImageId)
207  {
208  case FLASH_IMAGE_ACTIVE:
209  set_internal_info(&strFlashAccess.pfSourceFn, MEM_ID_WINC_ACTIVE);
210  break;
212  set_internal_info(&strFlashAccess.pfSourceFn, MEM_ID_WINC_INACTIVE);
213  break;
214  }
215  strFlashAccess.u32Size = OTA_IMAGE_SIZE;
216 
217  ret = commit_access(&strFlashAccess);
218  }
219 ERR:
220  M2M_INFO("FAState:%d\n", ret);
221  return ret;
222 }
223 
224 sint8 m2m_flash_updateimage(uint8 u8Options, uint16 u16Id, tpfDataAccessFn pfSourceFn, uint32 u32SourceSize)
225 {
226  sint8 ret = FLASH_RETURN_OK;
227 
228  M2M_INFO("FA Image %d\n", u8Options);
229  ret = transfer_init();
230  if (ret < 0)
231  goto ERR;
232  if (u8Options & FLASH_UPDATEIMAGE_OPTION_UPDATE)
233  {
234  uint8 au8ImageStart[4];
235  uint8 au8ImageCheck[] = {'N','M','I','S'};
236  tstrDataAccessInitParams init_params = {sizeof(au8ImageStart), FLASH_FN_FLAGS_READ};
237  sint8 status = M2M_SUCCESS;
238 
239  /* Check input parameters. */
240  ret = register_app_fn(pfSourceFn);
241  if (ret < 0)
242  goto ERR;
243  if (u32SourceSize != OTA_IMAGE_SIZE)
244  {
245  ret = FLASH_ERR_PARAM;
246  goto ERR;
247  }
248  status = app_data_access(FLASH_DATA_FN_INITIALIZE, &init_params);
249  if (status == M2M_SUCCESS)
250  {
251  tstrDataAccessParams params = {au8ImageStart, sizeof(au8ImageStart), 0, sizeof(au8ImageStart)};
252  status = app_data_access(FLASH_DATA_FN_DATA, &params);
253  }
254  if (status != M2M_SUCCESS)
255  {
257  goto ERR;
258  }
259  if (m2m_memcmp(au8ImageStart, au8ImageCheck, sizeof(au8ImageStart)))
260  {
262  goto ERR;
263  }
264  }
265 
266  ret = init_access();
267  if (ret == FLASH_RETURN_OK)
268  {
269  /* Set parameters for whole transfer. */
270  tstrFlashAccess strFlashAccess;
271  m2m_memset((uint8*)&strFlashAccess, 0, sizeof(tstrFlashAccess));
272 
273  strFlashAccess.strPersistentInfo.u16AppId = u16Id;
274  if (u8Options & FLASH_UPDATEIMAGE_OPTION_UPDATE)
275  {
276  strFlashAccess.strPersistentInfo.u8AccessFlags = FLASH_ACCESS_WINC_MASK | FLASH_ACCESS_OPTION_ERASE_FIRST;
277 
278  strFlashAccess.pfSourceFn = app_data_access;
279  set_internal_info(&strFlashAccess.pfDestinationFn, MEM_ID_WINC_INACTIVE);
280  strFlashAccess.u32Size = OTA_IMAGE_SIZE;
281  }
282  else
283  strFlashAccess.u32Size = 0;
284  if (u8Options & FLASH_UPDATEIMAGE_OPTION_VALIDATE)
285  strFlashAccess.strPersistentInfo.u8ModeFlags |= FLASH_MODE_FLAGS_CS_VALIDATE_IMAGE;
286  if (u8Options & FLASH_UPDATEIMAGE_OPTION_SWITCH)
287  strFlashAccess.strPersistentInfo.u8ModeFlags |= FLASH_MODE_FLAGS_CS_SWITCH;
288  strFlashAccess.strPersistentInfo.u8ModeFlags |= FLASH_MODE_FLAGS_CS;
289 
290  ret = commit_access(&strFlashAccess);
291  }
292 ERR:
293  M2M_INFO("FAState:%d\n", ret);
294  return ret;
295 }
296 
297 static sint8 m2m_flash_rootcert_access(tenuFlashAccessItemMode enuMode, uint8 u8ModeOptions, uint8 u8AccessOptions, uint16 u16Id, tpfDataAccessFn pfFn, uint32 u32Size)
298 {
299  sint8 ret = FLASH_RETURN_OK;
300  tstrRootCertEntryHeader strRootCertEntry;
301  uint16 u16EntrySz = 0;
302 
303  M2M_INFO("FA Rootcert %d\n", enuMode);
304  ret = transfer_init();
305  if (ret < 0)
306  goto ERR;
307 
308  switch (enuMode)
309  {
310  case FLASH_ITEM_ADD:
311  {
312  sint8 status = M2M_SUCCESS;
313  tstrDataAccessInitParams init_params = {sizeof(strRootCertEntry), FLASH_FN_FLAGS_READ};
314 
315  // Read the entry header
316  if (u32Size < sizeof(strRootCertEntry))
317  {
318  ret = FLASH_ERR_PARAM;
319  goto ERR;
320  }
321  status = pfFn(FLASH_DATA_FN_INITIALIZE, &init_params);
322  if (status == M2M_SUCCESS)
323  {
324  tstrDataAccessParams params = {(uint8*)&strRootCertEntry, sizeof(strRootCertEntry), 0, sizeof(strRootCertEntry)};
325  status = pfFn(FLASH_DATA_FN_DATA, &params);
326  }
327  if (status != M2M_SUCCESS)
328  {
330  goto ERR;
331  }
332  // Check source size matches size calculated from entry header.
333  status = rootcert_get_size(&strRootCertEntry, &u16EntrySz);
334  if ((status != M2M_SUCCESS) || (u32Size != u16EntrySz))
335  {
336  ret = FLASH_ERR_PARAM;
337  goto ERR;
338  }
339  }
340  break;
341  case FLASH_ITEM_READ:
342  case FLASH_ITEM_REMOVE:
345  break;
346  case FLASH_ITEM_READIDX:
347  // Hack strRootCertEntry to carry the index from u8ModeOptions.
348  *(uint32*)&strRootCertEntry = u8ModeOptions;
349  break;
350  default:
351  /* No other item modes supported. */
352  ret = FLASH_ERR_PARAM;
353  goto ERR;
354  break;
355  }
356 
357  ret = init_access();
358  if (ret == FLASH_RETURN_OK)
359  {
360  /* Now we can access the items in flash. */
362  uint32 u32Offset = 0;
363  if (pu8Buff == NULL)
364  {
365  ret = FLASH_ERR_INTERNAL;
366  goto ERR;
367  }
368  ret = rootcert_access(enuMode, &strRootCertEntry, &u16EntrySz, pu8Buff, &u32Offset);
369  if (ret == FLASH_RETURN_OK)
370  {
371  /* Set parameters for whole transfer, according to enuMode. */
372  sint8 status = M2M_SUCCESS;
373  tstrDataAccessInitParams init_params = {u16EntrySz, 0};
374  tstrDataAccessParams data_params = {pu8Buff + u32Offset, u16EntrySz, 0, u16EntrySz};
375  tstrFlashAccess strFlashAccess;
376 
377  m2m_memset((uint8*)&strFlashAccess, 0, sizeof(tstrFlashAccess));
378  strFlashAccess.strPersistentInfo.u16AppId = u16Id;
379  strFlashAccess.strPersistentInfo.u8AccessFlags = u8AccessOptions;
380 
381  switch (enuMode)
382  {
383  case FLASH_ITEM_ADD:
384  init_params.u8Flags = FLASH_FN_FLAGS_READ;
385  status = pfFn(FLASH_DATA_FN_INITIALIZE, &init_params);
386  if (status == M2M_SUCCESS)
387  status = pfFn(FLASH_DATA_FN_DATA, &data_params);
388  if (status != M2M_SUCCESS)
389  {
392  break;
393  }
394  u32Offset += u16EntrySz;
395  // intentional fallthrough.
396  case FLASH_ITEM_REMOVE:
398  if (status == M2M_SUCCESS)
399  status = winc_flash_write_verify(pu8Buff, M2M_BACKUP_FLASH_OFFSET, u32Offset);
400  if (status != M2M_SUCCESS)
401  {
402  ret = FLASH_ERR_WINC_ACCESS;
403  break;
404  }
406  strFlashAccess.strPersistentInfo.u8ModeFlags |= FLASH_MODE_FLAGS_DATA_IN_BACKUP;
407  break;
408  case FLASH_ITEM_READ:
409  case FLASH_ITEM_READIDX:
410  // Check source size is sufficient for reading entry.
411  if (u32Size < u16EntrySz)
412  {
413  ret = FLASH_ERR_SIZE;
414  break;
415  }
416  init_params.u8Flags = FLASH_FN_FLAGS_WRITE;
417  status = pfFn(FLASH_DATA_FN_INITIALIZE, &init_params);
418  if (status == M2M_SUCCESS)
419  status = pfFn(FLASH_DATA_FN_DATA, &data_params);
420  if (status != M2M_SUCCESS)
421  {
424  break;
425  }
426  break;
427  }
428  if (ret == 0)
429  {
430  ret = commit_access(&strFlashAccess);
431  if (enuMode != FLASH_ITEM_REMOVE)
433  }
434  }
435  free(pu8Buff);
436  }
437 ERR:
438  M2M_INFO("FAState:%d\n", ret);
439  return ret;
440 }
441 sint8 m2m_flash_rootcert_add(uint16 u16Id, tpfDataAccessFn pfSourceFn, uint32 u32SourceSize)
442 {
443  sint8 ret = FLASH_RETURN_OK;
444 
445  ret = register_app_fn(pfSourceFn);
446  if (ret == FLASH_RETURN_OK)
448  return ret;
449 }
450 sint8 m2m_flash_rootcert_remove(uint16 u16Id, uint8 *pu8Identifier, uint32 u32IdentifierSz)
451 {
452  sint8 ret = FLASH_ERR_PARAM;
453 
454  if ((pu8Identifier != NULL) && (u32IdentifierSz == 20))
455  {
456  m2m_memcpy(gau8ItemIdentifier, pu8Identifier, u32IdentifierSz);
458  }
459  return ret;
460 }
461 sint8 m2m_flash_rootcert_read(uint16 u16Id, tpfDataAccessFn pfDestFn, uint32 u32DestSize, uint8 *pu8Identifier, uint32 u32IdentifierSz)
462 {
463  sint8 ret = FLASH_RETURN_OK;
464 
465  ret = register_app_fn(pfDestFn);
466  if (ret == FLASH_RETURN_OK)
467  {
468  ret = FLASH_ERR_PARAM;
469  if ((pu8Identifier != NULL) && (u32IdentifierSz == 20))
470  {
471  m2m_memcpy(gau8ItemIdentifier, pu8Identifier, u32IdentifierSz);
472  ret = m2m_flash_rootcert_access(FLASH_ITEM_READ, 0, 0, u16Id, app_data_access, u32DestSize);
473  }
474  }
475  return ret;
476 }
477 sint8 m2m_flash_rootcert_readidx(uint16 u16Id, tpfDataAccessFn pfDestFn, uint32 u32DestSize, uint8 u8Index)
478 {
479  sint8 ret = FLASH_RETURN_OK;
480 
481  ret = register_app_fn(pfDestFn);
482  if (ret == FLASH_RETURN_OK)
483  ret = m2m_flash_rootcert_access(FLASH_ITEM_READIDX, u8Index, 0, u16Id, app_data_access, u32DestSize);
484  return ret;
485 }
486 
488 {
489  if (gu8Reset == 0)
490  {
491  sint8 status = M2M_ERR_FAIL;
492  tstrFlashAccessPersistent strSavedFlashAccess;
493 
494  status = spi_flash_read((uint8*)&strSavedFlashAccess, HOST_CONTROL_FLASH_OFFSET, sizeof(tstrFlashAccessPersistent));
495  if ((status == M2M_SUCCESS) && (strSavedFlashAccess.u32Signature == FLASH_SIGNATURE))
496  {
497  switch (strSavedFlashAccess.enuTransferStatus)
498  {
499  case FLASH_STATUS_ACTIVE:
500  if (strSavedFlashAccess.u8ModeFlags & FLASH_MODE_FLAGS_CS_SWITCH)
501  {
502  // Check to see if switch happened before we were interrupted. If so we had actually completed.
503  uint8 target;
504  if (image_get_target(&target) == M2M_SUCCESS)
505  {
506  if ((target == 0) && (strSavedFlashAccess.u8ModeFlags & FLASH_MODE_FLAGS_CS_SWITCH_TARGET))
507  gu8Success = 1;
508  if ((target > 0) && !(strSavedFlashAccess.u8ModeFlags & FLASH_MODE_FLAGS_CS_SWITCH_TARGET))
509  gu8Success = 1;
510  }
511  }
512  gu16LastAccessId = strSavedFlashAccess.u16AppId;
513  gu8Changed = !(strSavedFlashAccess.u8ModeFlags & FLASH_MODE_FLAGS_UNCHANGED);
514  if (gu8Success == 1)
515  {
516  strSavedFlashAccess.enuTransferStatus = FLASH_STATUS_DONE;
518  }
519  break;
520  case FLASH_STATUS_DONE:
521  gu16LastAccessId = strSavedFlashAccess.u16AppId;
522  gu8Changed = !(strSavedFlashAccess.u8ModeFlags & FLASH_MODE_FLAGS_UNCHANGED);
523  gu8Success = 1;
524  break;
525  default:
526  break;
527  }
528  }
529  }
530  m2m_memset((uint8*)pstrState, 0, sizeof(tstrFlashState));
531  if (gu16LastAccessId)
532  {
533  pstrState->u16LastAccessId = gu16LastAccessId;
534  pstrState->u8Success = gu8Success;
535  pstrState->u8Changed = gu8Changed;
536  }
537  pstrState->u8Init = gu8Init;
538  pstrState->u8Reset = gu8Reset;
539 }
541 {
542  if (gu8Reset == 0)
543  {
544  // WINC backup recovery may be needed.
546  {
547  gu8Init = 1;
548  gu8Reset = 1;
549  return M2M_SUCCESS;
550  }
551  }
552  return M2M_ERR_FAIL;
553 }
NMI_API void m2m_memcpy(uint8 *pDst, uint8 *pSrc, uint32 sz)
Copy specified number of bytes from source buffer to destination buffer.
Definition: nm_common.c:36
#define FLASH_ERR_WINC_CONFLICT
Definition: m2m_flash.h:78
#define M2M_ERR_FAIL
Definition: nm_common.h:63
#define FLASH_ERR_UNINIT
Definition: m2m_flash.h:80
#define free
Definition: m2m_flash.c:58
sint8 rootcert_get_size(tstrRootCertEntryHeader *pstrHdr, uint16 *pu16Size)
Definition: nmflash.c:535
signed char sint8
Range of values between -128 to 127.
Definition: nm_bsp.h:111
sint8 winc_flash_write_verify(uint8 *pu8Buf, uint32 u32Offset, uint32 u32Size)
Definition: nmflash.c:90
#define FLASH_UPDATEIMAGE_OPTION_SWITCH
Definition: m2m_flash.h:62
NMI_API sint8 m2m_memcmp(uint8 *pu8Buff1, uint8 *pu8Buff2, uint32 u32Size)
Compare specified number of data bytes in pu8Buff1 and pu8Buff2 and decide if they all match...
Definition: nm_common.c:116
sint8 m2m_flash_rootcert_add(uint16 u16Id, tpfDataAccessFn pfSourceFn, uint32 u32SourceSize)
Add an entry to the WINC TLS root certificate store.
Definition: m2m_flash.c:441
tenuFlashDataFnCtl
Control parameter for tpfDataAccessFn.
Definition: m2m_flash.h:94
sint8 m2m_flash_init(void)
Initialize the module.
Definition: m2m_flash.c:540
This module contains WINC3400 M2M driver APIs declarations.
sint8 m2m_flash_rootcert_read(uint16 u16Id, tpfDataAccessFn pfDestFn, uint32 u32DestSize, uint8 *pu8Identifier, uint32 u32IdentifierSz)
Read an entry from the WINC TLS root certificate store, referenced by entry identifier.
Definition: m2m_flash.c:461
#define FLASH_MODE_FLAGS_CS_SWITCH
Definition: nmflash.h:51
static sint8 commit_access(tstrFlashAccess *pstrFlashAccess)
Definition: m2m_flash.c:79
#define FLASH_MODE_FLAGS_CS_VALIDATE_IMAGE
Definition: nmflash.h:53
#define FLASH_ACCESS_OPTION_COMPARE_AFTER
Definition: nmflash.h:115
static sint8 init_access(void)
Definition: m2m_flash.c:69
#define FLASH_ERR_INTERNAL
Definition: m2m_flash.h:82
This structure contains data for local data access (read or write).
Definition: m2m_flash.h:253
#define M2M_SUCCESS
Definition: nm_common.h:51
Header of a root certificate entry in flash.
Definition: m2m_types.h:1907
#define FLASH_MODE_FLAGS_DATA_IN_BACKUP
Definition: nmflash.h:55
#define NULL
Definition: nm_bsp.h:52
static uint8 gau8ItemIdentifier[20]
Definition: m2m_flash.c:51
tenuFlashAccessItemMode
Transfer modes available for accessing items in WINC flash stores such as TLS root certificate store...
Definition: nmflash.h:171
unsigned short uint16
Range of values between 0 to 65535.
Definition: nm_bsp.h:96
sint8 m2m_flash_updateimage(uint8 u8Options, uint16 u16Id, tpfDataAccessFn pfSourceFn, uint32 u32SourceSize)
Write/validate/switch a WINC firmware image.
Definition: m2m_flash.c:224
sint8 image_get_target(uint8 *pu8Target)
Definition: nmflash.c:515
This structure contains parameters for initializing a local data access (read or write).
Definition: m2m_flash.h:239
#define FLASH_FN_FLAGS_READ
Definition: nmflash.h:82
#define malloc
Definition: m2m_flash.c:57
WINC3400 IoT Application Interface.
#define FLASH_MODE_FLAGS_CS_SWITCH_TARGET
Definition: nmflash.h:52
sint8 recover_backup(void)
Definition: nmflash.c:442
#define FLASH_MODE_FLAGS_CS
Definition: nmflash.h:50
#define HOST_CONTROL_FLASH_SZ
#define FLASH_ERR_LOCAL_ACCESS
Definition: m2m_flash.h:69
This structure contains data for local data access (read, erase or write).
Definition: nmflash.h:251
uint8 gu8Reset
Definition: nmflash.c:61
uint8 gu8Init
Definition: nmflash.c:60
#define FLASH_ERR_SIZE
Definition: m2m_flash.h:73
sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz)
Read a specified portion of data from SPI Flash. .
Definition: spi_flash.c:505
sint8 m2m_wifi_reinit_hold(void)
First part of m2m_wifi_reinit, up to the point of initializing spi for flash access.
Definition: m2m_wifi.c:543
#define FLASH_ERR_PARAM
Definition: m2m_flash.h:67
#define FLASH_FN_FLAGS_WRITE
Definition: nmflash.h:74
void m2m_flash_get_state(tstrFlashState *pstrState)
Get information about the module current state and about the most recent access attempt.
Definition: m2m_flash.c:487
#define FLASH_SIGNATURE
Definition: nmflash.h:47
NMI_API void m2m_memset(uint8 *pBuf, uint8 val, uint32 sz)
Set specified number of data bytes in specified data buffer to specified value.
Definition: nm_common.c:58
sint8 rootcert_access(tenuFlashAccessItemMode enuMode, tstrRootCertEntryHeader *pstrReferenceHdr, uint16 *pu16EntrySize, uint8 *pu8Buff, uint32 *pu32Offset)
Definition: nmflash.c:570
sint8 spi_flash_erase(uint32 u32Offset, uint32 u32Sz)
Erase a specified portion of SPI Flash. .
Definition: spi_flash.c:616
static sint8 m2m_flash_rootcert_access(tenuFlashAccessItemMode enuMode, uint8 u8ModeOptions, uint8 u8AccessOptions, uint16 u16Id, tpfDataAccessFn pfFn, uint32 u32Size)
Definition: m2m_flash.c:297
#define M2M_TLS_ROOTCER_FLASH_OFFSET
static sint8 app_data_access(tenuFlashDataFnCtl enuCtl, void *pvStr)
Definition: m2m_flash.c:143
tstrFlashAccessPersistent strPersistentInfo
Definition: nmflash.h:195
#define HOST_CONTROL_FLASH_OFFSET
sint8 m2m_flash_readimage(uint8 enuImageId, uint16 u16Id, tpfDataAccessFn pfDestFn, uint32 u32DestSize)
Definition: m2m_flash.c:174
SPI Flash.
static tpfDataAccessFn gpfAppFn
Definition: m2m_flash.c:50
#define FLASH_ACCESS_WINC_MASK
Definition: nmflash.h:120
#define FLASH_ACCESS_OPTION_ERASE_FIRST
Definition: nmflash.h:89
sint8 m2m_flash_rootcert_readidx(uint16 u16Id, tpfDataAccessFn pfDestFn, uint32 u32DestSize, uint8 u8Index)
Read an entry from the WINC TLS root certificate store, referenced by entry index.
Definition: m2m_flash.c:477
uint32 u32DataOffset
Definition: nmflash.h:257
#define M2M_TLS_ROOTCER_FLASH_SZ
uint8 gu8Changed
Definition: nmflash.c:59
sint8 m2m_flash_rootcert_remove(uint16 u16Id, uint8 *pu8Identifier, uint32 u32IdentifierSz)
Remove an entry from the WINC TLS root certificate store.
Definition: m2m_flash.c:450
sint8(* tpfDataAccessFn)(tenuFlashDataFnCtl enuCtl, void *pvStr)
A function of this type is used for local data access. It can be implemented to handle simple RAM acc...
Definition: m2m_flash.h:229
#define FLASH_UPDATEIMAGE_OPTION_UPDATE
Definition: m2m_flash.h:54
#define M2M_BACKUP_FLASH_OFFSET
#define M2M_BACKUP_FLASH_SZ
#define M2M_INFO(...)
Definition: nm_debug.h:83
unsigned long uint32
Range of values between 0 to 4294967295.
Definition: nm_bsp.h:103
uint16 gu16LastAccessId
Definition: nmflash.c:57
#define OTA_IMAGE_SIZE
WINC Flash Interface.
uint8 gu8Success
Definition: nmflash.c:58
unsigned char uint8
Range of values between 0 to 255.
Definition: nm_bsp.h:89
void set_internal_info(tpfDataAccessFn *ppfFn, uint32 u32LocationId)
Definition: nmflash.c:430
static sint8 register_app_fn(tpfDataAccessFn pfFn)
Definition: m2m_flash.c:135
#define FLASH_ERR_WINC_ACCESS
Definition: m2m_flash.h:71
#define FLASH_SIG_STA_SZ
Definition: nmflash.h:192
#define FLASH_MODE_FLAGS_UNCHANGED
Definition: nmflash.h:54
#define FLASH_UPDATEIMAGE_OPTION_VALIDATE
Definition: m2m_flash.h:58
This module contains M2M host interface APIs implementation.
sint8 transfer_run(tstrFlashAccess *pstrFlashAccess)
Definition: nmflash.c:679
This structure contains parameters for initializing a local data access (read, erase or write)...
Definition: nmflash.h:226
#define FLASH_RETURN_OK
Definition: nmflash.h:45
This structure contains information about an attempted transfer.
Definition: m2m_flash.h:267
static sint8 transfer_init(void)
Definition: m2m_flash.c:60
WINC3400 Flash Interface.


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57