I'm wanting to create a code image with the layout:
1 - Startup/Bootstrap 2 - Executable code 3 - (probable gap) 4 - Fixed location dispatch table 5 - (probably gap) 6 - Fixed location tables 7 - (probable gap) 8 - Fixed location text
I've got the scatter file doing all of this - Except for one thing.
The initial RW and ZI Load regions always occur following the image - And are copied/decompressed to their required location during the scatter load.
The documentation suggests that this is where it is always placed, but I don't really want it there.
Is there any way to force the linker to place these initial RW and ZI load regions at a specific location?
Because I want it contained somewhere within the image.
The start of the image is the bootstrap.
The end of the image is the fixed location text.
I need the image to be of a fixed/pre-determined size.
Historically, our releases have had copyright text and other useful information at the end of the image. This has proven to be very useful for us (for example, when scanning a collection of images on a PC) and I would like to maintain that pattern.
You should be able to do it using a .sct file with multiple load regions. In the linker options, make certain "use memory layout dialog" is unchecked and supply a section file something like:
LR_1 0x04008000 0x00010000 { ER_ROM +0 { *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } } LR_2 0x04002000 0x00006000 { ER_RAM +0 { .ANY (+RW +ZI) } }
This places a load region at 0x04008000 containing the read-only sections and another at 0x04002000 containing the RW and ZI sections.
In this example, they're configured to execute in place; those are convenient RAM locations for my current project. I've not tried building one that moves the execution regions somewhere else, but what do you want for a quick hack?
Unfortunately, that doesn't do what I want.
The initial data (i.e., what would normally be compressed and copied by the scatter loader) that would go into the RAM is copied from an area in the ROM section. This section is the one I want to locate.
I can find no name for it, no entry in the map file, nothing. The documentation says it is automatically created, but there seems no way to explicitly locate it.
My example only executes in place because I can't test it otherwise. The key section is this:
LR_2 0x04002000 0x00006000 { ER_RAM +0 { .ANY (+RW +ZI) } }
which creates a second load region at a specific address to hold RW and ZI data.
It should be possible to configure this section to put the data anywhere you want during execution using something like:
LR_2 0x04002000 0x00006000 { ER_RAM ***address-goes-here*** { .ANY (+RW +ZI) } }
but I can't test it.
The chunk of the linker manual you'll want to look at is "Images with a complex memory map", which can be found under "About scatter-loading" in the "Using Scatter-loading Description Files" section.
Sorry, but I don't think your understanding what I am saying.
I know how to locate the RW and ZI sections - It is quite straightforward.
But ... The initialised data within the RW section is copied to there by the scatter loader (just prior to entry of 'main') and it is the section that I want to locate.