PHF to HEX?

Ford information and tools can be found here
User avatar
pman92
Posts: 577
Joined: Thu May 03, 2012 10:50 pm
Location: Castlemaine, Vic
Contact:

Re: PHF to HEX?

Post by pman92 »

TripleFJeff wrote: Sun Apr 06, 2025 10:45 pm I'm not a programmer and I don't know python
Install python (https://www.python.org/downloads/), download the attached script, an drag and drop your .bin files onto it.
You'll probably have to install the intelhex library from a terminal first (run "pip install intelhex")

Or use PCMflash to write bin instead which I can also recommend.

DWS wrote: Mon Apr 07, 2025 12:22 am hex - I'm guessing this is the intel hex format that pman92 posted about, but I'll know more looking at the file later. Sounds like it's similar to PHF, not a raw dump file. The confusing thing is, Ford calls the older files a hex file too, but they are just a bin file with a hex extension.
intel hex is the standard format files are stored in when working with microcontrollers.
They can take up more space since everything is stored as ASCII. But they also only take up as much space as is used.
EG. a simple program that uses only 5% of a micros storage space is still much smaller stored as .hex than .bin
Plus you can store different memory sections (flash / eeprom etc.) in the same file.

Having a look at a .phf file I can see the similarity. Seems to be exactly the same idea.
Just looks like the data is stored as binary rather than ASCII to save space.
Attachments
bin_2_hex.py
(1.64 KiB) Downloaded 40 times
DWS
Posts: 203
Joined: Tue Oct 12, 2021 10:04 am
cars: Tons of Toyotas, 2003 cavi derby car, ford trucks, etc.
Location: USA
Contact:

Re: PHF to HEX?

Post by DWS »

Funny, I already made a converted on my website PHF to HEX.

How do you generate the header and footer data with out a file to reference since you're going BIN to HEX? Like if it's always the same computer type, then yea copy/paste the same data, but that's not really a universal solution.

Btw I coded the check sum math and everything on my website for PHF, it's the same setup, just presented in a different way. Eventually probably need to allow for HEX2PHF, and HEX2BIN. The not so easy part is BIN2PHF or BIN2HEX since the metadata isn't known by default and the extra checksums and such.

Anyway, this is more of a test/dev link but if all looks good I'll replace the orig phf2bin file since it does both.

https://eec.derbyws.com/phf2hex.php
Ford EEC-V Tuner Site
  • Immo Off, PATS, Security only currently
  • Bank Swapping
  • View VIN and other info about the bin file
PHF to BIN Converter/Viewer
User avatar
pman92
Posts: 577
Joined: Thu May 03, 2012 10:50 pm
Location: Castlemaine, Vic
Contact:

Re: PHF to HEX?

Post by pman92 »

DWS wrote: Mon Apr 07, 2025 8:43 am How do you generate the header and footer data with out a file to reference since you're going BIN to HEX?
I'm not sure how you would do that. It's not really a part of the intel hex format.
I believe when parsing an intel hex file it should technically ignore everything upto the first ":" character (start of first record / line). And will ignore data between records until it sees the next ":". So you could put headers / footers in the file with other data (such as checksums and such). But how they are formulated and what they contain is application dependant
TripleFJeff
Posts: 9
Joined: Thu Apr 03, 2025 3:42 am

Re: PHF to HEX?

Post by TripleFJeff »

pman92 wrote: Mon Apr 07, 2025 7:45 am Or use PCMflash to write bin instead which I can also recommend.
While I'd like to avoid having to get yet another tool... have you taken a Ford PHF, converted to BIN, and used PCMflash to program it? If we can't get the PHF to HEX to work with my tool, than that would be an option.
User avatar
pman92
Posts: 577
Joined: Thu May 03, 2012 10:50 pm
Location: Castlemaine, Vic
Contact:

Re: PHF to HEX?

Post by pman92 »

TripleFJeff wrote: Mon Apr 07, 2025 11:21 am
pman92 wrote: Mon Apr 07, 2025 7:45 am Or use PCMflash to write bin instead which I can also recommend.
While I'd like to avoid having to get yet another tool... have you taken a Ford PHF, converted to BIN, and used PCMflash to program it? If we can't get the PHF to HEX to work with my tool, than that would be an option.
Yes I have.

The ford PHF files won't have a VID block in them though. So stuff like VIN number isn't in the file.

This will be the same problem regardless of using pcmflash or converting phf to hex and using your tool (you will have to transfer the VID block into file).

PCMflash will transfer the VID over from the PCM automatically (unless you enabled recovery mode).
oldtinfords
Posts: 43
Joined: Sun Jun 25, 2017 8:22 pm

Re: PHF to HEX?

Post by oldtinfords »

DWS wrote: Mon Apr 07, 2025 8:43 am
Btw I coded the check sum math and everything on my website for PHF, it's the same setup, just presented in a different way. Eventually probably need to allow for HEX2PHF, and HEX2BIN. The not so easy part is BIN2PHF or BIN2HEX since the metadata isn't known by default and the extra checksums and such.

Anyway, this is more of a test/dev link but if all looks good I'll replace the orig phf2bin file since it does both.

https://eec.derbyws.com/phf2hex.php
Your tool has created identical hex files to the couple of hex files I have.

I've only had a brief play with PT, it will read the VID block, allow you to edit, load & save VID files, so utilising hex files should work ok.
There's the same options for TRID.

Now I'll have to find some time to dig out the mycanic & do some testing.
TripleFJeff
Posts: 9
Joined: Thu Apr 03, 2025 3:42 am

Re: PHF to HEX?

Post by TripleFJeff »

pman92 wrote: Mon Apr 07, 2025 12:55 pm The ford PHF files won't have a VID block in them though. So stuff like VIN number isn't in the file.
PTDiag will do the VID. In fact, the entire point of this exercise is to wipe out the VID so I can rewrite it with a different VIN. You can't overwrite a VID, so the only way to do it is with a complete rewrite of the software.
TripleFJeff
Posts: 9
Joined: Thu Apr 03, 2025 3:42 am

Re: PHF to HEX?

Post by TripleFJeff »

oldtinfords wrote: Mon Apr 07, 2025 6:54 pm Now I'll have to find some time to dig out the mycanic & do some testing.
mycanic is newer hardware from the same company (eepod) as the MCS1 I'm using. They use the same drivers.
TripleFJeff
Posts: 9
Joined: Thu Apr 03, 2025 3:42 am

Re: PHF to HEX?

Post by TripleFJeff »

DWS, let me know if you got some PMs from me. Seems to be acting up and things are stuck in my Outbox.
DWS
Posts: 203
Joined: Tue Oct 12, 2021 10:04 am
cars: Tons of Toyotas, 2003 cavi derby car, ford trucks, etc.
Location: USA
Contact:

Re: PHF to HEX?

Post by DWS »

TripleFJeff wrote: Tue Apr 08, 2025 1:56 am DWS, let me know if you got some PMs from me. Seems to be acting up and things are stuck in my Outbox.
Yep, it seems like I got them all. FYI the outbox is more of a read receipt type of setup. A message stays there until the other party views it. I know it's confusing since the real outbox in the days of email clients, if it was stuck there it meant it didn't send out.



oldtinfords wrote: Mon Apr 07, 2025 6:54 pm
DWS wrote: Mon Apr 07, 2025 8:43 am
Btw I coded the check sum math and everything on my website for PHF, it's the same setup, just presented in a different way. Eventually probably need to allow for HEX2PHF, and HEX2BIN. The not so easy part is BIN2PHF or BIN2HEX since the metadata isn't known by default and the extra checksums and such.

Anyway, this is more of a test/dev link but if all looks good I'll replace the orig phf2bin file since it does both.

https://eec.derbyws.com/phf2hex.php
Your tool has created identical hex files to the couple of hex files I have.

I've only had a brief play with PT, it will read the VID block, allow you to edit, load & save VID files, so utilising hex files should work ok.
There's the same options for TRID.

Now I'll have to find some time to dig out the mycanic & do some testing.
Thanks for confirming. I've added a space prefix setting as it seems like PTDiag (I think that's what Jeff is using) seems to require 2 space prefixes in the header/footers. The way the code works, no headers or no footers might break the formatting a little and the $ line gets the full prefix, while the file I got from Jeff has 1 space instead of 2, and the PHF file I'm looking at has no spaces, but if you have 2 space prefix, the site outputs 2 before the $. Not sure how picky the software is around the exact formatting of that. No footers would probably put double the prefix at the end then the @ if I'm thinking right, probably doesn't break anything though.

Never knew these formats were even desired or being used, so completely new to me lol. Eventually I'll probably add them as options on my main tuning website once it accepts the newer file types and probably should allow it to use PHF and HEX files as well as bins. The automatic file identification got a lot more complex suddenly lol. I do like opening up options though and make converting between formats easy and somewhat seamless even though the GUI looks like it's from the 90's xD. Function over looks =)
Ford EEC-V Tuner Site
  • Immo Off, PATS, Security only currently
  • Bank Swapping
  • View VIN and other info about the bin file
PHF to BIN Converter/Viewer
Post Reply