74 while (offset < u32Size)
76 uint32 chunk_sz =
sizeof(buf);
77 if (chunk_sz > u32Size - offset)
78 chunk_sz = u32Size - offset;
82 ret =
m2m_memcmp(buf, pu8Buf + offset, chunk_sz);
121 for(i = 0; i < len; i++)
124 for(g = 0; g < 8; g++)
126 uint8 inv = (((buff[i] << g) & 0x80) >> 7) ^ ((reg >> 6) & 1);
127 reg = ((reg << 1) & 0x7f) ^ (9 * inv);
159 pstrControlSec->u32OtaSequenceNumber++;
171 uint8 bUpdate =
false;
257 static uint8 u8Flags = 0;
264 u8Flags = init_params->
u8Flags;
270 if (pu8Location !=
NULL)
293 static uint32 u32CurrentAddr = 0;
294 static uint8 u8Flags = 0;
302 u8Flags = init_params->
u8Flags;
384 if (u8Flags & FLASH_FN_FLAGS_READ_SURROUNDING)
395 if (u8Flags & FLASH_FN_FLAGS_READ_SURROUNDING)
415 printf(
" FA End 0x%lx\n", u32CurrentAddr);
459 status =
spi_flash_read(pu8Buff, strBackup.u32SourceAddr, strBackup.u32Size);
462 status =
spi_flash_erase(strBackup.u32DestinationAddr, strBackup.u32Size);
518 uint32 u32OffsetActive = 0;
519 uint32 u32OffsetInactive = 0;
529 *pu8Target = (u32OffsetInactive > u32OffsetActive) ? 1 : 0;
538 if ((pstrHdr ==
NULL) || (pu16Size ==
NULL))
578 uint32 u32StoreOffset = 0;
626 if (
m2m_memcmp(pu8Zero, (
uint8*)pstrReferenceHdr,
sizeof(strEntryHeader.au8SHA1NameHash)))
637 if (u32Entries == *(
uint32*)pstrReferenceHdr)
640 *pu16EntrySize = u16EntrySize;
645 else if (!
m2m_memcmp(strEntryHeader.au8SHA1NameHash, (
uint8*)pstrReferenceHdr,
sizeof(strEntryHeader.au8SHA1NameHash)))
656 *pu16EntrySize = u16EntrySize;
665 *pu32Offset -= u16EntrySize;
668 *pu32Offset += u16EntrySize;
671 u32StoreOffset += u16EntrySize;
692 uint32 u32BytesTransferred = 0;
734 if (pfReadFn !=
NULL)
749 if (pfWriteFn !=
NULL)
762 if (u32BytesRemaining > 0)
769 pu8Buff =
malloc(u32BytesRemaining);
777 while (u32BytesRemaining > 0)
781 if (u32BytesTransferred > 0)
793 if (pfReadFn !=
NULL)
807 if (pfWriteFn !=
NULL)
830 if (u32BytesRemaining > 0)
833 if (pfReadFn !=
NULL)
835 if (pfWriteFn !=
NULL)
841 if (pfReadFn !=
NULL)
843 if (pfWriteFn !=
NULL)
NMI_API void m2m_memcpy(uint8 *pDst, uint8 *pSrc, uint32 sz)
Copy specified number of bytes from source buffer to destination buffer.
#define FLASH_ERR_WINC_CONFLICT
uint8 is_internal_info(tpfDataAccessFn pfFn)
#define FLASH_ACCESS_OPTION_USE_BACKUP
#define FLASH_FN_FLAGS_READ_SURROUNDING
uint32 u32OtaControlSecCrc
#define M2M_TLS_ROOTCER_FLASH_SIG
sint8 rootcert_get_size(tstrRootCertEntryHeader *pstrHdr, uint16 *pu16Size)
signed char sint8
Range of values between -128 to 127.
sint8 winc_flash_write_verify(uint8 *pu8Buf, uint32 u32Offset, uint32 u32Size)
static sint8 read_control_sector(tstrOtaControlSec *pstrControlSec, uint32 u32Offset)
#define FLASH_BACKUP_STA_SZ
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...
tenuFlashDataFnCtl
Control parameter for tpfDataAccessFn.
uint32 u32OtaRollbackImageOffset
This module contains WINC3400 M2M driver APIs declarations.
static sint8 update_control_sector(tstrOtaControlSec *pstrControlSec)
#define FLASH_MODE_FLAGS_CS_SWITCH
#define FLASH_MODE_FLAGS_CS_VALIDATE_IMAGE
#define FLASH_ACCESS_OPTION_COMPARE_AFTER
uint32 u32OtaRollbackImageValidStatus
#define FLASH_ACCESS_OPTION_COMPARE_BEFORE
#define FLASH_ERR_INTERNAL
#define FLASH_FN_FLAGS_BACKUP
tpfDataAccessFn pfDestinationFn
#define FLASH_MODE_FLAGS_DATA_IN_BACKUP
size_t count(InputIterator first, InputIterator last, T const &item)
tenuFlashAccessStatus enuTransferStatus
tstrRootCertRsaKeyInfo strRsaKeyInfo
static uint32 gu32LocationId
#define FLASH_BACKUP_STORE_OFFSET
tenuFlashAccessItemMode
Transfer modes available for accessing items in WINC flash stores such as TLS root certificate store...
static sint8 winc_flash_compare(uint8 *pu8Buf, uint32 u32Offset, uint32 u32Size)
unsigned short uint16
Range of values between 0 to 65535.
sint8 image_get_target(uint8 *pu8Target)
#define FLASH_FN_FLAGS_READ
sint8 recover_backup(void)
#define FLASH_MODE_FLAGS_CS
#define FLASH_ERR_LOCAL_ACCESS
This structure contains data for local data access (read, erase or write).
This struct contains the Control Section. The Control Section is used to define the working image and...
static sint8 set_changed_flag(tstrFlashAccessPersistent *pstrPersistentInfo)
sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz)
Read a specified portion of data from SPI Flash. .
#define FLASH_FN_FLAGS_COMPARE_AFTER
#define FLASH_FN_FLAGS_WRITE
tpfDataAccessFn pfSourceFn
NMI_API void m2m_memset(uint8 *pBuf, uint8 val, uint32 sz)
Set specified number of data bytes in specified data buffer to specified value.
sint8 rootcert_access(tenuFlashAccessItemMode enuMode, tstrRootCertEntryHeader *pstrReferenceHdr, uint16 *pu16EntrySize, uint8 *pu8Buff, uint32 *pu32Offset)
sint8 spi_flash_erase(uint32 u32Offset, uint32 u32Sz)
Erase a specified portion of SPI Flash. .
#define M2M_CONTROL_FLASH_OFFSET
#define M2M_CONTROL_FLASH_SZ
#define M2M_TLS_ROOTCER_FLASH_OFFSET
uint32 u32OtaCurrentworkingImagOffset
uint32 u32OtaSequenceNumber
tenuBackupStatus enuTransferStatus
tstrFlashAccessPersistent strPersistentInfo
#define HOST_CONTROL_FLASH_OFFSET
#define FLASH_ACCESS_OPTION_ERASE_FIRST
tstrRootCertEcdsaKeyInfo strEcsdaKeyInfo
#define FLASH_FN_FLAGS_ERASE
#define M2M_TLS_ROOTCER_FLASH_SZ
#define FLASH_SECTOR_SIZE
static uint8 * gpu8Location
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...
#define M2M_BACKUP_FLASH_OFFSET
#define FLASH_ACCESS_OPTION_KEEP_SURROUNDING
#define M2M_BACKUP_FLASH_SZ
static sint8 access_control_sector(tenuCSOp enuOp, uint32 *param)
static sint8 local_access_ptr(tenuFlashDataFnCtl enuCtl, void *pvStr)
unsigned long uint32
Range of values between 0 to 4294967295.
#define OTA_STATUS_INVALID
void set_internal_info_ptr(tpfDataAccessFn *ppfFn, uint8 *pu8Ptr)
sint8 spi_flash_write(uint8 *pu8Buf, uint32 u32Offset, uint32 u32Sz)
Write a specified portion of data to SPI Flash. .
unsigned char uint8
Range of values between 0 to 255.
void set_internal_info(tpfDataAccessFn *ppfFn, uint32 u32LocationId)
#define FLASH_ERR_WINC_ACCESS
#define FLASH_BACKUP_STORE_SZ
static sint8 winc_flash_access(tenuFlashDataFnCtl enuCtl, void *pvStr)
#define FLASH_MODE_FLAGS_UNCHANGED
static uint8 crc7(uint8 crc, const uint8 *buff, uint16 len)
#define FLASH_FN_FLAGS_COMPARE_BEFORE
sint8 transfer_run(tstrFlashAccess *pstrFlashAccess)
This structure contains parameters for initializing a local data access (read, erase or write)...
sint8 prepare_backup(uint32 u32Target)
WINC3400 Flash Interface.