Search code examples
ideembeddedpicmicrochipmplab

How can I make MPLAB import a HEX file with comments or import a HEX file specified on a commandline?


I'm working with the CCS c compiler which produces its object files in the Intel 32 bit HEX format, aka INHX32. This compiler has a directive which causes it to put comments in these files. The comment lines are at the beginning of the file, and begin with a semicolon, like so:

;  This is a comment
:020000040000FA
:1000000007EF33F0000C000C056ED8CF06F0E0CF00
:1000100007F00001E9CF0DF0EACF08F0E1CF09F0D9

I'd like to use this directive, as the comments would be extremely useful to those who later import the hex files into MPLAB. However, MPLAB will not import files with comments. When I try, I get an "Invalid file format, information not available" error.

I realize these comment lines are not part of the original Intel spec, but some other compilers and development tools accept them. Is there any way to make MPLAB do so?

I could write a script that would strip these lines out and then pass the resulting file to MPLAB, but as far as I can tell MPLAB can't import a file via the commandline.


Solution

  • It turns out MPLAB definitely doesn't do imports (or much else) from the commandline. So I wrote an AutoIt script to strip the comments, and save the rest in a temporary file. Then it imports that file into MPLAB by controlling MPLAB's GUI.

    This is actually better than getting MPLAB to import the file directly, since my script displays the comments in a dialog so there is no need for the user to open the file in an editor to read them.