因项目需求,需要用Flash存放两个字节,我已经将Flash重新划分,此时要将这两个字节写入Flash,但我不可能将整页都擦除(这两个字节存放在代码后面),但我又不想单独开辟一页来存放这两个字节,发现在SBL固件升级中,有如下函数,这个函数向0x0890这个flash地址写校验和,其并没有擦除flash,这是如何实现的?谢谢
void appForceBoot(void)
{
uint16 crc[2];
// Make sure SBL is present.
HalFlashRead(SBL_CRC_PAGE, SBL_CRC_OFFSET, (uint8 *)crc, 4);
if ((crc[0] == 0xFFFF) || (crc[0] == 0x0000) ||
(crc[1] == 0xFFFF) || (crc[1] == 0x0000) ||
(crc[1] != crc[0]))
{
return;
}
HAL_DISABLE_INTERRUPTS();
crc[0] ^= 0xFFFF; // Only write to zero bits that are not already zero.
crc[1] = 0xFFFF; // No need to write any bits to zero.
HalFlashWrite(HAL_SBL_IMG_CRC, (uint8 *)crc, 1);
HAL_SYSTEM_RESET();
}
cedar_xuesong:
OSAL里面有专门的NV函数,参考这个帖子
http://www.deyisupport.com/question_answer/wireless_connectivity/bluetooth/f/103/t/48352.aspx