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 * a different checksum location, because this one is added at the end of the
* user program's vector table. * 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 /** \brief Enable support for a custom flash layout table. It is located in
* flash_layout.c. This was done because the default flashLayout[] table * flash_layout.c. This was done because the default flashLayout[] table
* in the bootloader's core has more flash memory reserved for the bootloader * 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 * a different checksum location, because this one is added at the end of the
* user program's vector table. * 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 /** \brief Enable support for a custom flash layout table. It is located in
* flash_layout.c. This was done because the default flashLayout[] table * flash_layout.c. This was done because the default flashLayout[] table
* in the bootloader's core has more flash memory reserved for the bootloader * 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 * a different checksum location, because this one is added at the end of the
* user program's vector table. * 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 /** \brief Enable support for a custom flash layout table. It is located in
* flash_layout.c. This was done because the default flashLayout[] table * flash_layout.c. This was done because the default flashLayout[] table
* in the bootloader's core has more flash memory reserved for the bootloader * 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 * a different checksum location, because this one is added at the end of the
* user program's vector table. * 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 * a different checksum location, because this one is added at the end of the
* user program's vector table. * 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 * a different checksum location, because this one is added at the end of the
* user program's vector table. * 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 * of the checksum in the user program accordingly. Otherwise the checksum
* verification will always fail. * verification will always fail.
*/ */
#ifndef FLASH_VECTOR_TABLE_CS_OFFSET #ifndef BOOT_FLASH_VECTOR_TABLE_CS_OFFSET
#define FLASH_VECTOR_TABLE_CS_OFFSET (0xC0) #define BOOT_FLASH_VECTOR_TABLE_CS_OFFSET (0xC0)
#endif #endif
/**************************************************************************************** /****************************************************************************************
* Plausibility checks * Plausibility checks
****************************************************************************************/ ****************************************************************************************/
#if (FLASH_VECTOR_TABLE_CS_OFFSET >= FLASH_WRITE_BLOCK_SIZE) #if (BOOT_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." #error "BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is set too high. It must be located in the first writable block."
#endif #endif
#ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE #ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
@ -363,7 +363,7 @@ blt_bool FlashWriteChecksum(void)
signature_checksum += 1; /* two's complement */ signature_checksum += 1; /* two's complement */
/* write the checksum */ /* 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); sizeof(blt_addr), (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/ } /*** 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+0x10));
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14)); 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+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 */ /* sum should add up to an unsigned 32-bit value of 0 */
if (signature_checksum == 0) if (signature_checksum == 0)
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,8 +45,15 @@
#define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0])) #define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0]))
#define FLASH_LAST_SECTOR_IDX (FLASH_TOTAL_SECTORS-1) #define FLASH_LAST_SECTOR_IDX (FLASH_TOTAL_SECTORS-1)
#define FLASH_ERASE_BLOCK_SIZE (512) #define FLASH_ERASE_BLOCK_SIZE (512)
/** \brief Offset into the user program's vector table where the checksum is located. */ /** \brief Offset into the user program's vector table where the checksum is located.
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x82) * 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. */ /** \brief Total size of the vector table, excluding the bootloader specific checksum. */
#define FLASH_VECTOR_TABLE_SIZE (0x80) #define FLASH_VECTOR_TABLE_SIZE (0x80)
/** \brief Start address of the bootloader programmable flash. */ /** \brief Start address of the bootloader programmable flash. */
@ -101,6 +108,10 @@
/**************************************************************************************** /****************************************************************************************
* Plausibility checks * 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 #ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
#define BOOT_FLASH_CUSTOM_LAYOUT_ENABLE (0u) #define BOOT_FLASH_CUSTOM_LAYOUT_ENABLE (0u)
#endif #endif
@ -562,7 +573,7 @@ blt_bool FlashWriteChecksum(void)
/* write the checksum */ /* write the checksum */
checksum_address = flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \ checksum_address = flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \ 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), return FlashWrite(checksum_address, sizeof(signature_checksum),
(blt_int8u *)&signature_checksum); (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/ } /*** end of FlashWriteChecksum ***/
@ -584,7 +595,7 @@ blt_bool FlashVerifyChecksum(void)
/* get linear address of the checksum */ /* get linear address of the checksum */
checksum_addr_lin = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \ checksum_addr_lin = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \ 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 */ /* get linear address of the vector table start */
vector_table_addr_lin = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \ vector_table_addr_lin = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \ flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \

View File

@ -47,8 +47,15 @@
#define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0])) #define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0]))
#define FLASH_LAST_SECTOR_IDX (FLASH_TOTAL_SECTORS-1) #define FLASH_LAST_SECTOR_IDX (FLASH_TOTAL_SECTORS-1)
#define FLASH_ERASE_BLOCK_SIZE (256) #define FLASH_ERASE_BLOCK_SIZE (256)
/** \brief Offset into the user program's vector table where the checksum is located. */ /** \brief Offset into the user program's vector table where the checksum is located.
#define FLASH_VECTOR_TABLE_CS_OFFSET (0x82) * 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. */ /** \brief Total size of the vector table, excluding the bootloader specific checksum. */
#define FLASH_VECTOR_TABLE_SIZE (0x80) #define FLASH_VECTOR_TABLE_SIZE (0x80)
/** \brief Start address of the bootloader programmable flash. */ /** \brief Start address of the bootloader programmable flash. */
@ -96,6 +103,10 @@
/**************************************************************************************** /****************************************************************************************
* Plausibility checks * 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 #ifndef BOOT_FLASH_CUSTOM_LAYOUT_ENABLE
#define BOOT_FLASH_CUSTOM_LAYOUT_ENABLE (0u) #define BOOT_FLASH_CUSTOM_LAYOUT_ENABLE (0u)
#endif #endif
@ -594,7 +605,7 @@ blt_bool FlashWriteChecksum(void)
/* write the checksum */ /* write the checksum */
checksum_address = flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \ checksum_address = flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \ 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), return FlashWrite(checksum_address, sizeof(signature_checksum),
(blt_int8u *)&signature_checksum); (blt_int8u *)&signature_checksum);
} /*** end of FlashWriteChecksum ***/ } /*** end of FlashWriteChecksum ***/
@ -616,7 +627,7 @@ blt_bool FlashVerifyChecksum(void)
/* get global address of the checksum */ /* get global address of the checksum */
checksum_addr_glob = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \ checksum_addr_glob = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \ 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 */ /* get global address of the vector table start */
vector_table_addr_glob = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \ vector_table_addr_glob = (flashLayout[FLASH_LAST_SECTOR_IDX].sector_start + \
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \ flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \