2.6. Generating PROM Programming Files

By default, the executable file is in Common Object File Format (COFF). Using the object code utility program erc-coff-objcopy, COFF files may be converted into several other industry-standard formats, such as ELF, Intel Hex, and Motorola S Records.

The following example shows how we convert an COFF file to Intel Hex format.

Example 2-6. Converting to Intel Hex

$ erc-coff-objcopy --output-target=ihex hello hello.ihex
$ 

If you don't need the COFF file, then you can get the linker to generate the Intel Hex file directly.

Example 2-7. Generating Intel Hex

$ erc-coff-gcc hello.c -o hello.ihex -oformat=ihex
$ more hello.ihex
:020000040200F8
:1000000010800280010000000100000001000000DB
:10001000A14800002900800381C52260A610201D90
:10002000A14800002900800381C52260A610201B82
:10003000A14800002900800381C52260A610201B72
:10004000A14800002900800381C52260A610201B62
:10005000A14800002900800381C5208CA61020053E
:10006000A14800002900800381C520E8A6102006D1
:10007000A14800002900800381C52260A610201D30
:10008000A14800002900800381C52204A610200099
...lots of output...
$ 

We can run the Intel Hex file, as in the following example:

Example 2-8. Running an Intel Hex FIle

$ erc-coff-run hello.ihex
Hello world
$

Or we can generate Motorola S Records, and run from there.

Example 2-9. Recompiling and Running with S-Records

$ erc-coff-gcc hello.c -o hello.sre -oformat=srec
$ more hello.sre
S00C000068656C6C6F2E73726567
S3150200000010800280010000000100000001000000D3
S31502000010A14800002900800381C52260A610201D88
S31502000020A14800002900800381C52260A610201B7A
S31502000030A14800002900800381C52260A610201B6A
S31502000040A14800002900800381C52260A610201B5A
S31502000050A14800002900800381C5208CA610200536
...lots of output...
$ erc-coff-run hello.sre
Hello world
$