PHF to HEX?

Ford information and tools can be found here
TripleFJeff
Posts: 9
Joined: Thu Apr 03, 2025 3:42 am

PHF to HEX?

Post by TripleFJeff »

Is there any "easy" way to covert a PHF to a HEX file? I have tools that can program a Ford PCM with a HEX file, but for this I only have a PHF file that came from the Ford database. Looking at the contents of the file
I can see that the information is there but not the right format.

In the PHF, the header is all there with "nul" as the line break. And if I convert PHF to BIN then to HEX I can get the HEX data, but it is missing what seems to be the addressing that is in the HEX file. This is a screenshot comparing a PHF-BIN-HEX conversion to a HEX file.
Screenshot 2025-04-05 123638.png
Is there a way to covert the PHF to a HEX of this format? Or alternately is there a tool that can program with the PHF that doesn't require a subscription like FJDS?
darkman5001
Posts: 250
Joined: Sat Dec 18, 2021 8:15 am
cars: 2005 Yukon, 2004 Suburban, 2001 Tahoe, 2002 Envoy, 2006 Envoy, 2003 Lincoln LS
Location: New Jersey, USA

Re: PHF to HEX?

Post by darkman5001 »

I am curious to know the answers to this as well...
User avatar
pman92
Posts: 577
Joined: Thu May 03, 2012 10:50 pm
Location: Castlemaine, Vic
Contact:

Re: PHF to HEX?

Post by pman92 »

If you haven't already check out the DWS bin converter:
viewtopic.php?t=8854

Bin to hex shouldn't be too difficult. If you cant find anything that does it already, a python script could do it.

Details on hex file format are on wikipedia:
https://en.m.wikipedia.org/wiki/Intel_HEX
User avatar
pman92
Posts: 577
Joined: Thu May 03, 2012 10:50 pm
Location: Castlemaine, Vic
Contact:

Re: PHF to HEX?

Post by pman92 »

For fun I asked AI.
Haven't tested it but looks like it will work.
You'll need to install intelhex library first (pip install intelhex)

Code: Select all

from intelhex import IntelHex
import sys

def bin_to_hex(bin_filename, hex_filename, start_address=0x0000):
    ih = IntelHex()
    with open(bin_filename, 'rb') as f:
        binary_data = f.read()
        ih.frombytes(binary_data, offset=start_address)
    ih.write_hex_file(hex_filename)
    print(f"Successfully converted {bin_filename} to {hex_filename}")

if __name__ == '__main__':
    if len(sys.argv) < 3:
        print("Usage: python bin2hex.py input.bin output.hex [start_address]")
        sys.exit(1)

    bin_file = sys.argv[1]
    hex_file = sys.argv[2]
    address = int(sys.argv[3], 0) if len(sys.argv) >= 4 else 0x0000

    bin_to_hex(bin_file, hex_file, address)
TripleFJeff
Posts: 9
Joined: Thu Apr 03, 2025 3:42 am

Re: PHF to HEX?

Post by TripleFJeff »

pman92 wrote: Sun Apr 06, 2025 7:43 am If you haven't already check out the DWS bin converter:
viewtopic.php?t=8854

Bin to hex shouldn't be too difficult. If you cant find anything that does it already, a python script could do it.

Details on hex file format are on wikipedia:
https://en.m.wikipedia.org/wiki/Intel_HEX
That is what I started with. I took the PHF file and used that utility to convert to BIN, then used an online utility to go from BIN to HEX. The result is what is on the left side of the screen. It doesn't have any header information, but that probably isn't necessary. But it doesn't really resemble the "real" HEX file shown on the right. The one on the left is 16 bytes. The one on the right is 32 bytes and has some sort of addresses or checksums on either side of it.
User avatar
pman92
Posts: 577
Joined: Thu May 03, 2012 10:50 pm
Location: Castlemaine, Vic
Contact:

Re: PHF to HEX?

Post by pman92 »

The intel hex format is described on Wikipedia as I linked above:
https://en.m.wikipedia.org/wiki/Intel_HEX
See the "file example"

Give that python script a go
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 »

I think we need more context to what you're trying to do. A bin file is a hex file more or less. You use a hex editor to edit a bin file as it shows the data represented as hexadecimal (16 base).

Do you have a PHF file and the equivalent Hex file as an example so I can see what exactly you're trying to do? If it's not too hard I could probably add it in my tool as an option (the DWS PHF2BIN that was linked earlier also in my sig lol).

If it's just a text file of the bin file in hex format, that's pretty easy to do, it bloats the file up a lot as say FF in the bin file is 1111 1111 however in a text file FF is 2 bytes of data (each character in a text file is 1 byte for standard ascii based character sets, other ones can be up to 4 bytes per character) so it will double the file size.

I'm wondering if you effectively just need to change .bin to .hex.

I looked at your pic a bit closer, and it looks like the green text at the end is a sort of checksum byte. It reminds me a lot of the PHF file slightly reformatted, like when I was working out how it worked I formatted it in a similar way to try to make sense of things. The actual software that uses this file format might be useful to know if it can be shared so I know what to call the format, since hex is too generic of a name to really have much weight behind it.

Anyway, from what I see in the pic and my memory (it's also 4:30am lol), it looks like the right side is a PHF file with the header/footer stripped off. 02 is like a command, same for 20 if I remember right, Going from purely memory

02 - length of data
0000 - address
04 - type - 04 is like a bank switch/chunk flag
0000 - upper address (2 bytes long from length)
FA - checksum

20 - length of data (hex so this is 32)
0000 - address (add upper address to it aka 0000 0000)
00 - type (aka data)
next 32 bytes = raw file data, same as what the left window would have
70 - checksum for the packet

Anyway, if I'm understanding this right, it should be easy to strip the header and footer off the PHF file. Look for that 02000004 hex signature and remove everything before it. There was a signature for the end as well to switch to the footer section (if there is one), you'd find that and remove everything after and I suspect that should be the format you're looking for. Upload the files and let me look and maybe a 3rd you're trying to convert and I'll take a peek at them.
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 »

02 0000 04 0000 FA
02 = byte count (always 2 for this record type)
0000 = address (not relavent for this record type)
04 = Record type. 04 specifies an extended address. Intel hex natively supports 16 bit addresses, this specifies the upper half of the address for subsequent data.
0000 = upper half of address
FA = checksum for this line


20 0000 00 <data> 70
20 = byte count
0000 = address
00 = record type (00 = data)
Then all the data bytes (0x20 of them)
70 = checksum for this line
TripleFJeff
Posts: 9
Joined: Thu Apr 03, 2025 3:42 am

Re: PHF to HEX?

Post by TripleFJeff »

Let me fill in some of the blanks.

First, I'd consider myself an "advanced user" of this stuff. I'm very familiar with engine and other module calibration, CAN, UDS, vehicle-level communication, troubleshooting, etc. Along the way I have worked for Ford, for a GM Supplier on Global B, some heavy trucks, as well as aftermarket products, mostly in the racing industry. That said, although I'm comfortable with digging into Hex and Binary for troubleshooting and making things play nice together, I'm not a programmer and I don't know python. Not to say that I couldn't learn it if I needed to, but my knowledge of it has always come from the need to make the systems work, calibrate engines, etc. I'm also not really familiar with the different file formats (PHF, BIN, HEX, etc.) but can open them in Notepad++ and poke around to try and make sense of it.

Here is what I am trying to do. I work on a lot of 2005-2010 S197 Mustangs (4.6 3V). I mostly use SCT for calibration, and Forscan for dealing with PATS and other functions. SCT tuners are locked to a VIN, and everytime you change VINs you use up an "unlock". After 5 unlocks, you have to pay to get more. I like to have spare PCMs, so to keep from having to use up unlocks everytime I want to test or switch one, I like to have them all with the same VIN. You can't change a VIN that has already been written, so you have to do a fresh reprogramming, then write the VIN and other VID info to it. Also, I sometimes need to convert hardware to a different strategy. I can do that just with the SCT programmer, but there is often a mismatch between the Equizzer software version that is in the module and what the strategy I'm using is expecting. I can get around this by changing it in the SCT file but that becomes a hassle to keep track of which Equizzer is in which module and keep separate SCT files for different modules. By doing a fresh reprogramming with a Ford tool, it also rewrites the Equizzer.

I have a older J2534 tool (Eepod MCS1, probably at least 25 years old) that works with Ford FJDS. In the past when I've needed to do this, I've bought a 2-day FJDS license to do it. I have the PHF files saved from when I've done this in the past.

I also have PTDiag, and I have some Hex files for this application that I've used via the MCS1 for programming.

What I'm trying to do is take the easily available PHF files, and convert them to a HEX file that can be used with PTDiag so I don't have to get a license to use FJDS everytime I want to reprogram one of these modules.

The file shown on the right does have a header, I just have it scrolled down so you can't see it. The PHF file has a matching header, but somewhere in the PHF-BIN-HEX conversion that gets stripped away. I don't know if the header is relevant to the programming process, but that part can be easily replicated if needed. It's the rest that I don't know what to do with.

I don't want to publicly post the HEX files I have, but I can send it to you privately to look at.
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 »

Interesting, I've never used SCT myself or really know anything about it or Equizzer, so I'll have to read up a bit about them

If I'm understanding things right, PCM Flash would probably do what you need and you alreaday have the J2534 pass through device (assuming that one is open and PCM Flash works with it). Can always download the software and test if it can Identify the computer using the correct computer type in the drop down menu. PCM Flash only does Read/Write, no editing except sometimes checksum auto correction when writing. This is at least how I'd do it and PCM Flash uses just a plain bin file, nothing special. Their licensing system is per computer type, unlimited usage.

On the file formats here's my understanding of them.

bin - raw dump of the computer, no extra meta data or anything about the file, just strictly the contents of the flash/eeprom.
phf - Ford's file format for IDS which can have header and footer details about the computer and how to write the data. Data is in "packets" with several checksums to validate the file isn't corrupt and has a special formatting
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.
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