From dea8e21945234fbe4b7745b80609cc0598c2dd14 Mon Sep 17 00:00:00 2001 From: Frank Voorburg Date: Mon, 17 Oct 2016 23:31:31 +0000 Subject: [PATCH] Refs #140. - Checksum location is now configurable for Cortex Mx targets, due to possible different size in vector tables. git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@157 5dc33758-31d5-4daf-9ae8-b24bf3d40d73 --- Target/Source/ARMCM0_STM32/flash.c | 18 +++++++++++++++++- Target/Source/ARMCM3_EFM32/flash.c | 18 +++++++++++++++++- Target/Source/ARMCM3_LM3S/flash.c | 18 +++++++++++++++++- Target/Source/ARMCM3_STM32/flash.c | 19 ++++++++++++++++++- Target/Source/ARMCM3_STM32F2/flash.c | 18 +++++++++++++++++- Target/Source/ARMCM4_STM32/flash.c | 18 +++++++++++++++++- Target/Source/ARMCM4_TM4C/flash.c | 18 +++++++++++++++++- 7 files changed, 120 insertions(+), 7 deletions(-) diff --git a/Target/Source/ARMCM0_STM32/flash.c b/Target/Source/ARMCM0_STM32/flash.c index c85df350..847b095e 100644 --- a/Target/Source/ARMCM0_STM32/flash.c +++ b/Target/Source/ARMCM0_STM32/flash.c @@ -51,8 +51,24 @@ /** \brief Number of bytes to erase per erase operation. */ #define FLASH_ERASE_BLOCK_SIZE (0x400) #endif -/** \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. + * For this target it is set to the end of the vector table. 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 FLASH_VECTOR_TABLE_CS_OFFSET #define 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." +#endif /**************************************************************************************** diff --git a/Target/Source/ARMCM3_EFM32/flash.c b/Target/Source/ARMCM3_EFM32/flash.c index 3fa7341c..deac01ed 100644 --- a/Target/Source/ARMCM3_EFM32/flash.c +++ b/Target/Source/ARMCM3_EFM32/flash.c @@ -44,8 +44,24 @@ #define FLASH_WRITE_BLOCK_SIZE (512) /** \brief Total numbers of sectors in array flashLayout[]. */ #define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0])) -/** \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. + * For this target it is set to the end of the vector table. 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 FLASH_VECTOR_TABLE_CS_OFFSET #define 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." +#endif /**************************************************************************************** diff --git a/Target/Source/ARMCM3_LM3S/flash.c b/Target/Source/ARMCM3_LM3S/flash.c index dff1666f..8658175b 100644 --- a/Target/Source/ARMCM3_LM3S/flash.c +++ b/Target/Source/ARMCM3_LM3S/flash.c @@ -48,8 +48,24 @@ #define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0])) /** \brief Number of bytes to erase per erase operation. */ #define FLASH_ERASE_BLOCK_SIZE (0x400) -/** \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. + * For this target it is set to the end of the vector table. 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 FLASH_VECTOR_TABLE_CS_OFFSET #define 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." +#endif /**************************************************************************************** diff --git a/Target/Source/ARMCM3_STM32/flash.c b/Target/Source/ARMCM3_STM32/flash.c index 311b0cb0..25c44f60 100644 --- a/Target/Source/ARMCM3_STM32/flash.c +++ b/Target/Source/ARMCM3_STM32/flash.c @@ -52,8 +52,17 @@ #endif /** \brief Macro for accessing the flash control registers. */ #define FLASH ((tFlashRegs *) (blt_int32u)0x40022000) -/** \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. + * For this target it is set to the end of the vector table. 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 FLASH_VECTOR_TABLE_CS_OFFSET #define FLASH_VECTOR_TABLE_CS_OFFSET (0x150) +#endif + #define FLASH_KEY1 ((blt_int32u)0x45670123) #define FLASH_KEY2 ((blt_int32u)0xCDEF89AB) #define FLASH_LOCK_BIT ((blt_int32u)0x00000080) @@ -66,6 +75,14 @@ #define FLASH_PG_BIT ((blt_int32u)0x00000001) +/**************************************************************************************** +* 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." +#endif + + /**************************************************************************************** * Type definitions ****************************************************************************************/ diff --git a/Target/Source/ARMCM3_STM32F2/flash.c b/Target/Source/ARMCM3_STM32F2/flash.c index 39723830..a348dcf2 100644 --- a/Target/Source/ARMCM3_STM32F2/flash.c +++ b/Target/Source/ARMCM3_STM32F2/flash.c @@ -44,8 +44,24 @@ #define FLASH_WRITE_BLOCK_SIZE (512) /** \brief Total numbers of sectors in array flashLayout[]. */ #define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0])) -/** \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. + * For this target it is set to the end of the vector table. 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 FLASH_VECTOR_TABLE_CS_OFFSET #define 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." +#endif /**************************************************************************************** diff --git a/Target/Source/ARMCM4_STM32/flash.c b/Target/Source/ARMCM4_STM32/flash.c index 07ee67ee..0e9cec48 100644 --- a/Target/Source/ARMCM4_STM32/flash.c +++ b/Target/Source/ARMCM4_STM32/flash.c @@ -45,8 +45,24 @@ #define FLASH_WRITE_BLOCK_SIZE (512) /** \brief Total numbers of sectors in array flashLayout[]. */ #define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0])) -/** \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. + * For this target it is set to the end of the vector table. 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 FLASH_VECTOR_TABLE_CS_OFFSET #define 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." +#endif /**************************************************************************************** diff --git a/Target/Source/ARMCM4_TM4C/flash.c b/Target/Source/ARMCM4_TM4C/flash.c index 7b555268..d2f725bf 100644 --- a/Target/Source/ARMCM4_TM4C/flash.c +++ b/Target/Source/ARMCM4_TM4C/flash.c @@ -50,8 +50,24 @@ #define FLASH_TOTAL_SECTORS (sizeof(flashLayout)/sizeof(flashLayout[0])) /** \brief Number of bytes to erase per erase operation. */ #define FLASH_ERASE_BLOCK_SIZE (0x400) -/** \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. + * For this target it is set to the end of the vector table. 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 FLASH_VECTOR_TABLE_CS_OFFSET #define 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." +#endif /****************************************************************************************