From: sjlongland Date: Sun, 27 Sep 2015 00:03:20 +0000 (+0000) Subject: stm32f4_vrom: Do checksum on copy of block. X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=a646b0b8e8af64ebd504647a7e69444d4aa65117;p=freetel-svn-tracking.git stm32f4_vrom: Do checksum on copy of block. Store a temporary copy of the block on the stack to do our checksumming on. This allows us to zero out the CRC32 field. (There is a way to include the CRC32 field in the checksum itself, but haven't figured out the mathematics needed yet.) git-svn-id: https://svn.code.sf.net/p/freetel/code@2400 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/stm32/src/stm32f4_vrom.c b/codec2-dev/stm32/src/stm32f4_vrom.c index adc400b2..987211f2 100644 --- a/codec2-dev/stm32/src/stm32f4_vrom.c +++ b/codec2-dev/stm32/src/stm32f4_vrom.c @@ -159,10 +159,14 @@ static const struct vrom_data_block_t* vrom_get_block( static uint32_t vrom_crc32( const struct vrom_data_block_t* const block) { + struct vrom_data_block_t temp_block; + uint32_t size = sizeof(temp_block); + const uint8_t* in = (const uint8_t*)(&temp_block); uint32_t tmp; uint32_t crc; - uint32_t size = VROM_BLOCK_SZ - sizeof(uint32_t); - const uint8_t* in = (const uint8_t*)(&(block->header.rom)); + + memcpy(&temp_block, block, sizeof(temp_block)); + temp_block.header.crc32 = 0; CRC_ResetDR(); while(size) {