Segment Swap utility
Re: Segment Swap utility
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.
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.
Re: Segment Swap utility
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
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.
Re: Segment Swap utility
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?
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?
Re: Segment Swap utility
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.
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.
Re: Segment Swap utility
Or Bin Builder?kur4o wrote:
bin building tool.
https://github.com/joukoy/PCMBinBuilder
Trying to find good name and create usable GUI and functionality
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.
Re: Segment Swap utility
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.
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.
Re: Segment Swap utility
I set starting address to 0, ending address to 0x3FFF and let program to calculate: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.
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.
Re: Segment Swap utility
It should be 3fff + 0 = $4000 length. The start and end addresses are correct but to convert it to length just add 1.So, obviously it writes 3FFF bytes (3FFF - 0 = 3FFF)
It is the same with the calibration segments. the length will be the end address - start address +1
Re: Segment Swap utility
You are right.kur4o wrote:It should be 3fff + 0 = $4000 length. The start and end addresses are correct but to convert it to length just add 1.So, obviously it writes 3FFF bytes (3FFF - 0 = 3FFF)
It is the same with the calibration segments. the length will be the end address - start address +1
Added +1 and confirmed with HEX editor, now file ends at 0x3FFF
Uploaded new exe.
Re: Segment Swap utility
And of course the same bug when reading segments
New EXE again.
New EXE again.