mirror of https://github.com/FOME-Tech/openblt.git
Refs #1522. Reintegrating branch into the trunk.
git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@1025 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
parent
2ddb317259
commit
bcdf763d48
|
@ -54,8 +54,12 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x08000 }, /* flash sectors 16 to 31 - 32kb */
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -54,8 +54,12 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x08000 }, /* flash sectors 16 to 31 - 32kb */
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -54,8 +54,12 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x08000 }, /* flash sectors 16 to 31 - 32kb */
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -54,8 +54,12 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x08000 }, /* flash sectors 16 to 31 - 32kb */
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -69,10 +69,36 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08040000, 0x40000 }, /* flash sectors 128 to 255 - 256kb */
|
||||
{ 0x08080000, 0x80000 } /* flash sectors 256 to 511 - 512kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
{ 0x08040000, 0x08000 }, /* flash sectors 128 to 143 - 32kb */
|
||||
{ 0x08048000, 0x08000 }, /* flash sectors 144 to 159 - 32kb */
|
||||
{ 0x08050000, 0x08000 }, /* flash sectors 160 to 175 - 32kb */
|
||||
{ 0x08058000, 0x08000 }, /* flash sectors 176 to 191 - 32kb */
|
||||
{ 0x08060000, 0x08000 }, /* flash sectors 192 to 207 - 32kb */
|
||||
{ 0x08068000, 0x08000 }, /* flash sectors 208 to 223 - 32kb */
|
||||
{ 0x08070000, 0x08000 }, /* flash sectors 224 to 239 - 32kb */
|
||||
{ 0x08078000, 0x08000 }, /* flash sectors 240 to 255 - 32kb */
|
||||
{ 0x08080000, 0x08000 }, /* flash sectors 256 to 271 - 32kb */
|
||||
{ 0x08088000, 0x08000 }, /* flash sectors 272 to 287 - 32kb */
|
||||
{ 0x08090000, 0x08000 }, /* flash sectors 288 to 303 - 32kb */
|
||||
{ 0x08098000, 0x08000 }, /* flash sectors 304 to 319 - 32kb */
|
||||
{ 0x080A0000, 0x08000 }, /* flash sectors 320 to 335 - 32kb */
|
||||
{ 0x080A8000, 0x08000 }, /* flash sectors 336 to 351 - 32kb */
|
||||
{ 0x080B0000, 0x08000 }, /* flash sectors 352 to 367 - 32kb */
|
||||
{ 0x080B8000, 0x08000 }, /* flash sectors 368 to 383 - 32kb */
|
||||
{ 0x080C0000, 0x08000 }, /* flash sectors 384 to 399 - 32kb */
|
||||
{ 0x080C8000, 0x08000 }, /* flash sectors 400 to 415 - 32kb */
|
||||
{ 0x080D0000, 0x08000 }, /* flash sectors 416 to 431 - 32kb */
|
||||
{ 0x080D8000, 0x08000 }, /* flash sectors 432 to 447 - 32kb */
|
||||
{ 0x080E0000, 0x08000 }, /* flash sectors 448 to 463 - 32kb */
|
||||
{ 0x080E8000, 0x08000 }, /* flash sectors 464 to 479 - 32kb */
|
||||
{ 0x080F0000, 0x08000 }, /* flash sectors 480 to 495 - 32kb */
|
||||
{ 0x080F8000, 0x08000 }, /* flash sectors 496 to 511 - 32kb */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -69,10 +69,36 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08040000, 0x40000 }, /* flash sectors 128 to 255 - 256kb */
|
||||
{ 0x08080000, 0x80000 } /* flash sectors 256 to 511 - 512kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
{ 0x08040000, 0x08000 }, /* flash sectors 128 to 143 - 32kb */
|
||||
{ 0x08048000, 0x08000 }, /* flash sectors 144 to 159 - 32kb */
|
||||
{ 0x08050000, 0x08000 }, /* flash sectors 160 to 175 - 32kb */
|
||||
{ 0x08058000, 0x08000 }, /* flash sectors 176 to 191 - 32kb */
|
||||
{ 0x08060000, 0x08000 }, /* flash sectors 192 to 207 - 32kb */
|
||||
{ 0x08068000, 0x08000 }, /* flash sectors 208 to 223 - 32kb */
|
||||
{ 0x08070000, 0x08000 }, /* flash sectors 224 to 239 - 32kb */
|
||||
{ 0x08078000, 0x08000 }, /* flash sectors 240 to 255 - 32kb */
|
||||
{ 0x08080000, 0x08000 }, /* flash sectors 256 to 271 - 32kb */
|
||||
{ 0x08088000, 0x08000 }, /* flash sectors 272 to 287 - 32kb */
|
||||
{ 0x08090000, 0x08000 }, /* flash sectors 288 to 303 - 32kb */
|
||||
{ 0x08098000, 0x08000 }, /* flash sectors 304 to 319 - 32kb */
|
||||
{ 0x080A0000, 0x08000 }, /* flash sectors 320 to 335 - 32kb */
|
||||
{ 0x080A8000, 0x08000 }, /* flash sectors 336 to 351 - 32kb */
|
||||
{ 0x080B0000, 0x08000 }, /* flash sectors 352 to 367 - 32kb */
|
||||
{ 0x080B8000, 0x08000 }, /* flash sectors 368 to 383 - 32kb */
|
||||
{ 0x080C0000, 0x08000 }, /* flash sectors 384 to 399 - 32kb */
|
||||
{ 0x080C8000, 0x08000 }, /* flash sectors 400 to 415 - 32kb */
|
||||
{ 0x080D0000, 0x08000 }, /* flash sectors 416 to 431 - 32kb */
|
||||
{ 0x080D8000, 0x08000 }, /* flash sectors 432 to 447 - 32kb */
|
||||
{ 0x080E0000, 0x08000 }, /* flash sectors 448 to 463 - 32kb */
|
||||
{ 0x080E8000, 0x08000 }, /* flash sectors 464 to 479 - 32kb */
|
||||
{ 0x080F0000, 0x08000 }, /* flash sectors 480 to 495 - 32kb */
|
||||
{ 0x080F8000, 0x08000 }, /* flash sectors 496 to 511 - 32kb */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -69,10 +69,36 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08040000, 0x40000 }, /* flash sectors 128 to 255 - 256kb */
|
||||
{ 0x08080000, 0x80000 } /* flash sectors 256 to 511 - 512kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
{ 0x08040000, 0x08000 }, /* flash sectors 128 to 143 - 32kb */
|
||||
{ 0x08048000, 0x08000 }, /* flash sectors 144 to 159 - 32kb */
|
||||
{ 0x08050000, 0x08000 }, /* flash sectors 160 to 175 - 32kb */
|
||||
{ 0x08058000, 0x08000 }, /* flash sectors 176 to 191 - 32kb */
|
||||
{ 0x08060000, 0x08000 }, /* flash sectors 192 to 207 - 32kb */
|
||||
{ 0x08068000, 0x08000 }, /* flash sectors 208 to 223 - 32kb */
|
||||
{ 0x08070000, 0x08000 }, /* flash sectors 224 to 239 - 32kb */
|
||||
{ 0x08078000, 0x08000 }, /* flash sectors 240 to 255 - 32kb */
|
||||
{ 0x08080000, 0x08000 }, /* flash sectors 256 to 271 - 32kb */
|
||||
{ 0x08088000, 0x08000 }, /* flash sectors 272 to 287 - 32kb */
|
||||
{ 0x08090000, 0x08000 }, /* flash sectors 288 to 303 - 32kb */
|
||||
{ 0x08098000, 0x08000 }, /* flash sectors 304 to 319 - 32kb */
|
||||
{ 0x080A0000, 0x08000 }, /* flash sectors 320 to 335 - 32kb */
|
||||
{ 0x080A8000, 0x08000 }, /* flash sectors 336 to 351 - 32kb */
|
||||
{ 0x080B0000, 0x08000 }, /* flash sectors 352 to 367 - 32kb */
|
||||
{ 0x080B8000, 0x08000 }, /* flash sectors 368 to 383 - 32kb */
|
||||
{ 0x080C0000, 0x08000 }, /* flash sectors 384 to 399 - 32kb */
|
||||
{ 0x080C8000, 0x08000 }, /* flash sectors 400 to 415 - 32kb */
|
||||
{ 0x080D0000, 0x08000 }, /* flash sectors 416 to 431 - 32kb */
|
||||
{ 0x080D8000, 0x08000 }, /* flash sectors 432 to 447 - 32kb */
|
||||
{ 0x080E0000, 0x08000 }, /* flash sectors 448 to 463 - 32kb */
|
||||
{ 0x080E8000, 0x08000 }, /* flash sectors 464 to 479 - 32kb */
|
||||
{ 0x080F0000, 0x08000 }, /* flash sectors 480 to 495 - 32kb */
|
||||
{ 0x080F8000, 0x08000 }, /* flash sectors 496 to 511 - 32kb */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -69,10 +69,36 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08040000, 0x40000 }, /* flash sectors 128 to 255 - 256kb */
|
||||
{ 0x08080000, 0x80000 } /* flash sectors 256 to 511 - 512kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
{ 0x08040000, 0x08000 }, /* flash sectors 128 to 143 - 32kb */
|
||||
{ 0x08048000, 0x08000 }, /* flash sectors 144 to 159 - 32kb */
|
||||
{ 0x08050000, 0x08000 }, /* flash sectors 160 to 175 - 32kb */
|
||||
{ 0x08058000, 0x08000 }, /* flash sectors 176 to 191 - 32kb */
|
||||
{ 0x08060000, 0x08000 }, /* flash sectors 192 to 207 - 32kb */
|
||||
{ 0x08068000, 0x08000 }, /* flash sectors 208 to 223 - 32kb */
|
||||
{ 0x08070000, 0x08000 }, /* flash sectors 224 to 239 - 32kb */
|
||||
{ 0x08078000, 0x08000 }, /* flash sectors 240 to 255 - 32kb */
|
||||
{ 0x08080000, 0x08000 }, /* flash sectors 256 to 271 - 32kb */
|
||||
{ 0x08088000, 0x08000 }, /* flash sectors 272 to 287 - 32kb */
|
||||
{ 0x08090000, 0x08000 }, /* flash sectors 288 to 303 - 32kb */
|
||||
{ 0x08098000, 0x08000 }, /* flash sectors 304 to 319 - 32kb */
|
||||
{ 0x080A0000, 0x08000 }, /* flash sectors 320 to 335 - 32kb */
|
||||
{ 0x080A8000, 0x08000 }, /* flash sectors 336 to 351 - 32kb */
|
||||
{ 0x080B0000, 0x08000 }, /* flash sectors 352 to 367 - 32kb */
|
||||
{ 0x080B8000, 0x08000 }, /* flash sectors 368 to 383 - 32kb */
|
||||
{ 0x080C0000, 0x08000 }, /* flash sectors 384 to 399 - 32kb */
|
||||
{ 0x080C8000, 0x08000 }, /* flash sectors 400 to 415 - 32kb */
|
||||
{ 0x080D0000, 0x08000 }, /* flash sectors 416 to 431 - 32kb */
|
||||
{ 0x080D8000, 0x08000 }, /* flash sectors 432 to 447 - 32kb */
|
||||
{ 0x080E0000, 0x08000 }, /* flash sectors 448 to 463 - 32kb */
|
||||
{ 0x080E8000, 0x08000 }, /* flash sectors 464 to 479 - 32kb */
|
||||
{ 0x080F0000, 0x08000 }, /* flash sectors 480 to 495 - 32kb */
|
||||
{ 0x080F8000, 0x08000 }, /* flash sectors 496 to 511 - 32kb */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ static blt_bool FlashAddToBlock(tFlashBlockInfo *block, blt_addr address,
|
|||
blt_int8u *data, blt_int32u len);
|
||||
static blt_bool FlashWriteBlock(tFlashBlockInfo *block);
|
||||
static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector);
|
||||
static blt_bool FlashEmptyCheckSector(blt_int8u sector_num);
|
||||
static blt_int8u FlashGetSector(blt_addr address);
|
||||
|
||||
|
||||
|
@ -660,6 +661,70 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
} /*** end of FlashWriteBlock ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Checks if the flash sector is already completely erased.
|
||||
** \param sector_num Sector number. Note that this is the sector_num element of the
|
||||
** flashLayout array, not an index into the array.
|
||||
** \return BLT_TRUE if the flash sector is already erased, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_bool FlashEmptyCheckSector(blt_int8u sector_num)
|
||||
{
|
||||
blt_bool result = BLT_FALSE;
|
||||
blt_addr sectorAddr;
|
||||
blt_int32u sectorSize;
|
||||
blt_int8u sectorIdx;
|
||||
blt_int32u wordCnt;
|
||||
blt_int32u volatile const * wordPtr;
|
||||
|
||||
/* find the index of this sector into the flashLayout array */
|
||||
for (sectorIdx = 0; sectorIdx < FLASH_TOTAL_SECTORS; sectorIdx++)
|
||||
{
|
||||
/* is this the index that the sector number belongs to? */
|
||||
if (flashLayout[sectorIdx].sector_num == sector_num)
|
||||
{
|
||||
/* retrieve sector info */
|
||||
sectorAddr = flashLayout[sectorIdx].sector_start;
|
||||
sectorSize = flashLayout[sectorIdx].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));
|
||||
|
||||
/* update result to success for now */
|
||||
result = BLT_TRUE;
|
||||
/* 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++;
|
||||
}
|
||||
/* sector index found and checked. no need to continue with another one.*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* give the result back to the caller. */
|
||||
return result;
|
||||
} /*** end of FlashEmptyCheckSector ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Erases the flash sectors from first_sector up until last_sector.
|
||||
** \param first_sector First flash sector number.
|
||||
|
@ -698,6 +763,9 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
|
||||
/* erase all sectors one by one */
|
||||
for (sectorIdx=first_sector; sectorIdx<= last_sector; sectorIdx++)
|
||||
{
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sectorIdx) == BLT_FALSE)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
|
@ -712,6 +780,7 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* lock the flash array again */
|
||||
HAL_FLASH_Lock();
|
||||
|
|
|
@ -163,13 +163,24 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x08008000, 0x08000 }, /* flash sectors 16 to 31 - 32kb */
|
||||
#endif
|
||||
#if (BOOT_NVM_SIZE_KB > 64)
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
#endif
|
||||
#if (BOOT_NVM_SIZE_KB > 128)
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
#endif
|
||||
#if (BOOT_NVM_SIZE_KB > 256)
|
||||
{ 0x08040000, 0x40000 }, /* flash sectors 128 to 255 - 256kb */
|
||||
{ 0x08040000, 0x08000 }, /* flash sectors 128 to 143 - 32kb */
|
||||
{ 0x08048000, 0x08000 }, /* flash sectors 144 to 159 - 32kb */
|
||||
{ 0x08050000, 0x08000 }, /* flash sectors 160 to 175 - 32kb */
|
||||
{ 0x08058000, 0x08000 }, /* flash sectors 176 to 191 - 32kb */
|
||||
{ 0x08060000, 0x08000 }, /* flash sectors 192 to 207 - 32kb */
|
||||
{ 0x08068000, 0x08000 }, /* flash sectors 207 to 223 - 32kb */
|
||||
{ 0x08070000, 0x08000 }, /* flash sectors 224 to 239 - 32kb */
|
||||
{ 0x08078000, 0x08000 }, /* flash sectors 240 to 255 - 32kb */
|
||||
#endif
|
||||
#if (BOOT_NVM_SIZE_KB > 512)
|
||||
#error "BOOT_NVM_SIZE_KB > 512 is currently not supported."
|
||||
|
|
|
@ -114,6 +114,7 @@ static blt_bool FlashAddToBlock(tFlashBlockInfo *block, blt_addr address,
|
|||
blt_int8u *data, blt_int32u len);
|
||||
static blt_bool FlashWriteBlock(tFlashBlockInfo *block);
|
||||
static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector);
|
||||
static blt_bool FlashEmptyCheckSector(blt_int8u sector_num);
|
||||
static blt_int8u FlashGetSector(blt_addr address);
|
||||
|
||||
|
||||
|
@ -137,7 +138,7 @@ static blt_int8u FlashGetSector(blt_addr address);
|
|||
static const tFlashSector flashLayout[] =
|
||||
{
|
||||
/* space is reserved for a bootloader configuration with all supported communication
|
||||
* interfaces enabled. when for example only UART is needed, than the space required
|
||||
* interfaces enabled. when for example only UART is needed, then the space required
|
||||
* for the bootloader can be made a lot smaller here.
|
||||
*/
|
||||
/* { 0x08000000, 0x04000, 0}, flash sector 0 - reserved for bootloader */
|
||||
|
@ -676,6 +677,70 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
} /*** end of FlashWriteBlock ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Checks if the flash sector is already completely erased.
|
||||
** \param sector_num Sector number. Note that this is the sector_num element of the
|
||||
** flashLayout array, not an index into the array.
|
||||
** \return BLT_TRUE if the flash sector is already erased, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_bool FlashEmptyCheckSector(blt_int8u sector_num)
|
||||
{
|
||||
blt_bool result = BLT_FALSE;
|
||||
blt_addr sectorAddr;
|
||||
blt_int32u sectorSize;
|
||||
blt_int8u sectorIdx;
|
||||
blt_int32u wordCnt;
|
||||
blt_int32u volatile const * wordPtr;
|
||||
|
||||
/* find the index of this sector into the flashLayout array */
|
||||
for (sectorIdx = 0; sectorIdx < FLASH_TOTAL_SECTORS; sectorIdx++)
|
||||
{
|
||||
/* is this the index that the sector number belongs to? */
|
||||
if (flashLayout[sectorIdx].sector_num == sector_num)
|
||||
{
|
||||
/* retrieve sector info */
|
||||
sectorAddr = flashLayout[sectorIdx].sector_start;
|
||||
sectorSize = flashLayout[sectorIdx].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));
|
||||
|
||||
/* update result to success for now */
|
||||
result = BLT_TRUE;
|
||||
/* 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++;
|
||||
}
|
||||
/* sector index found and checked. no need to continue with another one.*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* give the result back to the caller. */
|
||||
return result;
|
||||
} /*** end of FlashEmptyCheckSector ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Erases the flash sectors from first_sector up until last_sector.
|
||||
** \param first_sector First flash sector number.
|
||||
|
@ -714,6 +779,9 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
|
||||
/* erase all sectors one by one */
|
||||
for (sectorIdx=first_sector; sectorIdx<= last_sector; sectorIdx++)
|
||||
{
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sectorIdx) == BLT_FALSE)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
|
@ -728,6 +796,7 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* lock the flash array again */
|
||||
HAL_FLASH_Lock();
|
||||
|
|
|
@ -178,13 +178,39 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 0x08010000, 0x10000 }, /* flash sectors 32 to 63 - 64kb */
|
||||
{ 0x08020000, 0x20000 }, /* flash sectors 64 to 127 - 128kb */
|
||||
{ 0x08010000, 0x08000 }, /* flash sectors 32 to 47 - 32kb */
|
||||
{ 0x08018000, 0x08000 }, /* flash sectors 48 to 63 - 32kb */
|
||||
{ 0x08020000, 0x08000 }, /* flash sectors 64 to 79 - 32kb */
|
||||
{ 0x08028000, 0x08000 }, /* flash sectors 80 to 95 - 32kb */
|
||||
{ 0x08030000, 0x08000 }, /* flash sectors 96 to 111 - 32kb */
|
||||
{ 0x08038000, 0x08000 }, /* flash sectors 112 to 127 - 32kb */
|
||||
#if (BOOT_NVM_SIZE_KB > 256)
|
||||
{ 0x08040000, 0x40000 }, /* flash sectors 128 to 255 - 256kb */
|
||||
{ 0x08040000, 0x08000 }, /* flash sectors 128 to 143 - 32kb */
|
||||
{ 0x08048000, 0x08000 }, /* flash sectors 144 to 159 - 32kb */
|
||||
{ 0x08050000, 0x08000 }, /* flash sectors 160 to 175 - 32kb */
|
||||
{ 0x08058000, 0x08000 }, /* flash sectors 176 to 191 - 32kb */
|
||||
{ 0x08060000, 0x08000 }, /* flash sectors 192 to 207 - 32kb */
|
||||
{ 0x08068000, 0x08000 }, /* flash sectors 208 to 223 - 32kb */
|
||||
{ 0x08070000, 0x08000 }, /* flash sectors 224 to 239 - 32kb */
|
||||
{ 0x08078000, 0x08000 }, /* flash sectors 240 to 255 - 32kb */
|
||||
#endif
|
||||
#if (BOOT_NVM_SIZE_KB > 512)
|
||||
{ 0x08080000, 0x80000 } /* flash sectors 256 to 511 - 512kb */
|
||||
{ 0x08080000, 0x08000 }, /* flash sectors 256 to 271 - 32kb */
|
||||
{ 0x08088000, 0x08000 }, /* flash sectors 272 to 287 - 32kb */
|
||||
{ 0x08090000, 0x08000 }, /* flash sectors 288 to 303 - 32kb */
|
||||
{ 0x08098000, 0x08000 }, /* flash sectors 304 to 319 - 32kb */
|
||||
{ 0x080A0000, 0x08000 }, /* flash sectors 320 to 335 - 32kb */
|
||||
{ 0x080A8000, 0x08000 }, /* flash sectors 336 to 351 - 32kb */
|
||||
{ 0x080B0000, 0x08000 }, /* flash sectors 352 to 367 - 32kb */
|
||||
{ 0x080B8000, 0x08000 }, /* flash sectors 368 to 383 - 32kb */
|
||||
{ 0x080C0000, 0x08000 }, /* flash sectors 384 to 399 - 32kb */
|
||||
{ 0x080C8000, 0x08000 }, /* flash sectors 400 to 415 - 32kb */
|
||||
{ 0x080D0000, 0x08000 }, /* flash sectors 416 to 431 - 32kb */
|
||||
{ 0x080D8000, 0x08000 }, /* flash sectors 432 to 447 - 32kb */
|
||||
{ 0x080E0000, 0x08000 }, /* flash sectors 448 to 463 - 32kb */
|
||||
{ 0x080E8000, 0x08000 }, /* flash sectors 464 to 479 - 32kb */
|
||||
{ 0x080F0000, 0x08000 }, /* flash sectors 480 to 495 - 32kb */
|
||||
{ 0x080F8000, 0x08000 }, /* flash sectors 496 to 511 - 32kb */
|
||||
#endif
|
||||
#if (BOOT_NVM_SIZE_KB > 1024)
|
||||
#error "BOOT_NVM_SIZE_KB > 1024 is currently not supported."
|
||||
|
|
|
@ -143,6 +143,7 @@ static blt_bool FlashAddToBlock(tFlashBlockInfo *block, blt_addr address,
|
|||
blt_int8u *data, blt_int32u len);
|
||||
static blt_bool FlashWriteBlock(tFlashBlockInfo *block);
|
||||
static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector);
|
||||
static blt_bool FlashEmptyCheckSector(blt_int8u sector_num);
|
||||
static blt_int8u FlashGetSector(blt_addr address);
|
||||
static blt_addr FlashGetSectorBaseAddr(blt_int8u sector);
|
||||
static blt_addr FlashTranslateToNonCachedAddress(blt_addr address);
|
||||
|
@ -776,6 +777,10 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
/* not a valid sector address so abort */
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sector_cnt) == BLT_FALSE)
|
||||
{
|
||||
/* determine timeout time of the operation */
|
||||
timeoutTime = TimerGet() + FLASH_ERASE_TIME_MAX_MS;
|
||||
/* start erase operation */
|
||||
|
@ -800,7 +805,7 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
{
|
||||
/* error occurred during flash erase, abort */
|
||||
return BLT_FALSE;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -809,6 +814,70 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
} /*** end of FlashEraseSectors ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Checks if the flash sector is already completely erased.
|
||||
** \param sector_num Sector number. Note that this is the sector_num element of the
|
||||
** flashLayout array, not an index into the array.
|
||||
** \return BLT_TRUE if the flash sector is already erased, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_bool FlashEmptyCheckSector(blt_int8u sector_num)
|
||||
{
|
||||
blt_bool result = BLT_FALSE;
|
||||
blt_addr sectorAddr;
|
||||
blt_int32u sectorSize;
|
||||
blt_int8u sectorIdx;
|
||||
blt_int32u wordCnt;
|
||||
blt_int32u volatile const * wordPtr;
|
||||
|
||||
/* find the index of this sector into the flashLayout array */
|
||||
for (sectorIdx = 0; sectorIdx < FLASH_TOTAL_SECTORS; sectorIdx++)
|
||||
{
|
||||
/* is this the index that the sector number belongs to? */
|
||||
if (flashLayout[sectorIdx].sector_num == sector_num)
|
||||
{
|
||||
/* retrieve sector info */
|
||||
sectorAddr = flashLayout[sectorIdx].sector_start;
|
||||
sectorSize = flashLayout[sectorIdx].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));
|
||||
|
||||
/* update result to success for now */
|
||||
result = BLT_TRUE;
|
||||
/* 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 != 0x00000000u)
|
||||
{
|
||||
/* 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++;
|
||||
}
|
||||
/* sector index found and checked. no need to continue with another one.*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* give the result back to the caller. */
|
||||
return result;
|
||||
} /*** end of FlashEmptyCheckSector ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Determines the flash sector the address is in.
|
||||
** \param address Address in the flash sector.
|
||||
|
|
|
@ -114,6 +114,7 @@ static blt_bool FlashAddToBlock(tFlashBlockInfo *block, blt_addr address,
|
|||
blt_int8u *data, blt_int32u len);
|
||||
static blt_bool FlashWriteBlock(tFlashBlockInfo *block);
|
||||
static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector);
|
||||
static blt_bool FlashEmptyCheckSector(blt_int8u sector_num);
|
||||
static blt_int8u FlashGetSector(blt_addr address);
|
||||
static blt_bool FlashIsSingleBankMode(void);
|
||||
|
||||
|
@ -674,6 +675,70 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
} /*** end of FlashWriteBlock ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Checks if the flash sector is already completely erased.
|
||||
** \param sector_num Sector number. Note that this is the sector_num element of the
|
||||
** flashLayout array, not an index into the array.
|
||||
** \return BLT_TRUE if the flash sector is already erased, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_bool FlashEmptyCheckSector(blt_int8u sector_num)
|
||||
{
|
||||
blt_bool result = BLT_FALSE;
|
||||
blt_addr sectorAddr;
|
||||
blt_int32u sectorSize;
|
||||
blt_int8u sectorIdx;
|
||||
blt_int32u wordCnt;
|
||||
blt_int32u volatile const * wordPtr;
|
||||
|
||||
/* find the index of this sector into the flashLayout array */
|
||||
for (sectorIdx = 0; sectorIdx < FLASH_TOTAL_SECTORS; sectorIdx++)
|
||||
{
|
||||
/* is this the index that the sector number belongs to? */
|
||||
if (flashLayout[sectorIdx].sector_num == sector_num)
|
||||
{
|
||||
/* retrieve sector info */
|
||||
sectorAddr = flashLayout[sectorIdx].sector_start;
|
||||
sectorSize = flashLayout[sectorIdx].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));
|
||||
|
||||
/* update result to success for now */
|
||||
result = BLT_TRUE;
|
||||
/* 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++;
|
||||
}
|
||||
/* sector index found and checked. no need to continue with another one.*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* give the result back to the caller. */
|
||||
return result;
|
||||
} /*** end of FlashEmptyCheckSector ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Erases the flash sectors from first_sector up until last_sector.
|
||||
** \param first_sector First flash sector number.
|
||||
|
@ -721,6 +786,9 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
|
||||
/* erase all sectors one by one */
|
||||
for (sectorIdx=first_sector; sectorIdx<= last_sector; sectorIdx++)
|
||||
{
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sectorIdx) == BLT_FALSE)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
|
@ -735,6 +803,7 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* lock the flash array again */
|
||||
HAL_FLASH_Lock();
|
||||
|
|
|
@ -114,6 +114,7 @@ static tFlashBlockInfo *FlashSwitchBlock(tFlashBlockInfo *block, blt_addr base_a
|
|||
static blt_bool FlashAddToBlock(tFlashBlockInfo *block, blt_addr address,
|
||||
blt_int8u *data, blt_int32u len);
|
||||
static blt_bool FlashWriteBlock(tFlashBlockInfo *block);
|
||||
static blt_bool FlashEmptyCheckSector(blt_int8u sector_idx);
|
||||
static blt_bool FlashEraseSectors(blt_int8u first_sector_idx,
|
||||
blt_int8u last_sector_idx);
|
||||
static blt_int8u FlashGetSectorIdx(blt_addr address);
|
||||
|
@ -786,6 +787,56 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
} /*** end of FlashWriteBlock ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Checks if the flash sector is already completely erased.
|
||||
** \param sector_idx flash sector number index into flashLayout[].
|
||||
** \return BLT_TRUE if the flash sector is already erased, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
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 ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Erases the flash sectors from indices first_sector_idx up until
|
||||
** last_sector_idx into the flashLayout[] array.
|
||||
|
@ -826,6 +877,9 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector_idx, blt_int8u last_sec
|
|||
|
||||
/* erase the sectors one by one */
|
||||
for (sectorIdx = first_sector_idx; sectorIdx <= last_sector_idx; sectorIdx++)
|
||||
{
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sectorIdx) == BLT_FALSE)
|
||||
{
|
||||
/* service the watchdog */
|
||||
CopService();
|
||||
|
@ -855,7 +909,7 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector_idx, blt_int8u last_sec
|
|||
/* error detected so don't bother continuing with the loop */
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/* lock the flash array again */
|
||||
HAL_FLASH_Lock();
|
||||
|
|
Loading…
Reference in New Issue