Refs #383. Refactored FLASH_VECTOR_TABLE_CS_OFFSET to BOOT_FLASH_VECTOR_TABLE_CS_OFFSET.

git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@363 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
Frank Voorburg 2017-09-11 11:28:39 +00:00
parent 39edea4e62
commit c512848520
18 changed files with 96 additions and 74 deletions

View File

@ -146,7 +146,7 @@
* a different checksum location, because this one is added at the end of the
* user program's vector table.
*/
#define FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
/** \brief Enable support for a custom flash layout table. It is located in
* flash_layout.c. This was done because the default flashLayout[] table
* in the bootloader's core has more flash memory reserved for the bootloader

View File

@ -128,7 +128,7 @@
* a different checksum location, because this one is added at the end of the
* user program's vector table.
*/
#define FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
/** \brief Enable support for a custom flash layout table. It is located in
* flash_layout.c. This was done because the default flashLayout[] table
* in the bootloader's core has more flash memory reserved for the bootloader

View File

@ -128,7 +128,7 @@
* a different checksum location, because this one is added at the end of the
* user program's vector table.
*/
#define FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
/** \brief Enable support for a custom flash layout table. It is located in
* flash_layout.c. This was done because the default flashLayout[] table
* in the bootloader's core has more flash memory reserved for the bootloader

View File

@ -182,7 +182,7 @@
* a different checksum location, because this one is added at the end of the
* user program's vector table.
*/
#define FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
/****************************************************************************************

View File

@ -182,7 +182,7 @@
* a different checksum location, because this one is added at the end of the
* user program's vector table.
*/
#define FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
/****************************************************************************************

View File

@ -192,7 +192,7 @@
* a different checksum location, because this one is added at the end of the
* user program's vector table.
*/
#define FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0xec)
/****************************************************************************************

View File

@ -58,16 +58,16 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0xC0)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0xC0)
#endif
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -363,7 +363,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -386,7 +386,7 @@ blt_bool FlashVerifyChecksum(void)
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{

View File

@ -54,8 +54,8 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x018)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x018)
#endif
/** \brief Maximum time for a sector erase operation as specified by the XCM1xxx data-
@ -72,8 +72,8 @@
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -387,7 +387,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -409,7 +409,7 @@ blt_bool FlashVerifyChecksum(void)
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{

View File

@ -51,16 +51,16 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x0B8)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x0B8)
#endif
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -360,7 +360,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -383,7 +383,7 @@ blt_bool FlashVerifyChecksum(void)
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{

View File

@ -55,16 +55,16 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0xF0)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0xF0)
#endif
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -361,7 +361,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -384,7 +384,7 @@ blt_bool FlashVerifyChecksum(void)
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{

View File

@ -59,8 +59,8 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x150)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x150)
#endif
#define FLASH_KEY1 ((blt_int32u)0x45670123)
@ -78,8 +78,8 @@
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -392,7 +392,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -415,7 +415,7 @@ blt_bool FlashVerifyChecksum(void)
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{

View File

@ -51,16 +51,16 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x184)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x184)
#endif
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -353,7 +353,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -376,7 +376,7 @@ blt_bool FlashVerifyChecksum(void)
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{

View File

@ -58,16 +58,16 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x188)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x188)
#endif
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -396,7 +396,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -419,7 +419,7 @@ blt_bool FlashVerifyChecksum(void)
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{

View File

@ -52,16 +52,16 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x188)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x188)
#endif
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -376,7 +376,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -399,7 +399,7 @@ blt_bool FlashVerifyChecksum(void)
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{

View File

@ -57,16 +57,16 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x26C)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x26C)
#endif
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -363,7 +363,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -386,7 +386,7 @@ blt_bool FlashVerifyChecksum(void)
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0)
{

View File

@ -53,8 +53,8 @@
* of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail.
*/
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x200)
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x200)
#endif
/** \brief Minimum amount of bytes that can be programmed to flash at a time. It is
@ -84,8 +84,8 @@
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -377,7 +377,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum = ~signature_checksum; /* one's complement */
/* write the checksum */
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
return FlashWrite(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET,
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -406,7 +406,7 @@ blt_bool FlashVerifyChecksum(void)
/* read the checksum value from flash that was writtin by the bootloader at the end
* of the last firmware update
*/
signature_checksum_rom = *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
signature_checksum_rom = *((blt_int32u *)(flashLayout[0].sector_start+BOOT_FLASH_VECTOR_TABLE_CS_OFFSET));
/* verify that they are both the same */
if (signature_checksum == signature_checksum_rom)

View File

@ -45,8 +45,15 @@
#define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0]))
#define FLASH_LAST_SECTOR_IDX (FLASH_TOTAL_SECTORS-1)
#define FLASH_ERASE_BLOCK_SIZE (512)
/** \brief Offset into the user program's vector table where the checksum is located. */
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x82)
/** \brief Offset into the user program's vector table where the checksum is located.
* Note that the value can be overriden in blt_conf.h, because the size of the
* vector table could vary. When changing this value, don't forget to update the
* location of the checksum in the user program accordingly. Otherwise the
* checksum verification will always fail.
*/
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x82)
#endif
/** \brief Total size of the vector table, excluding the bootloader specific checksum. */
#define FLASH_VECTOR_TABLE_SIZE (0x80)
/** \brief Start address of the bootloader programmable flash. */
@ -101,6 +108,10 @@
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
#define BOOT_FLASH_CUSTOM_LAYOUT_ENABLE (0u)
#endif
@ -562,7 +573,7 @@ blt_bool FlashWriteChecksum(void)
/* write the checksum */
checksum_address = flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \
FLASH_VECTOR_TABLE_CS_OFFSET;
BOOT_FLASH_VECTOR_TABLE_CS_OFFSET;
return FlashWrite(checksum_address, sizeof(signature_checksum),
(blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -584,7 +595,7 @@ blt_bool FlashVerifyChecksum(void)
/* get linear address of the checksum */
checksum_addr_lin = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \
FLASH_VECTOR_TABLE_CS_OFFSET);
BOOT_FLASH_VECTOR_TABLE_CS_OFFSET);
/* get linear address of the vector table start */
vector_table_addr_lin = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \

View File

@ -47,8 +47,15 @@
#define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0]))
#define FLASH_LAST_SECTOR_IDX (FLASH_TOTAL_SECTORS-1)
#define FLASH_ERASE_BLOCK_SIZE (256)
/** \brief Offset into the user program's vector table where the checksum is located. */
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x82)
/** \brief Offset into the user program's vector table where the checksum is located.
* Note that the value can be overriden in blt_conf.h, because the size of the
* vector table could vary. When changing this value, don't forget to update the
* location of the checksum in the user program accordingly. Otherwise the
* checksum verification will always fail.
*/
#ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0x82)
#endif
/** \brief Total size of the vector table, excluding the bootloader specific checksum. */
#define FLASH_VECTOR_TABLE_SIZE (0x80)
/** \brief Start address of the bootloader programmable flash. */
@ -96,6 +103,10 @@
/****************************************************************************************
* Plausibility checks
****************************************************************************************/
#if (BOOT_FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE)
#error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
#define BOOT_FLASH_CUSTOM_LAYOUT_ENABLE (0u)
#endif
@ -594,7 +605,7 @@ blt_bool FlashWriteChecksum(void)
/* write the checksum */
checksum_address = flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \
FLASH_VECTOR_TABLE_CS_OFFSET;
BOOT_FLASH_VECTOR_TABLE_CS_OFFSET;
return FlashWrite(checksum_address, sizeof(signature_checksum),
(blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/
@ -616,7 +627,7 @@ blt_bool FlashVerifyChecksum(void)
/* get global address of the checksum */
checksum_addr_glob = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \
FLASH_VECTOR_TABLE_CS_OFFSET);
BOOT_FLASH_VECTOR_TABLE_CS_OFFSET);
/* get global address of the vector table start */
vector_table_addr_glob = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \