Segment Swap utility

They go by many names, P01, P59, VPW, '0411 etc. Also covering E38 and newer here.
kur4o
Posts: 948
Joined: Sun Apr 10, 2016 9:20 pm

Re: Segment Swap utility

Post by kur4o »

Now the save and exraction works as expected.

I think the most appropriate file extension is just .bin. It is a binary file anyway so there will no confusions, especially with the labeling system you have applied.

I tried to save invalid bin on purpose and the program crashed.
You might add some security check on segment loading. Compare the length defined in the OS data vs the actual size of the selected calibration segment if there is mismatch throw an error to select another segment. Also check the if the selected segment`s numerical number matches the place it will go in.

About the patching, you may label the patches, an OS patch and caldata patch, based on the bin part the patch is in.

I will try to gather all the info for eeprom area and post later.
kur4o
Posts: 948
Joined: Sun Apr 10, 2016 9:20 pm

Re: Segment Swap utility

Post by kur4o »

Code: Select all

AT $4000 or $6000
69 CD C5 E4 00 C0 02 EB 31 4B 41 30 33 4C 31 55 
33 32 36 36 BC 00 39 56 00 C0 13 87 59 46 5A 42 
00 31 47 31 59 59 33 32 47 34 34 35 31 30 39 32 
33 32 3A 67 00 00 00 00 00 00 00 FF 00 00 80 14 
80 30 7F E7 7F D7 FF FF FF FF FF FF FF FF FF 00 
FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
FF FF FF FF FF FF FF FF A5 A0

69 CD seed
C5 E4 key 
00 C0 02 EB - 12583659[HARDWARE number in HEX]
31 4B 41 30 33 4C 31 55 33 32 36 36[serial number in ASCII] 
BC 00 39 56 -[some identifier]
00 C0 13 87 - 12587911[some nubmer on the PCM label below broadcast code]
59 46 5A 42 - YFZB[broadcast code in ASCII]
00 
31 47 31 59 59 33 32 47 34 34 35 31 30 39 32 33 32 3A 67 -[VIN in ASCII]
00 00 00 00 00 00 00 FF 00 00 80 14 80 30 7F E7 7F D7 FF FF FF FF FF FF FF FF FF 00 FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
A5 A0 -eeprom area check word
Here is the vin info.
That info can be saved on 2 different locations. To identify where that is stored read word $4088 and $6088. Check which one matches to $A5A0. If $4088 matches the vin info starts at $4000, if $6088 matches the vin info starts at $6000. If non matches the vin info might be corrupt or the data structure might be different.

On 99-00 PCM, the check word is stored at $4056 or $6056. The above info seems to be at the correct location.
Last edited by kur4o on Tue Jan 28, 2020 2:06 am, edited 1 time in total.
User avatar
joukoy
Posts: 392
Joined: Tue Dec 17, 2019 3:27 am
cars: Pontiac Firebird 1978

Re: Segment Swap utility

Post by joukoy »

VIN reading should be easy.

Currently OS extraction is "fake", it just copies full bin to OS folder.
Is it enough if I copy OS segements, (addresses found in $500)?

When building new binary, will need:
- OS + CAL segments
- VIN, or should it ask for one?
- Other parts?
kur4o
Posts: 948
Joined: Sun Apr 10, 2016 9:20 pm

Re: Segment Swap utility

Post by kur4o »

Building bin from scratch will need

Os segment 0-4000 and 20000-till last 2 bytes of bin
caldata segments 8000-end of last caldata segment.
Check if caldata segments are in correct order and size.
Fill last 2 bytes of bin and the space between last caldata segment till $20000 with 4AFC.
Copy 4000-8000 area from a user provided good bin, or external file.

Apply patches.
Correct checksums.
Here the user can enter new vin, serial and so on.
Check if the seed key pair is good[the algo number is $28].
Check if the eeprom data[4000-8000] is good for the selected OS. [a database needs to be made for this check].
Success.

Now you have the ultimate bin building tool.

If it is too much effort to convert the OS segment you can use full bins, but sometimes that can lead to confusions.
User avatar
joukoy
Posts: 392
Joined: Tue Dec 17, 2019 3:27 am
cars: Pontiac Firebird 1978

Re: Segment Swap utility

Post by joukoy »

kur4o wrote:
bin building tool.
Or Bin Builder?
https://github.com/joukoy/PCMBinBuilder

Trying to find good name and create usable GUI and functionality :D

Please test again.
I think there is at least 1 problem: I build new bin and opened it with Efilive => BCC is "J?J?"
Edit: Fixed bug: eeprom data was not copied to bin.
kur4o
Posts: 948
Joined: Sun Apr 10, 2016 9:20 pm

Re: Segment Swap utility

Post by kur4o »

I found some blatant bug. I hope you don`t fall off your chair.

Both Os segments and caldata segments are 1 byte short extracted. It could be because of the program not counting from 0. SO area from 0-3fff is $4000 bytes long. I guess you set the length to $3fff. Everything in the file should be even sized.

I hope you fix that so I can keep testing other areas of the program.

So far it looks much better than the initial design. Awesome work. It needs some final polishing to get the ultimate bin builder done.
User avatar
joukoy
Posts: 392
Joined: Tue Dec 17, 2019 3:27 am
cars: Pontiac Firebird 1978

Re: Segment Swap utility

Post by joukoy »

kur4o wrote:I found some blatant bug. I hope you don`t fall off your chair.

Both Os segments and caldata segments are 1 byte short extracted. It could be because of the program not counting from 0. SO area from 0-3fff is $4000 bytes long. I guess you set the length to $3fff. Everything in the file should be even sized.

I hope you fix that so I can keep testing other areas of the program.

So far it looks much better than the initial design. Awesome work. It needs some final polishing to get the ultimate bin builder done.
I set starting address to 0, ending address to 0x3FFF and let program to calculate:
writer.Write(Buf, (int)StartAddr, (int)(EndAddr-StartAddr));
So, obviously it writes 3FFF bytes (3FFF - 0 = 3FFF)
Are you saying OS segemnet 1 starts in address 0 and ends in address 0x4000, including 0x4000 ? If yes, I can change this to program.

But for calibration segments, addresses are read from binary, and used same block of code for writing as with OS segements.
kur4o
Posts: 948
Joined: Sun Apr 10, 2016 9:20 pm

Re: Segment Swap utility

Post by kur4o »

So, obviously it writes 3FFF bytes (3FFF - 0 = 3FFF)
It should be 3fff + 0 = $4000 length. The start and end addresses are correct but to convert it to length just add 1.

It is the same with the calibration segments. the length will be the end address - start address +1
User avatar
joukoy
Posts: 392
Joined: Tue Dec 17, 2019 3:27 am
cars: Pontiac Firebird 1978

Re: Segment Swap utility

Post by joukoy »

kur4o wrote:
So, obviously it writes 3FFF bytes (3FFF - 0 = 3FFF)
It should be 3fff + 0 = $4000 length. The start and end addresses are correct but to convert it to length just add 1.

It is the same with the calibration segments. the length will be the end address - start address +1
You are right.
Added +1 and confirmed with HEX editor, now file ends at 0x3FFF
Uploaded new exe.
User avatar
joukoy
Posts: 392
Joined: Tue Dec 17, 2019 3:27 am
cars: Pontiac Firebird 1978

Re: Segment Swap utility

Post by joukoy »

And of course the same bug when reading segments :rant:
New EXE again.
Post Reply