mirror of https://github.com/rusefi/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
|
@ -53,9 +53,13 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 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 */
|
||||
{ 0x08008000, 0x08000 }, /* flash sectors 16 to 31 - 32kb */
|
||||
{ 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 */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -53,9 +53,13 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 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 */
|
||||
{ 0x08008000, 0x08000 }, /* flash sectors 16 to 31 - 32kb */
|
||||
{ 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 */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -53,9 +53,13 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 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 */
|
||||
{ 0x08008000, 0x08000 }, /* flash sectors 16 to 31 - 32kb */
|
||||
{ 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 */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -53,9 +53,13 @@ static const tFlashSector flashLayout[] =
|
|||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 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 */
|
||||
{ 0x08008000, 0x08000 }, /* flash sectors 16 to 31 - 32kb */
|
||||
{ 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 */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -49,30 +49,56 @@ static const tFlashSector flashLayout[] =
|
|||
/* { 0x08004800, 0x00800 }, flash sector 9 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08005000, 0x00800 }, flash sector 10 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08005800, 0x00800 }, flash sector 11 - 2kb (reserved for bootloader)*/
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 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 */
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 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 */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -49,30 +49,56 @@ static const tFlashSector flashLayout[] =
|
|||
/* { 0x08004800, 0x00800 }, flash sector 9 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08005000, 0x00800 }, flash sector 10 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08005800, 0x00800 }, flash sector 11 - 2kb (reserved for bootloader)*/
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 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 */
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 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 */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -49,30 +49,56 @@ static const tFlashSector flashLayout[] =
|
|||
/* { 0x08004800, 0x00800 }, flash sector 9 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08005000, 0x00800 }, flash sector 10 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08005800, 0x00800 }, flash sector 11 - 2kb (reserved for bootloader)*/
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 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 */
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 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 */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -49,30 +49,56 @@ static const tFlashSector flashLayout[] =
|
|||
/* { 0x08004800, 0x00800 }, flash sector 9 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08005000, 0x00800 }, flash sector 10 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08005800, 0x00800 }, flash sector 11 - 2kb (reserved for bootloader)*/
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 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 */
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 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.
|
||||
|
@ -699,17 +764,21 @@ 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++)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* set the sector to erase */
|
||||
eraseInitStruct.Sector = sectorIdx;
|
||||
/* submit the sector erase request */
|
||||
if(HAL_FLASHEx_Erase(&eraseInitStruct, (uint32_t *)&eraseSectorError) != HAL_OK)
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sectorIdx) == BLT_FALSE)
|
||||
{
|
||||
/* could not perform erase operation */
|
||||
result = BLT_FALSE;
|
||||
/* error detected so don't bother continuing with the loop */
|
||||
break;
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* set the sector to erase */
|
||||
eraseInitStruct.Sector = sectorIdx;
|
||||
/* submit the sector erase request */
|
||||
if(HAL_FLASHEx_Erase(&eraseInitStruct, (uint32_t *)&eraseSectorError) != HAL_OK)
|
||||
{
|
||||
/* could not perform erase operation */
|
||||
result = BLT_FALSE;
|
||||
/* error detected so don't bother continuing with the loop */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -715,17 +780,21 @@ 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++)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* set the sector to erase */
|
||||
eraseInitStruct.Sector = sectorIdx;
|
||||
/* submit the sector erase request */
|
||||
if(HAL_FLASHEx_Erase(&eraseInitStruct, (uint32_t *)&eraseSectorError) != HAL_OK)
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sectorIdx) == BLT_FALSE)
|
||||
{
|
||||
/* could not perform erase operation */
|
||||
result = BLT_FALSE;
|
||||
/* error detected so don't bother continuing with the loop */
|
||||
break;
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* set the sector to erase */
|
||||
eraseInitStruct.Sector = sectorIdx;
|
||||
/* submit the sector erase request */
|
||||
if(HAL_FLASHEx_Erase(&eraseInitStruct, (uint32_t *)&eraseSectorError) != HAL_OK)
|
||||
{
|
||||
/* could not perform erase operation */
|
||||
result = BLT_FALSE;
|
||||
/* error detected so don't bother continuing with the loop */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,40 +151,66 @@ static const tFlashSector flashLayout[] =
|
|||
/* { 0x08001000, 0x00800 }, flash sector 2 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08001800, 0x00800 }, flash sector 3 - 2kb (reserved for bootloader)*/
|
||||
/* { 0x08002000, 0x00800 }, flash sector 4 - 2kb (reserved for bootloader)*/
|
||||
{ 0x08002800, 0x00800 }, /* flash sector 5 - 2kb */
|
||||
{ 0x08003000, 0x00800 }, /* flash sector 6 - 2kb */
|
||||
{ 0x08003800, 0x00800 }, /* flash sector 7 - 2kb */
|
||||
{ 0x08004000, 0x00800 }, /* flash sector 8 - 2kb */
|
||||
{ 0x08004800, 0x00800 }, /* flash sector 9 - 2kb */
|
||||
{ 0x08005000, 0x00800 }, /* flash sector 10 - 2kb */
|
||||
{ 0x08005800, 0x00800 }, /* flash sector 11 - 2kb */
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 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 */
|
||||
{ 0x08002800, 0x00800 }, /* flash sector 5 - 2kb */
|
||||
{ 0x08003000, 0x00800 }, /* flash sector 6 - 2kb */
|
||||
{ 0x08003800, 0x00800 }, /* flash sector 7 - 2kb */
|
||||
{ 0x08004000, 0x00800 }, /* flash sector 8 - 2kb */
|
||||
{ 0x08004800, 0x00800 }, /* flash sector 9 - 2kb */
|
||||
{ 0x08005000, 0x00800 }, /* flash sector 10 - 2kb */
|
||||
{ 0x08005800, 0x00800 }, /* flash sector 11 - 2kb */
|
||||
{ 0x08006000, 0x00800 }, /* flash sector 12 - 2kb */
|
||||
{ 0x08006800, 0x00800 }, /* flash sector 13 - 2kb */
|
||||
{ 0x08007000, 0x00800 }, /* flash sector 14 - 2kb */
|
||||
{ 0x08007800, 0x00800 }, /* flash sector 15 - 2kb */
|
||||
{ 0x08008000, 0x00800 }, /* flash sector 16 - 2kb */
|
||||
{ 0x08008800, 0x00800 }, /* flash sector 17 - 2kb */
|
||||
{ 0x08009000, 0x00800 }, /* flash sector 18 - 2kb */
|
||||
{ 0x08009800, 0x00800 }, /* flash sector 19 - 2kb */
|
||||
{ 0x0800A000, 0x00800 }, /* flash sector 20 - 2kb */
|
||||
{ 0x0800A800, 0x00800 }, /* flash sector 21 - 2kb */
|
||||
{ 0x0800B000, 0x00800 }, /* flash sector 22 - 2kb */
|
||||
{ 0x0800B800, 0x00800 }, /* flash sector 23 - 2kb */
|
||||
{ 0x0800C000, 0x00800 }, /* flash sector 24 - 2kb */
|
||||
{ 0x0800C800, 0x00800 }, /* flash sector 25 - 2kb */
|
||||
{ 0x0800D000, 0x00800 }, /* flash sector 26 - 2kb */
|
||||
{ 0x0800D800, 0x00800 }, /* flash sector 27 - 2kb */
|
||||
{ 0x0800E000, 0x00800 }, /* flash sector 28 - 2kb */
|
||||
{ 0x0800E800, 0x00800 }, /* flash sector 29 - 2kb */
|
||||
{ 0x0800F000, 0x00800 }, /* flash sector 30 - 2kb */
|
||||
{ 0x0800F800, 0x00800 }, /* flash sector 31 - 2kb */
|
||||
{ 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,31 +777,35 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
/* not a valid sector address so abort */
|
||||
return BLT_FALSE;
|
||||
}
|
||||
/* determine timeout time of the operation */
|
||||
timeoutTime = TimerGet() + FLASH_ERASE_TIME_MAX_MS;
|
||||
/* start erase operation */
|
||||
XMC_FLASH_EraseSector((uint32_t *)sectorBaseAddr);
|
||||
/* wait for the flash operation to complete */
|
||||
while (XMC_FLASH_IsBusy() > 0)
|
||||
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sector_cnt) == BLT_FALSE)
|
||||
{
|
||||
/* check for operation timeout */
|
||||
if (TimerGet() > timeoutTime)
|
||||
/* determine timeout time of the operation */
|
||||
timeoutTime = TimerGet() + FLASH_ERASE_TIME_MAX_MS;
|
||||
/* start erase operation */
|
||||
XMC_FLASH_EraseSector((uint32_t *)sectorBaseAddr);
|
||||
/* wait for the flash operation to complete */
|
||||
while (XMC_FLASH_IsBusy() > 0)
|
||||
{
|
||||
/* timeout occurred. cannot continue */
|
||||
/* check for operation timeout */
|
||||
if (TimerGet() > timeoutTime)
|
||||
{
|
||||
/* timeout occurred. cannot continue */
|
||||
return BLT_FALSE;
|
||||
}
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
}
|
||||
/* check the result */
|
||||
status = XMC_FLASH_GetStatus();
|
||||
/* reset the erase finished flag */
|
||||
status &= ~XMC_FLASH_STATUS_ERASE_STATE;
|
||||
if (status != XMC_FLASH_STATUS_OK)
|
||||
{
|
||||
/* error occurred during flash erase, abort */
|
||||
return BLT_FALSE;
|
||||
}
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
}
|
||||
/* check the result */
|
||||
status = XMC_FLASH_GetStatus();
|
||||
/* reset the erase finished flag */
|
||||
status &= ~XMC_FLASH_STATUS_ERASE_STATE;
|
||||
if (status != XMC_FLASH_STATUS_OK)
|
||||
{
|
||||
/* 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.
|
||||
|
@ -722,17 +787,21 @@ 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++)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* set the sector to erase */
|
||||
eraseInitStruct.Sector = sectorIdx;
|
||||
/* submit the sector erase request */
|
||||
if(HAL_FLASHEx_Erase(&eraseInitStruct, (uint32_t *)&eraseSectorError) != HAL_OK)
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sectorIdx) == BLT_FALSE)
|
||||
{
|
||||
/* could not perform erase operation */
|
||||
result = BLT_FALSE;
|
||||
/* error detected so don't bother continuing with the loop */
|
||||
break;
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* set the sector to erase */
|
||||
eraseInitStruct.Sector = sectorIdx;
|
||||
/* submit the sector erase request */
|
||||
if(HAL_FLASHEx_Erase(&eraseInitStruct, (uint32_t *)&eraseSectorError) != HAL_OK)
|
||||
{
|
||||
/* could not perform erase operation */
|
||||
result = BLT_FALSE;
|
||||
/* error detected so don't bother continuing with the loop */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -827,35 +878,38 @@ 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++)
|
||||
{
|
||||
/* service the watchdog */
|
||||
CopService();
|
||||
/* get information about the sector */
|
||||
sectorBaseAddr = flashLayout[sectorIdx].sector_start;
|
||||
sectorSize = flashLayout[sectorIdx].sector_size;
|
||||
/* validate the sector information */
|
||||
if ( (sectorBaseAddr == FLASH_INVALID_ADDRESS) || (sectorSize == 0) )
|
||||
/* no need to erase the sector if it is already empty */
|
||||
if (FlashEmptyCheckSector(sectorIdx) == BLT_FALSE)
|
||||
{
|
||||
/* invalid sector information. flag error and abort erase operation */
|
||||
result = BLT_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* intialize the sector erase info structure */
|
||||
eraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
|
||||
eraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
|
||||
eraseInitStruct.Banks = flashLayout[sectorIdx].bank_num;
|
||||
eraseInitStruct.Sector = flashLayout[sectorIdx].sector_num;
|
||||
eraseInitStruct.NbSectors = 1;
|
||||
/* service the watchdog */
|
||||
CopService();
|
||||
/* get information about the sector */
|
||||
sectorBaseAddr = flashLayout[sectorIdx].sector_start;
|
||||
sectorSize = flashLayout[sectorIdx].sector_size;
|
||||
/* validate the sector information */
|
||||
if ( (sectorBaseAddr == FLASH_INVALID_ADDRESS) || (sectorSize == 0) )
|
||||
{
|
||||
/* invalid sector information. flag error and abort erase operation */
|
||||
result = BLT_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* submit the sector erase request */
|
||||
if (HAL_FLASHEx_Erase(&eraseInitStruct, (uint32_t *)&eraseSectorError) != HAL_OK)
|
||||
{
|
||||
/* could not perform erase operation */
|
||||
result = BLT_FALSE;
|
||||
/* error detected so don't bother continuing with the loop */
|
||||
break;
|
||||
}
|
||||
/* intialize the sector erase info structure */
|
||||
eraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
|
||||
eraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
|
||||
eraseInitStruct.Banks = flashLayout[sectorIdx].bank_num;
|
||||
eraseInitStruct.Sector = flashLayout[sectorIdx].sector_num;
|
||||
eraseInitStruct.NbSectors = 1;
|
||||
|
||||
/* submit the sector erase request */
|
||||
if (HAL_FLASHEx_Erase(&eraseInitStruct, (uint32_t *)&eraseSectorError) != HAL_OK)
|
||||
{
|
||||
/* could not perform erase operation */
|
||||
result = BLT_FALSE;
|
||||
/* error detected so don't bother continuing with the loop */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* lock the flash array again */
|
||||
HAL_FLASH_Lock();
|
||||
|
|
Loading…
Reference in New Issue