Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/18/03 17:15
Read: times


 
#36745 - RE: OMF51 - Format description
I looked at the document referenced at OMF51.ZIP and it seems to contain almost everything one would ever want to know about OMF files. I am not so sure why you say this information is not very instructive.

It is certain that it is substantial work to either parse one of these type files to extract information from it or to make a program that generates this format of file.

Perhaps if you were to be a bit more specific as to what you are trying to achieve then either myself or others here could help you in more detail.

I myself work with Cygnal parts using the Keil toolset. I had a need of trying to figure out how to get certain information included into the OMF output that was computed after the compile/link step.

Specifically I need to have a checksum inserted into the FLASH image so that after a processor is programmed that it can then test its code checksum as a part of its startup process each time power is applied. I wanted to be able to have this checksum be the correct value when running the debugger so that I could both test the program code with and without the correct checksum. However the Cygnal debugger uses the OMF51 object file as its input. It was clear that it was going to be a sizable task to put the checksum into the OMF51 file using a post processing utility. So I solved the problem in this manner. I first compile the program with a small source file included that has the CODE segment variable positoned at the address where I want the checksum to be located. (In the Keil tools the address for this variable, which is an initialized declaration in C code, needs to be set via an argument to the linker at link time). The C code uses a small text include file to fetch the actual checksum value.

After the comple / link step I have a batch file that I wrote (and installed as a user tool in the IDE tools menu) which supports converting the OMF51 file first to hex format and then to binary format. The batch file then runs a small utility I wrote in MSV C++ (as a Win32 console mode application) that can read the binary image and compute the proper checksum for the program. This utility then outputs a small text file containing that checksum as value in hex ascii format. (This text file is one and the same as the include file used by the C source code).

Finally to get the proper checksum into the program I simply re-compile and link the program again.

The batch file makes use of a number of utilities. (Note that my applicaton for this was on a Cygnal part with 128K bytes of FLASH and so the whole process is somewhat complicated by the fact that my code has bankswitching in it but the same general scheme will work for non-banked code where the object size is less than 64K bytes). First is used a keil tool called OC51 that converts an OMF51 file. Next I used the keil OH51 tool to extract the images of the various bank images from the OC51 output as a series of Intel Hex files. After that is used a HEX2BIN utility to convert each hex file to a binary file. The normal HEX2BIN utility that is found at the Keil web site and other places on the WEB, chokes on running in a Win32 console mode window so I wrote an equivalent program which is my own Win32 HEX2BIN utility. The next step is to use a COPY command to join all the bank image files together into one single 128K byte binary image file. And then as a last step this image file is processed by the Win32 checksum utility that I made that outputs the checksum include file.

I am using all this on a Cygnal 'F126 processor. If anyone is interested in a ZIP file that contains the batch file and copies of all these utilities please let me know...I would be happy to share.

Michael Karas


List of 3 messages in thread
TopicAuthorDate
OMF51 - Format description            01/01/70 00:00      
RE: OMF51 - Format description            01/01/70 00:00      
RE: OMF51 - Format description            01/01/70 00:00      

Back to Subject List