Keil Logo

ARMLINK: Fill Unused Flash Content With Predefined Value


Information in this support solution applies to:

  • Keil MDK

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 (FLASH_BASE + FLASH_SIZE) 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.

    An example scatter file, demonstrating the solution, is the following:

    LR_IROM1 0x08000000 0x00010000  {    ; load region size_region
      ER_IROM1 0x08000000 0x00010000  {  ; load address = execution address
       *.o (RESET, +First)
       *(InRoot$$Sections)
       .ANY (+RO)
       .ANY (+XO)
      }
      RW_IRAM1 0x20000000 0x00020000  {  ; RW data
       .ANY (+RW +ZI)
      }
      END_OF_BLOCK (0x08010000) FIXED EMPTY 0x0 {}
    }
    

Please note, if you fill-up the full flash size with a specific value the output file size will be increased. Downloading to flash will take longer, depending on the amount of flash space.

MORE INFORMATION

Last Reviewed: Monday, February 15, 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.