主题中讨论的其他器件:UNIFLASH、 SysConfig
您好!
我们正在最终完成基于 CC3235的产品的配置。 我在将安全证书写入 NWP 闪存时看到一些异常行为。 先介绍一些背景信息。 共有七个证书文件、大小从1554字节到2090字节不等。 每个文件都以块的形式从 STM32主处理器发送到 CC3235。 我们的应用程序代码会重新汇编每个文件、在每个文件完成后、会将其创建并写入 NWP 闪存。 基本来说、STM32 -> CC3235 app -> CC3235 NWP。 STM32在两个文件之间等待3秒、以便为 CC3235提供处理文件的时间。 足够简单。
但是、当我在传输文件后检查这些文件时、每个文件的长度正好是2048字节。 超过2048的时间将被截断。 这些较短的数据是完整的,但来自先前较长的文件的数据将填充--- 结束证书----- 写入偏移量2048。 我知道额外的数据不是来自应用、因为文件建立的缓冲区在每次使用前都会被清除。
现在、真正奇怪的是、如果我在每个文件关闭后设置一个断点、文件将被正确写入! 最初我认为这可能是因为每次命中断点后检查数据所引起的延迟。 但是、我在每次文件传输和写入之间添加了1分钟的延迟、问题仍然存在。 我将在下面添加文件编写应用程序代码、代码相当简单。 sl_fs 中的一个文件几乎覆盖了另一个文件、然后又使其写入闪存、就好像有一个缓冲区已损坏。
感谢您的任何帮助!
此致、
约翰
/**
* \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
}
