Skip to main content
Jagadish
Associate III
September 28, 2017
Question

Creating memory region of specific size in STML0xx using scatter file and .MAP

  • September 28, 2017
  • 13 replies
  • 4727 views
Posted on September 28, 2017 at 23:31

https://community.st.com/people/DAHMEN.IMEN

‌

https://community.st.com/people/Turvey.Clive.002

‌

Hi,

I am working with STM32L053 MCU using Keil IDE. I am trying to place a header structure of an image in 4k size flash area. I am using__attribute__((at(address))) to place the structure at specific address. 8K memory space is being allocated by default. How do I control the memory size allocated to this structure?

I tried using the target settings to create a ROM2 region specifying size 0x1000. And then using _attribute__ to place the header in this region.

Target setting:

Start addSize

ROM10x80020000x4000

ROM20x80010000x1000

It throws me an error saying:

app3\app3.axf: Error: L6220E: Load region LR_IROM2 size (8192 bytes) exceeds limit (4096 bytes). Region contains 0 bytes of padding and 0 bytes of veneers (total 0 bytes of linker generated content).

app3\app3.axf: Error: L6220E: Execution region ER_IROM2 size (8192 bytes) exceeds limit (4096 bytes). Region contains 0 bytes of padding and 0 bytes of veneers (total 0 bytes of linker generated content).

app3\app3.axf: Error: L6221E: Load region LR_IROM1 with Load range [0x08002000,0x08003730) overlaps with Load region LR_IROM2 with Load range [0x08001000,0x08003000).

app3\app3.axf: Error: L6221E: Execution region ER_IROM1 with Execution range [0x08002000,0x08003728) overlaps with Execution region ER_IROM2 with Execution range [0x08001000,0x08003000).

When I check the .MAP file there is LR_IROM2 region created and it reads as follows

Load Region LR_IROM2 (Base: 0x08001000, Size: 0x00002000, Max: 0x00001000, ABSOLUTE)

Execution Region ER_IROM2 (Base: 0x08001000, Size: 0x00002000, Max: 0x00001000, ABSOLUTE)

Base Addr Size Type Attr Idx E Section Name Object

0x08001000 0x00002000 Data RO 2229 .ARM.__AT_0x08001000 main.o

How do I configure a memory region of lesser memory size?

Secondly, eventhough I create ROM2 region in Target settings, why isnt it reflected in the scatter file? When I check the scatter file it shows the following

; *************************************************************

; *** Scatter-Loading Description File generated by uVision ***

; *************************************************************

LR_IROM1 0x08002000 0x00008000 { ; load region size_region

ER_IROM1 0x08002000 0x00008000 { ; load address = execution address

*.o (RESET, +First)

*(InRoot$$Sections)

.ANY (+RO)

}

RW_IRAM1 0x20000000 0x00002000 { ; RW data

.ANY (+RW +ZI)

}

}

There is no LR_IROM2 region described here.

Please help.

Thank you,

Harsha

Note: this post was migrated and contained many threaded conversations, some content may be missing.
    This topic has been closed for replies.

    13 replies

    Jagadish
    JagadishAuthor
    Associate III
    September 28, 2017
    Posted on September 28, 2017 at 23:42

    I found out now that scatter file works when I disable Use Memory Layout from Target Dialog. 

    So to create a memory region of specific size and address, do I go ahead and follow the scatter file syntax to create sub regions(ER) inside LR_IROM1 and then use __attribute__((section('sectionname'))?Or is it recommended to use a different LR to store the image header?

    Is this the right approach?

    Thanks,

    Harsha

    Tesla DeLorean
    Guru
    September 29, 2017
    Posted on September 29, 2017 at 00:43

    Need to create a different LR, and then ER within that.

    Something like this (doing it blind)

    LR_IROM1 0x08002000 0x00008000 { ; load region size_region

    ER_IROM1 0x08002000 0x00008000 { ; load address = execution address

    .ANY (+RO)

    }

    RW_IRAM1 0x20000000 0x00002000 { ; RW data

    .ANY (+RW +ZI)

    }

    }

    LR_IROM2 0x08001000 0x00001000 { ; load region size_region

    ER_IROM2 0x08001000 0x00001000 { ; load address = execution address

    *.o (RESET, +First)

    *(InRoot$$Sections)

    }

    }
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Jagadish
    JagadishAuthor
    Associate III
    September 29, 2017
    Posted on September 29, 2017 at 01:58

    Thank you for the response

    Turvey.Clive.002

    ‌

    Didn't work the way I wanted but made little progress. I am able to create a memory region of 0x1000. But I do not see the structure being placed in this region. If I want the application( along with it's vector table) to be loaded from 0x8002000 so that when I jump from bootloader to 0x8002000, the app should start running.I want to place the header structure on top of the application starting address i.e header at 0x8001000 if starting address of image is 0x8002000. Will I be able to create memory regions for this. Because I do not want header to be in between vector table and the image entry point.

    I tried different combinations, the closest that I got was using the following settings

    header_B __attribute__((section('.ARM.__at0x8001000')))={

    ...

    ...

    };

    and have scatter file as

    ; *************************************************************

    ; *** Scatter-Loading Description File generated by uVision ***

    ; *************************************************************

    LR_IROM1 0x08002000 0x00003000 { ; load region size_region

    ER_IROM1 0x08002000 0x00003000 { ; load address = execution address

    *.o (RESET, +First)

    *(InRoot$$Sections)

    .ANY (+RO)

    }

    RW_IRAM1 0x20000000 0x00002000 { ; RW data

    .ANY (+RW +ZI)

    }

    }

    LR_IROM2 0x08001000 0x00001000 {

    ER_IROM2 0x08001000 0x00001000 { ; load address = execution address

    *(.ARM.__at0x8001000)

    }

    }

    when I check the .MAP file I see

    Load Region LR_IROM2 (Base: 0x08001000, Size: 0x00000000, Max: 0x00001000, ABSOLUTE)

    Execution Region ER_IROM2 (Base: 0x08001000, Size: 0x00000000, Max: 0x00001000, ABSOLUTE)

    **** No section assigned to this execution region ****

    So I am not adding the structure to this region right? How do I place the structure into this LR_IROM2 region? I tried __attribute__((section('name'))) which is equivalent to #pragmas but failed to place it in that region. How should I match the 'name' of section inside attribute to that in scatter file so that it gets reflected in .MAP file? I think I am going wrong in this step.

    Any suggestion or help is much appreciated.

    Thanks and regards,

    Harsha

    Jagadish
    JagadishAuthor
    Associate III
    September 29, 2017
    Posted on September 29, 2017 at 20:38

    I accidentally put the wrong screenshot of the scatter file I was trying on another keil project. I did try again to confirm and it's the same result. I am starting to wonder if I have to make any changes in Linker settings

    static const char sig[] __attribute__((section(''IROM2''))) = ''IROM2 Signature'';

    0690X00000608RiQAI.png0690X00000608RsQAI.png
    Jagadish
    JagadishAuthor
    Associate III
    September 29, 2017
    Posted on September 29, 2017 at 20:44

    Finally, 

    0690X00000608RnQAI.png

    Had to add --keep=''main.o(IROM2)'' in Options>Linker>Misc controls section

    For some reason the linker removes the section. Now I am able to see the data in IROM2.

    Tesla DeLorean
    Guru
    September 29, 2017
    Posted on September 29, 2017 at 21:37

    The linker performs dead code removal if you have no internal references to the code/data.

    ie puts(sig);

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..