cancel
Showing results for 
Search instead for 
Did you mean: 

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

Jagadish
Associate II
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.
13 REPLIES 13
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.

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
Up vote any posts that you find helpful, it shows what's working..
Posted on September 29, 2017 at 22:16

Yes you are right. I had not made any references. Thank you Clive for your assistance.

Now I can create memory region and allocate the section in scatter file. 

But I am still stuck trying to place the header in IROM2.

0690X00000608RxQAI.png

this is my scatter file and the size of header is only 0x90. And I have specified 0x1000 as the max size. Why is the linker allocating 8kB of data?

ERROR displayed:

linking...

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,0x08003740) overlaps with Load region LR_IROM2 with Load range [0x08001000,0x08003000).

app3\app3.axf: Error: L6221E: Execution region ER_IROM1 with Execution range [0x08002000,0x08003738) overlaps with Execution region ER_IROM2 with Execution range [0x08001000,0x08003000).
Posted on September 29, 2017 at 22:58

Look, I have no idea how larger your header structure actually is, or what's in it. The linker seems to suggest its much larger, or you've consumed more space with other things getting dumped in there. You also seems to have inconsistent sizes for LR_IROM1 and ER_IROM1, and all your code/data headed for IROM1 needs to fit in 8KB which strikes me as rather tight.

You could perhaps drop the .ANY(+RO)

Hard to debug via a key-hole, and screen shots.

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