工具与软件:
尊敬的所有人:
我们来考虑一下 SDK v7.40中的这段代码
else if (blkNum == (numBlksInImgHdr - 1))
{
...
...
status = oadValidateCandidateHdr((imgHdr_t * )&candidateImageHeader);
if(status == OAD_SUCCESS)
{
...
status = oadEraseExtFlashPages(imagePage, candidateImageHeader.fixedHdr.len, pageSize);
// Cancel OAD due to flash erase error
if(FLASH_SUCCESS != status)
{
return (OAD_FLASH_ERR);
}
...
// Write a OAD_BLOCK to Flash.
status = writeFlashPg(imagePage, 0,
(uint8_t * ) &candidateImageHeader,
sizeof(imgHdr_t));
// Cancel OAD due to flash program error
if(FLASH_SUCCESS != status)
{
return (OAD_FLASH_ERR);
}
// If there are non header (image data) bytes in this packet
// write them to flash as well
if(nonHeaderBytes)
{
// Write a OAD_BLOCK to Flash.
status = writeFlashPg(imagePage,
sizeof(imgHdr_t),
(pValue+OAD_BLK_NUM_HDR_SZ+remainder),
nonHeaderBytes);
// Cancel OAD due to flash program error
if(FLASH_SUCCESS != status)
{
return (OAD_FLASH_ERR);
}
}
}
我担心的是连续2次调用 writeFlashPg()。
在它们中、失调电压已正确完成。 第一次调用的长度为141。 第二次调用的长度为99。
但它们都指向同一 imagePage 计数器变量。
在我正在使用的存储器中(通常为256块大小和4096扇区大小)、您无法做到这一点。
您必须一次性写入256块大小的内容。 嗯、不完全是、但您不能进行扩展超过256的写入。
因此、我想我需要向存储器驱动程序代码中添加一些边界检查逻辑吗?
提前感谢您的参与。