You copied the Doc URL to your clipboard.

Placing data items for target peripherals with a scatter file

To access the peripherals on your target, you must locate the data items that access them at the addresses of those peripherals.

To make sure that the data items are placed at the correct address for the peripherals, use the __attribute__((section(".ARM.__at_address"))) variable attribute together with a scatter file.


  1. Create peripheral.c to place the my_peripheral variable at address 0x10000000.
    #include "stdio.h"
    int my_peripheral __attribute__((section(".ARM.__at_0x10000000"))) = 0;
    int main(void)
        return 0;
  2. Create the scatter file scatter.scat.
    LR_1 0x040000          ; load region starts at 0x40000   
    {                      ; start of execution region descriptions      
        ER_RO 0x040000     ; load address = execution address
            *(+RO +RW)     ; all RO sections (must include section with 
                           ; initial entry point)
        ; rest of scatter-loading description
        ARM_LIB_STACK 0x40000 EMPTY -0x20000  ; Stack region growing down
        { }
        ARM_LIB_HEAP 0x28000000 EMPTY 0x80000 ; Heap region growing up
        { }
    LR_2 0x01000000
        ER_ZI +0 UNINIT
    LR_3 0x10000000
        ER_PERIPHERAL 0x10000000 UNINIT
  3. Build the image.
    armclang --target=arm-arm-eabi-none -mcpu=cortex-a9 peripheral.c -g -c -o peripheral.o
    armlink --cpu=cortex-a9 --scatter=scatter.scat --map --symbols peripheral.o --output=peripheral.axf > map.txt
    The memory map for load region LR_3 is:
      Load Region LR_3 (Base: 0x10000000, Size: 0x00000004, Max: 0xffffffff, ABSOLUTE)
        Execution Region ER_PERIPHERAL (Base: 0x10000000, Size: 0x00000004, Max: 0xffffffff, ABSOLUTE, UNINIT)
        Base Addr    Size         Type   Attr      Idx    E Section Name        Object
        0x10000000   0x00000004   Data   RW            5    .ARM.__at_0x10000000  peripheral.o
Was this page helpful? Yes No