Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1126 | savelij | 1 | .TH p2hex 1 |
| 2 | |||
| 3 | .SH NAME |
||
| 4 | .B p2hex \- convert code files into hex files |
||
| 5 | |||
| 6 | .SH SYNTAX |
||
| 7 | .B p2hex |
||
| 8 | [ option(s) ] <name(s)> [ further options/names ] |
||
| 9 | |||
| 10 | .SH DESCRIPTION |
||
| 11 | |||
| 12 | P2HEX is a tool to convert the contents of one or several code files |
||
| 13 | generated by AS into HEX files. A HEX file is a common method of |
||
| 14 | representing binary data in a way that is human-readable and |
||
| 15 | transferrable over non-transparent data lines. Generally spoken, |
||
| 16 | each byte of code or data is represented by two characters that show |
||
| 17 | the byte in its hexadecimal notation. A HEX file also contains |
||
| 18 | additional information like addresses and checksums that ease |
||
| 19 | processing of the data. Unfortunately, there is no generally |
||
| 20 | accepted standard format for HEX files. Instead, every processor |
||
| 21 | manufacturer developed his own format and some of them have become |
||
| 22 | "industry standards". P2HEX supports all formats that seem to have |
||
| 23 | gained acceptance, with some variations that are commonplace. |
||
| 24 | |||
| 25 | Arguments to P2HEX may be either command line parameters or file name |
||
| 26 | specifications. Any argument that starts with the charactes +, - or |
||
| 27 | / is regarded as a comand line parameter (which may take an |
||
| 28 | additional command line argument); any other argument is regarded as |
||
| 29 | a file name. Generally, P2HEX needs at least two file names: An |
||
| 30 | input code file and the name of the HEX output file. If multiple |
||
| 31 | file names are given, P2HEX will always take the last name as the |
||
| 32 | output file's name. If an input file name does not have an |
||
| 33 | extension, the extension '.p' is added automatically. Similarly, the |
||
| 34 | extension '.hex' is added automatically to the target file's name. |
||
| 35 | A special case occurs when only one file name is given: P2HEX will |
||
| 36 | then take its name as the source (possibly extended with '.p'), and |
||
| 37 | the same name as target (with '.hex' as additional or replaced |
||
| 38 | extension). |
||
| 39 | |||
| 40 | By default, P2HEX will choose a HEX format that is the most common |
||
| 41 | for the processor family a source file contains code for; this |
||
| 42 | however means that if the source file(s) contain(s) code for different |
||
| 43 | processor families, the HEX file might become an undesirable mixture |
||
| 44 | of formats; use the |
||
| 45 | .B -F |
||
| 46 | command-line parameter to force a certain format then. |
||
| 47 | |||
| 48 | .SH COMMAND-LINE PARAMETERS |
||
| 49 | |||
| 50 | If a command-line parameter starts with a slash(/) or minus sign(-), |
||
| 51 | it turns an option on; if a command-line parameter starts with a plus |
||
| 52 | sign(+), it turns a specific option off. Numeric arguments to |
||
| 53 | parameters can be either written in decimal or hexadecimal notation. |
||
| 54 | For hexadecimal notation, prefix the number with a dollar($) sign. |
||
| 55 | In the following list, all options will be shown in the form that is |
||
| 56 | needed to change the default behaviour, which might be a plus or |
||
| 57 | minus sign, depening on wether the option is on or off by default. |
||
| 58 | |||
| 59 | .B p2hex |
||
| 60 | accepts the following command-line parameters: |
||
| 61 | .TP |
||
| 62 | .B -a |
||
| 63 | |||
| 64 | Tell P2HEX to use relative addressing in the output HEX file. By |
||
| 65 | default, addresses the HEX file will be exactly the same absolute |
||
| 66 | addresses as they were in the code file. This may create problems |
||
| 67 | with some EPROM-burners if your code does not start at address 0. In |
||
| 68 | relative mode, the address filter's start address (see the |
||
| 69 | .B -r |
||
| 70 | command line switch) is subtracted from all addresses specifications |
||
| 71 | in the HEX file (with the exception of the entry address). |
||
| 72 | Therefore, addresses in the HEX file again start at 0. |
||
| 73 | .TP |
||
| 74 | .B -d < <start address>-<stop address> > |
||
| 75 | Tell P2HEX that items in the address range given by the argument |
||
| 76 | should be regarded as data rather than code. This option only has a |
||
| 77 | meaning for the TI-DSK format that can differenciate between code and |
||
| 78 | data. This option is principally obsolete since P2HEX can now directly |
||
| 79 | process data from the DATA segment. It should not be used in new projects, |
||
| 80 | since it may be removed in the near future. |
||
| 81 | .TP |
||
| 82 | .B -e <address> |
||
| 83 | |||
| 84 | Set an entry address or modify an existing one. Some HEX file |
||
| 85 | formats can carry a special record for an entry address that tells a |
||
| 86 | program loader where to jump after a program has been loaded. |
||
| 87 | Normally, this address is generated by AS if the program's END |
||
| 88 | statement has a label as argument, but this options allows to change |
||
| 89 | the entry point or add one if it was forgotten in the program itself. |
||
| 90 | .TP |
||
| 91 | .B -F <Default|Moto|Intel|Intel16|Intel32|MOS|Tek|DSK|C> |
||
| 92 | |||
| 93 | Force a certain format for the output HEX file. By default, P2HEX |
||
| 94 | will choose one depending on the target processor. Using |
||
| 95 | .B Default |
||
| 96 | as argument will also set this behaviour, which might be useful to |
||
| 97 | revert to P2HEX's default behaviour if the default has been changed |
||
| 98 | (see the discussion of the |
||
| 99 | .B P2HEXCMD |
||
| 100 | variable below for presetting parameters). |
||
| 101 | |||
| 102 | .B Moto |
||
| 103 | stands for the Motorola S-Record format, which allows addresses from |
||
| 104 | 16 to 32 bits in length and entry addresses. It bears its name due |
||
| 105 | to the fact that every record starts with the letter S. |
||
| 106 | |||
| 107 | .B Intel |
||
| 108 | is the "standard" Intellec-MCS8-Format for a variety of Intel |
||
| 109 | 8-Bit-CPUs that almost became a standard, but was originally limited |
||
| 110 | to 16-bit addresses. In later editions, the addressing capability |
||
| 111 | was extended to 20 ( |
||
| 112 | .B Intel16 |
||
| 113 | ) and 32 bits ( |
||
| 114 | .B Intel32 |
||
| 115 | ). |
||
| 116 | |||
| 117 | .B MOS |
||
| 118 | is a simple format introduced by the manufacturer MOS for their line |
||
| 119 | of 65xx CPUs. It is limited to 16-bit addresses, just like the |
||
| 120 | .B Tek |
||
| 121 | format that was defined by Tektronix. |
||
| 122 | |||
| 123 | .B DSK |
||
| 124 | is the format Texas Instruments uses for their line of 16-bit |
||
| 125 | fixed-point signal processors. In contrast to all other formats, it |
||
| 126 | is word-oriented and can distinguish between data and code segments. |
||
| 127 | .B Atmel |
||
| 128 | is the simple Hex format defined by Atmel for the AVR RISC family. |
||
| 129 | .TP |
||
| 130 | .B -f <number>[,<further numbers>] |
||
| 131 | |||
| 132 | Add <number> to the list of record header IDs that allow a record |
||
| 133 | from a source file to be written to the target file. A certain |
||
| 134 | header ID marks code for a certain target processor family; thus, |
||
| 135 | this filter allows to distill code for a certain processor out of a |
||
| 136 | source file that contains code for different processor families. |
||
| 137 | Negation of this parameter removes certain header IDs from P2HEX's |
||
| 138 | list. See the user manual of AS for a list of all possible header ID |
||
| 139 | values. If P2HEX's list of header IDs is empty, no filtering will |
||
| 140 | take place, i.e. all records from a source file will make it into the |
||
| 141 | target file. |
||
| 142 | .TP |
||
| 143 | .B -i <0|1|2> |
||
| 144 | |||
| 145 | Change the terminating line for an Intel-HEX file. Normally, an |
||
| 146 | Intel-HEX file is terminated with the line |
||
| 147 | .B :00000001FF , |
||
| 148 | but there are sources that also mention |
||
| 149 | .B :00000001 |
||
| 150 | or |
||
| 151 | .B :0000000000 |
||
| 152 | as the last line. The numeric argument of this parameter selects one |
||
| 153 | of these opportunities, with the first one being the default. This |
||
| 154 | parameter only has an effect if the target file's format is one of |
||
| 155 | the Intel-HEX variants. |
||
| 156 | .TP |
||
| 157 | .B -l <length> |
||
| 158 | |||
| 159 | Set the maximum number of bytes per record, and therefore the maximum |
||
| 160 | length of a line in the target file. Possible values are between 2 |
||
| 161 | and 254 bytes, with 16 being the default. |
||
| 162 | .TP |
||
| 163 | .B -m <0..3> |
||
| 164 | |||
| 165 | Set one of the four Intel-Hex variants defined by Microchip for the |
||
| 166 | PIC family of microcontrollers. The Default is the INHX8(0) format, |
||
| 167 | which contains all words in a Lobyte-Hibyte-ordering. INHX16M(1) does just |
||
| 168 | the opposite, whereas INHX8L(2) and INHX8H(3) only store the lower |
||
| 169 | resp. higher bytes of each word. This parameter only has an effect |
||
| 170 | if the target file's format is one of the Intel-HEX variants. |
||
| 171 | .TP |
||
| 172 | .B -r < <start>-<stop> > |
||
| 173 | |||
| 174 | Set a certain address range to be filtered out of the input file(s). |
||
| 175 | Code that lies outside this range does not appear in the output file. |
||
| 176 | As a special option, |
||
| 177 | .B <start> |
||
| 178 | and |
||
| 179 | .B <stop> |
||
| 180 | may consist of just a single dollar sign (escape this |
||
| 181 | in UNIX shells!) or 0x to signify the lowest resp. highest address that |
||
| 182 | occurs in the input file(s). This is also the default. Using this |
||
| 183 | option will implicitly enable a second pass over all input files to find |
||
| 184 | the minimum and maximum values before conversion starts, reducing the |
||
| 185 | speed of P2HEX slightly. |
||
| 186 | .TP |
||
| 187 | .B -R <offset> |
||
| 188 | |||
| 189 | Relocate all addresses from the source file by adding the given offset. |
||
| 190 | .TP |
||
| 191 | .B -s |
||
| 192 | |||
| 193 | In Motorola S-Record format, force P2HEX to write a termination record |
||
| 194 | after each group of data records, which may be necessary in some cases |
||
| 195 | (but creates problems most of the time...) |
||
| 196 | .TP |
||
| 197 | .B +5 |
||
| 198 | |||
| 199 | Disable output of Motorola S5-records, which contain the number of |
||
| 200 | data records that were sent and therefore allow an additional level |
||
| 201 | of checking. However, they are not understood by all programs and |
||
| 202 | therefore might be a source of trouble. |
||
| 203 | .TP |
||
| 204 | .B -M <1|2|3> |
||
| 205 | |||
| 206 | Force P2HEX to use a minimum length for the address fields of Motorola |
||
| 207 | S-records. For example, a value of 2 will effectively disable S1 records, |
||
| 208 | and a value of 3 will force usage of S3 records. The default is 1, which |
||
| 209 | enables full automatic setting of the S record length. |
||
| 210 | .TP |
||
| 211 | .B -avrlen <2|3> |
||
| 212 | |||
| 213 | Set the address field length of Atmel AVR Hex files to either two or three |
||
| 214 | bytes (the latter is the default). |
||
| 215 | .TP |
||
| 216 | .B -k |
||
| 217 | |||
| 218 | Instruct P2HEX to erase the program source files after conversion. |
||
| 219 | .TP |
||
| 220 | .B -avrlen <2|3> |
||
| 221 | |||
| 222 | Set the width of the address field used for the Atmel hex file format. |
||
| 223 | By default, 3-byte addresses will be used. |
||
| 224 | .TP |
||
| 225 | .B -segment <CODE|DATA|....> |
||
| 226 | |||
| 227 | Select the address space hex data is created from. By default, only records |
||
| 228 | for the CODE segment (plus DATA for TI DSK) will be considered. Use this |
||
| 229 | option with different arguments if the source file contains data from other |
||
| 230 | address spaces. This way, multiple HEX files (one per address space) can |
||
| 231 | be produced. |
||
| 232 | .TP |
||
| 233 | .B -cformat <string> |
||
| 234 | If C-style output is selected, this option allows to influence its structure. |
||
| 235 | See the manual for details on this format string. |
||
| 236 | .TP |
||
| 237 | .B -q or -quiet |
||
| 238 | |||
| 239 | Enable quiet operation mode, suppressing copyright and purely informative |
||
| 240 | messages. Only errors will be displayed. |
||
| 241 | |||
| 242 | .SH PRESETTING PARAMETERS |
||
| 243 | |||
| 244 | Parameters need not neccessarily be given in the command line itself. Before |
||
| 245 | processing of command line parameters starts, P2HEX will look if the |
||
| 246 | .B P2HEXCMD |
||
| 247 | environment variable is defined. If it exists, its contents will be |
||
| 248 | treated as additional command line paramters whose syntax is absolutely |
||
| 249 | equal to normal command line parameters. As exception is made if the |
||
| 250 | variable's contents start with a '@' sign; in such a case, the string after |
||
| 251 | the '@' sign is treated as the name of a file that contains the options. |
||
| 252 | Such a file (also called a 'key file') has the advantage that it allows |
||
| 253 | the options to be written in different lines, and it does not have a size |
||
| 254 | limit. Some operating systems (like MS-DOS) do have a length limit on |
||
| 255 | command lines and environment variable contents, so the key file may be |
||
| 256 | your only option if you have a lot of lengthy parameters for P2HEX. |
||
| 257 | |||
| 258 | .SH RETURN CODES |
||
| 259 | |||
| 260 | .B p2hex |
||
| 261 | may return with the following codes: |
||
| 262 | .TP |
||
| 263 | .B 0 |
||
| 264 | no errors. |
||
| 265 | .TP |
||
| 266 | .B 1 |
||
| 267 | incorrect command line parameters. |
||
| 268 | .TP |
||
| 269 | .B 2 |
||
| 270 | I/O-error. |
||
| 271 | .TP |
||
| 272 | .B 3 |
||
| 273 | An input file had an incorrect format. |
||
| 274 | |||
| 275 | .SH EXAMPLES |
||
| 276 | |||
| 277 | To convert a file |
||
| 278 | .B file1.p |
||
| 279 | fully into its HEX representation on a Unix platform, use |
||
| 280 | .PP |
||
| 281 | .B p2hex -r \e$-\e$ file1 |
||
| 282 | .PP |
||
| 283 | If you additionally want to force usage of the Motorola S-Record format, use |
||
| 284 | .PP |
||
| 285 | .B p2hex -r \e$-\e$ -F Moto file1 |
||
| 286 | .PP |
||
| 287 | |||
| 288 | .SH NATIONAL LANGUAGE SUPPORT |
||
| 289 | |||
| 290 | p2hex supports national languages in the same way as AS. See the manual |
||
| 291 | page for asl(1) for more information about this. |
||
| 292 | |||
| 293 | .SH TIPS |
||
| 294 | |||
| 295 | Calling P2HEX without any arguments will print a short help |
||
| 296 | listing all command line parameters. |
||
| 297 | |||
| 298 | .SH SEE ALSO |
||
| 299 | |||
| 300 | asl(1), plist(1), pbind(1), p2bin(1) |
||
| 301 | |||
| 302 | .SH HISTORY |
||
| 303 | |||
| 304 | P2HEX originally appeared as an AS tool in 1992, written in |
||
| 305 | Borland-Pascal, and was ported to C and UNIX in 1996. |
||
| 306 | |||
| 307 | .SH BUGS |
||
| 308 | |||
| 309 | Command line interpreters of some operating systems reserve some |
||
| 310 | characters for their own use, so it might be necessary to give |
||
| 311 | command line parameters with certain tricks (e.g., with the help |
||
| 312 | of escape characters). |
||
| 313 | |||
| 314 | P2HEX does not have so far an opportunity to filter records by |
||
| 315 | target segment. Instead, records that contain data for any other |
||
| 316 | segment than CODE are completely ignored. |
||
| 317 | |||
| 318 | .SH AUTHOR(S) |
||
| 319 | |||
| 320 | Alfred Arnold (alfred@ccac.rwth-aachen.de) |
||
| 321 |