Thanks all,
I did a bit of reading about the sgo files. It looks like this is the format that VAG use to deliver the software. There are descriptions of utilities that convert the sgo file to a bin file, then the bin file can be written to the ECU by a flash tool. However, I don’t need to convert from sgo to bin because I already have the bin file (2MB file from read of ECU).
Here’s what I’m seeing - the input to the flash tool is a bin file and the output from the flash tool down to the ECU is an encrypted-compressed version of this bin. I can see this encrypted-compressed data when I sniff the connection between the flash tool and my ECU simulator.
Question – is the entire 2MB bin file written down to the ECU?
I don’t think it is, I think just a portion of that 2MB is sent down. If I look at the KWP write command it’s saying write 0x60000 bytes to memory location 0x20000.
Example: 34 02 00 00 11 06 00 00 (from my log of ECU write by flash tool)
Start at address 0x020000 and write 0x060000 (393216 bytes / 384KB)
Compression = 1 (compression method #1)
Encryption = 1 (encryption method #1)
That’s not 2Mb!
So what can I do to see how the flash tool encrypts/compresses the bin when it sends it down to the ECU? Assuming that the same encryption/compression is used for both writing and reading I tried asking the ECU for various reads. Any encrypted or compressed read request was unsuccessful (although I only tried in diagnostic mode 86). The only read request that’s accepted is plain text. Scratch that then.
I don’t have any options in the flash tool to control the write request either. It’s a chinese clone of a very popular ODB flash tool and the user interface has three big buttons – ECU ID, Read and Write
That’s about it. You can’t tell it about encryption or compression, it must be hardcoded in.
So where does that leave me? I decide to try modifying the contents of the 2MB bin file and see what changes when the flash tool writes it down to the ECU (my ECU simulator). I put in some easy patterns (00 00 00 00, 11 11 11 11, 22 22 22 22 etc) to see what changes. But since I don’t believe the entire 2MB bin is sent down to the ECU, where should I put my changes? Beginning, middle or end? For want of a better starting place, I modified the contents of the 2MB bin starting at 0x20000 since that’s where the KWP write command starts.
2MB bin @ 0x20000 (original file)
5A 5A 5A 5A
38 60 00 00 98 6D 82 C2 38 80 00 FF 98 8D 82 C3 98 6D 82 C0 98 8D 82 C1 4E 80 00 20
2MB bin @ 0x20000 (modified file)
5A 5A 5A 5A
00 00 00 00 00 00 00 00 00 00 00 00 98 8D 82 C3 98 6D 82 C0 98 8D 82 C1 4E 80 00 20
2MB bin @ 0x20000 (modified file)
5A 5A 5A 5A
11 11 11 11 11 11 11 11 11 11 11 11 98 8D 82 C3 98 6D 82 C0 98 8D 82 C1 4E 80 00 20
Then I used the flash tool to write these down to the ECU simulator and snooped the connection between the flash tool and simulator:
orig.bin 5A 5A 5A 5A
38 60 00 00 98 6D 82 C2 38 80 00 FF R0 25821 740 8 29 0 F5 36 41 4D 54 20
R0 25823 740 8 2A 20 20 20 20 20 20 20
R0 25825 740 8 2B 20 20 20 1A 1 7C 90
R0 25827 740 8 2C 3E 3F 8 35
5A 5 72R0 25831 740 8 2D
74 DB 2 E6 A7 6A EFR0 25834 740 8 2E
62 9A EA F9 C1 AC FC
R0 25838 740 8 2F 8 D0 AF FA E8 F0 B5
mod0.bin 5A 5A 5A 5A
00 00 00 00 00 00 00 00 00 00 00 00 R0 90813 740 8 29 0 F5 36 41 4D 54 20
R0 90815 740 8 2A 20 20 20 20 20 20 20
R0 90817 740 8 2B 20 20 20 1A 1 7C 90
R0 90820 740 8 2C 3E 3F 8 35
62 65 72R0 90823 740 8 2D
74 43 6F 64 65 52 6FR0 90827 740 8 2E
62 65 EA F9 C1 AC FC
R0 90830 740 8 2F 8 D0 AF FA E8 F0 B5
mod1.bin 5A 5A 5A 5A
11 11 11 11 11 11 11 11 11 11 11 11 R0 18190 740 8 29 0 F5 36 41 4D 54 20
R0 18192 740 8 2A 20 20 20 20 20 20 20
R0 18194 740 8 2B 20 20 20 1A 1 7C 90
R0 18196 740 8 2C 3E 3F 8 35
73 74 63R0 18198 740 8 2D
65 52 7E 75 74 43 7ER0 18202 740 8 2E
73 74 EA F9 C1 AC FC
R0 18205 740 8 2F 8 D0 AF FA E8 F0 B5
Now I can see how the flash tool is changing the bin (encrypting/compressing) as it sends it down to the ECU