我在使用STM32H743运行openBLT程序boot部分时,在下载的检测阶段执行了FLASH读取函数,目的是检查FLASH是否为空。
在读取扇区0x08020000到0x0803FFFF的过程中,程序进入hardfault。
以下贴出flash检查程序:
[C] 纯文本查看 复制代码 static blt_bool FlashEmptyCheckSector(blt_int8u sector_idx)
{
blt_bool result = BLT_TRUE;
blt_addr sectorAddr;
blt_int32u sectorSize;
blt_int32u wordCnt;
blt_int32u volatile const * wordPtr;
/* retrieve sector info */
sectorAddr = flashLayout[sector_idx].sector_start;
sectorSize = flashLayout[sector_idx].sector_size;
/* sanity check. sector base address should be 32-bit aligned and the size
* should be a multiple of 32-bits.
*/
ASSERT_RT(((sectorAddr % sizeof(blt_int32u)) == 0) &&
((sectorSize % sizeof(blt_int32u)) == 0));
/* initialize the pointer to the first word in the sector */
wordPtr = (blt_int32u volatile const *)sectorAddr;
/* read sector 32-bits at a time */
for (wordCnt = 0; wordCnt < (sectorSize/sizeof(blt_int32u)); wordCnt++)
{
/* service the watchdog every 256th loop iteration */
if ((wordCnt % 256) == 0)
{
CopService();
}
/* word not in the erased state? */
if (*wordPtr != 0xFFFFFFFFu)
{
/* sector not empty, update the result accordingly */
result = BLT_FALSE;
/* no point in continuing the sector empty check */
break;
}
/* set pointer to the next word in the sector */
wordPtr++;
}
/* give the result back to the caller. */
return result;
} /*** end of FlashEmptyCheckSector ***/
DEBUG查看Fault Report有:

想求助该问题引发的原因。
---
本工程由cubeMX生成,时钟为480MHz,MPU等为默认配置。外部时钟25MHz,仅使用了USART1,GPIO外设。
|