ARM Technical Support Knowledge Articles

CREATING DATA-ONLY HEX FILES

Answer


Information in this article applies to:


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 uVision2.
  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

Article last edited on: 2009-02-03 10:31:10

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential