Keil Logo

BL51: CREATING DATA-ONLY HEX FILES


Information in this article applies to:

  • C51 Version 6.20
  • µVision2 Version 2.20

QUESTION

I want to create a program that is comprised of only constant data. I need to locate the data starting at 7800h. I don't have any code and don't want any included from the library. Is this possible?

ANSWER

Yes.

  1. Create the C data file. For example:
    struct NV_stuff
      {
      int a1;
      int a2;
      int a3;
      int a4;
      };
    
    const struct NV_stuff code NV_tab =
      {
      1, 2, 3, 4
      };
    
  2. Add the NODEFAULTLIBRARY linker directive so that the linker doesn't include any modules from the standard C library. You may add this in the Misc Controls box under the BL51 Misc Tab in the Project Options Dialog in µVision2.
  3. On the Output Tab in the Project Options, make sure that the Create HEX File checkbox is checked.
  4. Compile and link the program. You will receive the following warnings from the linker:
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?CO?TEST
    
    *** WARNING L10: CANNOT DETERMINE ROOT SEGMENT
    

    It is safe to ignore these.

  5. Open the MAP (*.m51) file created by the linker. Look at the link Map for the segment name.
    LINK MAP OF MODULE:  test (TEST)
    
    
                TYPE    BASE      LENGTH    RELOCATION   SEGMENT NAME
                -----------------------------------------------------
    
                * * * * * * *   C O D E   M E M O R Y   * * * * * * *
                CODE    0000H     0008H     UNIT         ?CO?TEST
    

    In this case, it is ?CO?TEST. ?CO? for constant data and TEST for the name of the C file.

  6. On the BL51 Locate Tab in the Project Options Dialog, enter ?CO?TEST(0x7800) in the CODE Space input line. This command instructs the linker to locate the ?CO?TEST segment starting at address 7800h.
  7. Re-compile and link the project. The resulting HEX file appears as follows:
    :08780000000100020003000476
    :00000001FF
    

MORE INFORMATION

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Tuesday, February 3, 2009


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.