Keil™, An ARM® Company

Technical Support

ARMLINK: FILL UNUSED FLASH CONTENT WITH PREDEFINED VALUE


Information in this support solution applies to:

  • MDK-ARM V3.x (Full Version only)
  • µVision V3.x

QUESTION

How do I fill up unused flash content with a specific value?

ANSWER

The following steps are required:

  • Add the following linker switch to Project -> Options for target -> Linker -> Misc Controls:
    --pad=VALUE
    
    Where VALUE is an integer, which can be given in hexadecimal format. If value is greater than 0xFF, then the padding byte is set to (char)value.
  • Create an dummy section in your scatter file with the used flash size:
    END_OF_BLOCK (END_ADR - START_ADR) FIXED EMPTY 0x0 {}
    
    The scatter file can be found in your output directory with the output file name and the extension .sct e.g. Blinky.sct. To enable scatter file usage uncheck Project -> Options for target -> Linker -> Use Memory Layout from Target Dialog and specify the scatter file below in the same dialog.

Optional

  • Use fromelf to create a HEX or BIN file by adding the following command line to Project -> Options for target -> User - Run User Programs After Build/Rebuild:
    • To create a BIN file use:
      C:\Keil\ARM\BIN31\fromelf.exe --bin "#L.axf" -o "$P\output.bin"
      
    • To create HEX file (Intel) use:
      C:\Keil\ARM\BIN31\fromelf.exe --i32 "#L.axf" -o "$P\output.hex"
      
    • To create a HEX file (Motorola) use:
      C:\Keil\ARM\BIN31\fromelf.exe --m32 "#L.axf" -o "$P\output.hex"
      

The output file generated by fromelf will contain value in all areas where no code exists. You can verify this with a text editor for the HEX file or with an editor which can display hex content (e.g. UltraEdit) for the BIN file. In the simulation you can verify the flash content via the memory or disassembly window.

Please Note

If you fill up the full flash size with a specific value the BIN/HEX file size will be increased. Downloading to flash will take longer and depend on the amount of flash space.

MORE INFORMATION

Last Reviewed: Wednesday, April 30, 2008


Did this article provide the answer you needed?
 
Yes
No
Not Sure