stm32f4_vrom: Do checksum on copy of block.
authorsjlongland <sjlongland@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 27 Sep 2015 00:03:20 +0000 (00:03 +0000)
committersjlongland <sjlongland@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 27 Sep 2015 00:03:20 +0000 (00:03 +0000)
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

codec2-dev/stm32/src/stm32f4_vrom.c

index adc400b24940ac1db7d5c5b59a804dce02ddec9a..987211f22656a4ca9285e66624e6a705a116fcde 100644 (file)
@@ -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) {