Other Parts Discussed in Thread: UNIFLASH, SYSCONFIG
Hello,
We are working on finalizing the provisioning of our CC3235 based product. I am seeing some anomalous behavior when we write the security certificates into the NWP flash memory. Some background first. There are seven certificate files that vary in size from 1554 bytes to 2090 bytes in size. Each file is sent from our STM32 main processor to the CC3235 in chunks. Our application code reassembles each file and as each file is complete it is created and written to the NWP flash. So basically STM32 -> CC3235 APP -> CC3235 NWP. The STM32 waits 3 seconds between files to give the CC3235 time to process the file. Simple enough.
However, when I go to examine the files after they are transferred, each is exactly 2048 bytes long. Those longer than 2048 are truncated. Those shorter are complete, but the data from a previous file that was longer fills the remaining space from the ----- END CERTIFICATE ----- to the offset 2048. I know the extra data did not come from the application because the buffer the file is built up in is cleared each time before use.
Now, the really strange part of this is that if I set a breakpoint after each file is closed, the file is written properly! Initially I thought this could be because of the delay induced by examining data after each time the breakpoint is hit. However, I added a 1 minute delay between each file transfer and write, and the problem persists. I will include the file write application code below, it's fairly simple. It almost looks like the sl_Fs is having one file overwrite the other before it makes it to flash like there is a buffer that is getting corrupted.
Thanks for any help!
Regards,
John
/** * \details This routine manages the FS Security Write * \note None * \param[in] typ denotes the security file type * \param[out] None * \return ret_val returns 0 on failure and non zero on success */ int32_t FS_SecurityWrite(fs_security_type_t typ) { const char *filename = FS_securityGetFileName(typ); fs_security_info_t * p_sec_info = FS_SecurityGetBuffer(typ); int32_t offset = 0; int32_t f_hndl = 0; int32_t ret_val = 0; //Note: Make sure to initialize config file with MAX_SECURITY_INFO_SIZE zeroes, even if // only using 20 bytes. // Otherwise, attempting to read MAX_SECURITY_INFO_SIZE bytes from the file would // fail. f_hndl = sl_FsOpen((const unsigned char *)filename, (SL_FS_CREATE | SL_FS_OVERWRITE | SL_FS_CREATE_FAILSAFE | SL_FS_CREATE_MAX_SIZE(MAX_SECURITY_INFO_SIZE)), 0); WSIS_SendDebugPrint("Fs Write f_hndl: %d size: %d typ: %d name: %s", f_hndl, MAX_SECURITY_INFO_SIZE, typ, filename); //Check if open was successful if(f_hndl < 0) { ret_val = f_hndl; } if(ret_val >= 0) { ret_val = sl_FsWrite(f_hndl,offset, (uint8_t *)p_sec_info->cert, p_sec_info->size); WSIS_SendDebugPrint("Fs Write ret_val: %d", ret_val); if(ret_val > 0) { offset += ret_val; } } if(f_hndl >= 0) { // Make sure to close it if sl_FsOpen was successful sl_FsClose(f_hndl, NULL, NULL, 0); } return ret_val; //<----- Works correctly if I set a breakpoint here }