Blame | Last modification | View Log | Download | RSS feed
.TH p2hex 1.SH NAME.B p2hex \- convert code files into hex files.SH SYNTAX.B p2hex[ option(s) ] <name(s)> [ further options/names ].SH DESCRIPTIONP2HEX is a tool to convert the contents of one or several code filesgenerated by AS into HEX files. A HEX file is a common method ofrepresenting binary data in a way that is human-readable andtransferrable over non-transparent data lines. Generally spoken,each byte of code or data is represented by two characters that showthe byte in its hexadecimal notation. A HEX file also containsadditional information like addresses and checksums that easeprocessing of the data. Unfortunately, there is no generallyaccepted standard format for HEX files. Instead, every processormanufacturer developed his own format and some of them have become"industry standards". P2HEX supports all formats that seem to havegained acceptance, with some variations that are commonplace.Arguments to P2HEX may be either command line parameters or file namespecifications. Any argument that starts with the charactes +, - or/ is regarded as a comand line parameter (which may take anadditional command line argument); any other argument is regarded asa file name. Generally, P2HEX needs at least two file names: Aninput code file and the name of the HEX output file. If multiplefile names are given, P2HEX will always take the last name as theoutput file's name. If an input file name does not have anextension, the extension '.p' is added automatically. Similarly, theextension '.hex' is added automatically to the target file's name.A special case occurs when only one file name is given: P2HEX willthen take its name as the source (possibly extended with '.p'), andthe same name as target (with '.hex' as additional or replacedextension).By default, P2HEX will choose a HEX format that is the most commonfor the processor family a source file contains code for; thishowever means that if the source file(s) contain(s) code for differentprocessor families, the HEX file might become an undesirable mixtureof formats; use the.B -Fcommand-line parameter to force a certain format then..SH COMMAND-LINE PARAMETERSIf a command-line parameter starts with a slash(/) or minus sign(-),it turns an option on; if a command-line parameter starts with a plussign(+), it turns a specific option off. Numeric arguments toparameters can be either written in decimal or hexadecimal notation.For hexadecimal notation, prefix the number with a dollar($) sign.In the following list, all options will be shown in the form that isneeded to change the default behaviour, which might be a plus orminus sign, depening on wether the option is on or off by default..B p2hexaccepts the following command-line parameters:.TP.B -aTell P2HEX to use relative addressing in the output HEX file. Bydefault, addresses the HEX file will be exactly the same absoluteaddresses as they were in the code file. This may create problemswith some EPROM-burners if your code does not start at address 0. Inrelative mode, the address filter's start address (see the.B -rcommand line switch) is subtracted from all addresses specificationsin the HEX file (with the exception of the entry address).Therefore, addresses in the HEX file again start at 0..TP.B -d < <start address>-<stop address> >Tell P2HEX that items in the address range given by the argumentshould be regarded as data rather than code. This option only has ameaning for the TI-DSK format that can differenciate between code anddata. This option is principally obsolete since P2HEX can now directlyprocess data from the DATA segment. It should not be used in new projects,since it may be removed in the near future..TP.B -e <address>Set an entry address or modify an existing one. Some HEX fileformats can carry a special record for an entry address that tells aprogram loader where to jump after a program has been loaded.Normally, this address is generated by AS if the program's ENDstatement has a label as argument, but this options allows to changethe entry point or add one if it was forgotten in the program itself..TP.B -F <Default|Moto|Intel|Intel16|Intel32|MOS|Tek|DSK|C>Force a certain format for the output HEX file. By default, P2HEXwill choose one depending on the target processor. Using.B Defaultas argument will also set this behaviour, which might be useful torevert to P2HEX's default behaviour if the default has been changed(see the discussion of the.B P2HEXCMDvariable below for presetting parameters)..B Motostands for the Motorola S-Record format, which allows addresses from16 to 32 bits in length and entry addresses. It bears its name dueto the fact that every record starts with the letter S..B Intelis the "standard" Intellec-MCS8-Format for a variety of Intel8-Bit-CPUs that almost became a standard, but was originally limitedto 16-bit addresses. In later editions, the addressing capabilitywas extended to 20 (.B Intel16) and 32 bits (.B Intel32)..B MOSis a simple format introduced by the manufacturer MOS for their lineof 65xx CPUs. It is limited to 16-bit addresses, just like the.B Tekformat that was defined by Tektronix..B DSKis the format Texas Instruments uses for their line of 16-bitfixed-point signal processors. In contrast to all other formats, itis word-oriented and can distinguish between data and code segments..B Atmelis the simple Hex format defined by Atmel for the AVR RISC family..TP.B -f <number>[,<further numbers>]Add <number> to the list of record header IDs that allow a recordfrom a source file to be written to the target file. A certainheader ID marks code for a certain target processor family; thus,this filter allows to distill code for a certain processor out of asource file that contains code for different processor families.Negation of this parameter removes certain header IDs from P2HEX'slist. See the user manual of AS for a list of all possible header IDvalues. If P2HEX's list of header IDs is empty, no filtering willtake place, i.e. all records from a source file will make it into thetarget file..TP.B -i <0|1|2>Change the terminating line for an Intel-HEX file. Normally, anIntel-HEX file is terminated with the line.B :00000001FF ,but there are sources that also mention.B :00000001or.B :0000000000as the last line. The numeric argument of this parameter selects oneof these opportunities, with the first one being the default. Thisparameter only has an effect if the target file's format is one ofthe Intel-HEX variants..TP.B -l <length>Set the maximum number of bytes per record, and therefore the maximumlength of a line in the target file. Possible values are between 2and 254 bytes, with 16 being the default..TP.B -m <0..3>Set one of the four Intel-Hex variants defined by Microchip for thePIC family of microcontrollers. The Default is the INHX8(0) format,which contains all words in a Lobyte-Hibyte-ordering. INHX16M(1) does justthe opposite, whereas INHX8L(2) and INHX8H(3) only store the lowerresp. higher bytes of each word. This parameter only has an effectif the target file's format is one of the Intel-HEX variants..TP.B -r < <start>-<stop> >Set a certain address range to be filtered out of the input file(s).Code that lies outside this range does not appear in the output file.As a special option,.B <start>and.B <stop>may consist of just a single dollar sign (escape thisin UNIX shells!) or 0x to signify the lowest resp. highest address thatoccurs in the input file(s). This is also the default. Using thisoption will implicitly enable a second pass over all input files to findthe minimum and maximum values before conversion starts, reducing thespeed of P2HEX slightly..TP.B -R <offset>Relocate all addresses from the source file by adding the given offset..TP.B -sIn Motorola S-Record format, force P2HEX to write a termination recordafter each group of data records, which may be necessary in some cases(but creates problems most of the time...).TP.B +5Disable output of Motorola S5-records, which contain the number ofdata records that were sent and therefore allow an additional levelof checking. However, they are not understood by all programs andtherefore might be a source of trouble..TP.B -M <1|2|3>Force P2HEX to use a minimum length for the address fields of MotorolaS-records. For example, a value of 2 will effectively disable S1 records,and a value of 3 will force usage of S3 records. The default is 1, whichenables full automatic setting of the S record length..TP.B -avrlen <2|3>Set the address field length of Atmel AVR Hex files to either two or threebytes (the latter is the default)..TP.B -kInstruct P2HEX to erase the program source files after conversion..TP.B -avrlen <2|3>Set the width of the address field used for the Atmel hex file format.By default, 3-byte addresses will be used..TP.B -segment <CODE|DATA|....>Select the address space hex data is created from. By default, only recordsfor the CODE segment (plus DATA for TI DSK) will be considered. Use thisoption with different arguments if the source file contains data from otheraddress spaces. This way, multiple HEX files (one per address space) canbe produced..TP.B -cformat <string>If C-style output is selected, this option allows to influence its structure.See the manual for details on this format string..TP.B -q or -quietEnable quiet operation mode, suppressing copyright and purely informativemessages. Only errors will be displayed..SH PRESETTING PARAMETERSParameters need not neccessarily be given in the command line itself. Beforeprocessing of command line parameters starts, P2HEX will look if the.B P2HEXCMDenvironment variable is defined. If it exists, its contents will betreated as additional command line paramters whose syntax is absolutelyequal to normal command line parameters. As exception is made if thevariable's contents start with a '@' sign; in such a case, the string afterthe '@' sign is treated as the name of a file that contains the options.Such a file (also called a 'key file') has the advantage that it allowsthe options to be written in different lines, and it does not have a sizelimit. Some operating systems (like MS-DOS) do have a length limit oncommand lines and environment variable contents, so the key file may beyour only option if you have a lot of lengthy parameters for P2HEX..SH RETURN CODES.B p2hexmay return with the following codes:.TP.B 0no errors..TP.B 1incorrect command line parameters..TP.B 2I/O-error..TP.B 3An input file had an incorrect format..SH EXAMPLESTo convert a file.B file1.pfully into its HEX representation on a Unix platform, use.PP.B p2hex -r \e$-\e$ file1.PPIf you additionally want to force usage of the Motorola S-Record format, use.PP.B p2hex -r \e$-\e$ -F Moto file1.PP.SH NATIONAL LANGUAGE SUPPORTp2hex supports national languages in the same way as AS. See the manualpage for asl(1) for more information about this..SH TIPSCalling P2HEX without any arguments will print a short helplisting all command line parameters..SH SEE ALSOasl(1), plist(1), pbind(1), p2bin(1).SH HISTORYP2HEX originally appeared as an AS tool in 1992, written inBorland-Pascal, and was ported to C and UNIX in 1996..SH BUGSCommand line interpreters of some operating systems reserve somecharacters for their own use, so it might be necessary to givecommand line parameters with certain tricks (e.g., with the helpof escape characters).P2HEX does not have so far an opportunity to filter records bytarget segment. Instead, records that contain data for any othersegment than CODE are completely ignored..SH AUTHOR(S)Alfred Arnold (alfred@ccac.rwth-aachen.de)