Keil Logo

LX51: Generating Hex Files for Banked Applications


Information in this article applies to:

  • C51 Version 7 and later

QUESTION

I have a code banking application that was created using the BL51 Linker. Now, I am porting the program to use the new extended LX51 Linker. The HEX conversion what was done by OC51 and OH51 in the past generated a single HEX file for each code bank. How can we do that with the OHX51 HEX converter?

ANSWER

By default, OHX51 generates a single HEX file that contains all code banks. OHX51 can be used to generate a HEX file or files that will support virtually all hardware schemes. Following are several examples:

64K Code Bank with Common Area Repeated in Each Bank

Hardware examples for this scheme is provided in the LX51 User's Guide, Banking with Four 64KB Banks and Banking with XDATA Port.

For the OHX51 Options, you must specify the HEX-386 File Format (selected in µVision under Options - Output - HEX Format: HEX-386). This causes OHX51 to generate an Intel HEX-386 File which is configured as follows:

  • 0x000000-0x00FFFF: Common Area + Code Bank 0
  • 0x010000-0x01FFFF: Common Area + Code Bank 1
  • 0x020000-0x02FFFF: Common Area + Code Bank 2
  • 0x030000-0x03FFFF: Common Area + Code Bank 3
  • And so on.

You may use this type of file with most device programmers.

32K Common Area Plus Multiple 32K Code Banks

A hardware example for this scheme is provided in the Lx51 User's Guide, under Banking with Common Area.

For the OHX51 Options, you must specify the HEX-386 File Format and the MERGE32K directives (selected in µVision under Options - Output - HEX Format: HEX-386 and MERGE32K). This causes OHX51 to generate an Intel HEX-386 File which is configured as follows:

  • 0x000000-0x007FFF: Common Area
  • 0x008000-0x00FFFF: Code Bank 1
  • 0x010000-0x017FFF: Code Bank 2
  • 0x018000-0x01FFFF: Code Bank 3
  • And so on.

You may use this type of file with most device programmers.

Note that Code Bank 0 may not be used with the MERGE32K option because Bank 0 doesn't exist anymore. At this point any file assigned to Bank 0 would not have code in the generated hexfile.

For more information, refer to the Generating HEX Files for Banked Applications in the See Also section.

Individual HEX File for Each Code Bank

If you require a single HEX file for each code bank, you must create a batch program that runs OHX51 once for each code bank. The contents of the batch file will be similar to:

OHX51 my_program RANGE (B0:0 - B0:0xFFFF) HEXFILE (my_program.H00)
OHX51 my_program RANGE (B1:0 - B1:0xFFFF) HEXFILE (my_program.H01) OFFSET (-0x10000)
OHX51 my_program RANGE (B2:0 - B2:0xFFFF) HEXFILE (my_program.H02) OFFSET (-0x20000)

This effectively generates the same output files as the BL51 Linker using the OC51 and OH51 utilities.

Note: OHX51 versions from 1.43 - 1.45 (= PK51 9.51 - 9.56) do not support negative offset values. Update to version 1.46 or higher (PK51 9.57 or higher) if you want to use a negative offset or use tools like srec_cat.exe (see links below) to move a hex file to a different address range.

MORE INFORMATION

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.