--
This commit is contained in:
@@ -220,6 +220,32 @@ blt_bool NvmDoneHook(void)
|
||||
|
||||
|
||||
#if (BOOT_NVM_CHECKSUM_HOOKS_ENABLE > 0)
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Writes a checksum of the user program to non-volatile memory. This is
|
||||
** performed once the entire user program has been programmed. Through
|
||||
** the checksum, the bootloader can check if a valid user programming is
|
||||
** present and can be started.
|
||||
** \return BLT_TRUE if successful, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool NvmVerifyChecksumHook(void);
|
||||
blt_bool NvmWriteChecksumHook(void)
|
||||
{
|
||||
blt_bool result = BLT_TRUE;
|
||||
uint32_t crc = 0;
|
||||
uint8_t data[FLASH_WRITE_BLOCK_SIZE] = {0};
|
||||
uint32_t len;
|
||||
FlashGetBlockInfoData(data, &len);
|
||||
if (len > FLASH_USER_PROG_SIZE)
|
||||
return BLT_FALSE;
|
||||
if (NvmVerifyChecksumHook() == BLT_TRUE)
|
||||
return BLT_TRUE;
|
||||
else
|
||||
return BLT_FALSE;
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Verifies the checksum, which indicates that a valid user program is
|
||||
** present and can be started.
|
||||
@@ -230,8 +256,9 @@ blt_bool NvmVerifyChecksumHook(void)
|
||||
{
|
||||
uint32_t crcCalculated;
|
||||
uint32_t len = *(uint32_t*)(LEN_ADDRESS);
|
||||
if (len > FLASH_USER_PROG_SIZE)
|
||||
return BLT_FALSE;
|
||||
uint32_t crcInFlash = *(uint32_t*) (FLASH_USER_PROG_ADDRESS + len );
|
||||
|
||||
if (calculateROM_CRC32(FLASH_AREA_FULLPROG, &crcCalculated) == BLT_TRUE)
|
||||
{
|
||||
if (crcCalculated == crcInFlash )
|
||||
@@ -243,25 +270,6 @@ blt_bool NvmVerifyChecksumHook(void)
|
||||
} /*** end of NvmVerifyChecksum ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Writes a checksum of the user program to non-volatile memory. This is
|
||||
** performed once the entire user program has been programmed. Through
|
||||
** the checksum, the bootloader can check if a valid user programming is
|
||||
** present and can be started.
|
||||
** \return BLT_TRUE if successful, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool NvmWriteChecksumHook(void)
|
||||
{
|
||||
blt_bool result = BLT_TRUE;
|
||||
uint32_t crc = 0;
|
||||
result = calculateROM_CRC32(FLASH_AREA_FULLPROG, &crc);
|
||||
if (result == BLT_TRUE)
|
||||
result = FlashWrite(FLASH_USER_PROG_ADDRESS + BOOT_FLASH_VECTOR_TABLE_CS_OFFSET + 1, sizeof (blt_addr), (blt_int8u*) &crc);
|
||||
else
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
#endif /* BOOT_NVM_CHECKSUM_HOOKS_ENABLE > 0 */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user