Calculating checksums? Can't get OS to work

They go by many names, P01, P59, VPW, '0411 etc. Also covering E38 and newer here.
04colyZQ8
Posts: 380
Joined: Thu Jan 16, 2014 12:41 pm
cars: 2004 Colorado 4.8L swap
86/90 Jimmy 6.5L diesel swap
80 Chevrolet Silverado TBI swap
88dodge W100 LPG conversion

Re: Calculating checksums? Can't get OS to work

Post by 04colyZQ8 »

jlvaldez wrote:Hey all, Gampy was helpful with information calculating the checksums for the various segments. I threw together a simple python script to generate and check the checksums of the various segments in a binary. Right now, I'm trying the P01/411 binary off my corvette, and I can get all segments to work correctly, except the OS.

From this thread that Gampy pointed me to: viewtopic.php?f=42&t=6198#p91839

Code: Select all

success &= this.ValidateRange(      0, 0x7FFFD,   0x500, "Operating system");
            success &= this.ValidateRange( 0x8002, 0x13FFF,  0x8000, "Engine calibration");
            success &= this.ValidateRange(0x14002, 0x16DFF, 0x14000, "Engine diagnostics.");
            success &= this.ValidateRange(0x16E02, 0x1BDFF, 0x16E00, "Transmission calibration");
            success &= this.ValidateRange(0x1BE02, 0x1C7FF, 0x1BE00, "Transmission diagnostics");
            success &= this.ValidateRange(0x1C802, 0x1E51F, 0x1C800, "Fuel system");
            success &= this.ValidateRange(0x1E522, 0x1EE9F, 0x1E520, "System");
            success &= this.ValidateRange(0x1EEA2, 0x1EF9F, 0x1EEA0, "Speedometer");
And Gampy pointed out that the correct OS segment information is:
0x000000 -> 0x0004FF
0x000502 -> 0x003FFF
0x020000 -> 0x07FFFF
Checksum is stored at 0x500

Yet for whatever reason, whenever I go through and add up these segments, I get invalid checksums, but the rest of the addresses in the code block work correctly (checksum + sum of 16-bit words = 0).

To be clear about how I'm doing this:
1) Sum each 16-bit word within each segment together.
2) Sum each of the sums from each segment
3) Bitwise and with 0xFFFF (truncate)

This strategy works for all segments except the OS, which leads me to believe an address range is wrong?

Code: Select all

python3 checksum.py 
Sum iteration: 0x0 0x4ff Size: 1280
Sum iteration: 0x502 0x3fff Size: 15102
Sum iteration: 0x20000 0x7ffff Size: 393216
I'm having trouble manually calculating some checksums on a BCM, I think its down similarly to the GM pcms. I can figure out the first 4 bits of a segment that's the sum 2s compliant, then byte swap. However the first crc16 checksum how is that calculated? what do you mean by "(checksum + sum of 16-bit words = 0)" ? I tired crc16 of the whole segment - the sum 16 bit of the segment, except the first 4 bits (second checksum), and that didn't equal zero? Please explain how to calculate the first checksum located at 8 from the start of the segment. Thanks -Jamie
Post Reply