Other Parts Discussed in Thread: UCD3138
Tool/software:
Hello again...
I am having problems calculating and verifying the checksums in flash memory.
Here are the steps.
STEP 1
I downloaded my application and added the checksum as follows:
The check sum is: 0x3097B3F36D16
The bootloader then successfully boots the program so I know the checksum added to the end of block1 is correct (at least the bootloader thinks it is).
STEP 2
I verified this is correct using the fusion gui here:
STEP 3
I ran my firmware checksum calculation over the same address space and I get a different result. Here is my code snippet. I used was from the UCD3138 programmers manual.
The value I calculate in my firmware with the function included below, is: 0x18F9B3F36D16 while the value fusion GUI calculates is 0x3097B3F36D16.
Can you please verify that this is the same function that the bootloader uses or perhaps supply me with the code snippet?
Any help is GREATLY appreciated as usual!
.
// FROM SPEC... Uint64 a0_long_checksum =0; Uint64 a0_long_checksum01 =0; Uint64 a0_long_checksum23 =0; void calculate_checksum(register Uint32 *start_address, register Uint32 *end_address) { Uint64 lcs = a0_long_checksum; //use local register variable for speed?? TAW not sur that works while(start_address < end_address) { lcs = lcs + *start_address ; lcs = lcs + (Uint32)*(start_address + 1) ; start_address = start_address + 2; } a0_long_checksum = lcs; } void Pflash_GetChecksum01(void) { a0_long_checksum = 0; Uint32* start_address = (Uint32*) PGM_BLOCK0_ADDRESS; // 0x00000000 Uint32* end_address = (Uint32*) (PGM_BLOCK2_ADDRESS -8);// 0x00010000 - 8 calculate_checksum(start_address,end_address ); // result is in a0_long_checksum a0_long_checksum01 =a0_long_checksum; }