Keil Logo

Technical Support

On-Line Manuals

Compiler Getting Started Guide

Preface Getting Started Using Common Compiler Options Writing Optimized Code Assembling Assembly Code Using Assembly and Intrinsics in C or C++ Code Mapping Code and Data to the Target What the linker does to create an image What you can control with a scatter file Placing data items for target peripherals with a s Placing the stack and heap with a scatter file Root region Effect of the ABSOLUTE attribute on a root region Effect of the FIXED attribute on a root region Placing functions and data in a named section Placing functions and data at specific addresses Placing __at sections at a specific address Restrictions on placing __at sections Automatically placing __at sections Manually placing __at sections Placing a key in flash memory with an __at section Placing constants at fixed locations Placing jump tables in ROM Placing a variable at a specific address without s Placing a variable at a specific address with scat Bare-metal Position Independent Executables Placement of Arm C and C++ library code Placing code in a root region Placing Arm C library code Placing Arm C++ library code Placement of unassigned sections Default rules for placing unassigned sections Command-line options for controlling the placement Prioritizing the placement of unassigned sections Specify the maximum region size permitted for plac Examples of using placement algorithms for .ANY se Example of next_fit algorithm showing behavior of Examples of using sorting algorithms for .ANY sect Behavior when .ANY sections overflow because of li Placing veneers with a scatter file Preprocessing a scatter file Default behavior for armclang -E in a scatter file Using other preprocessors in a scatter file Reserving an empty block of memory Characteristics of a reserved empty block of memor Example of reserving an empty block of memory Aligning regions to page boundaries Aligning execution regions and input sections Overlays Embedded Software Development Building Secure and Non-secure Images Using Armv8‑ Supporting reference information

Placing a key in flash memory with an __at section

6.6.5 Placing a key in flash memory with an __at section

Some flash devices require a key to be written to an address to activate certain features. An __at section provides a simple method of writing a value to a specific address.

Placing the flash key variable in C or C++ code

Assume that a device has flash memory from 0x8000 to 0x10000 and a key is required in address 0x8000. To do this with an __at section, you must declare a variable so that the compiler can generate a section called .ARM.__at_0x8000.

// place flash_key in a section called .ARM.__at_0x8000
long flash_key __attribute__((section(".ARM.__at_0x8000")));
Manually placing a flash execution region

The following example shows how to manually place a flash execution region with a scatter file:

ER_FLASH 0x8000 0x2000
{
    *(+RW)
    *(.ARM.__at_0x8000) ; key
}

Use the linker command-line option --no_autoat to enable manual placement.

Automatically placing a flash execution region

The following example shows how to automatically place a flash execution region with a scatter file. Use the linker command-line option --autoat to enable automatic placement.

LR1 0x0
{
    ER_FLASH 0x8000 0x2000
    {
        *(+RO)                   ; other code and read-only data, the
                                 ; __at section is automatically selected
    }
    ER2 0x4000
    {
        *(+RW +ZI)               ; Any other RW and ZI variables
    }
}
Non-ConfidentialPDF file icon PDF version100748_0612_00_en
Copyright © 2016–2019 Arm Limited or its affiliates. All rights reserved. 
  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.