This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Scatter File Memory Confusion

I am using Keil uVision with an LM3S6965. I am trying to place a status string in flash on a cortex M3. I want it to be near the end of flash. I am using the following inside my program:

const char completeString[] __attribute__((at(0x3FF00))) = "stat";

And the scatter file looks like this:

LR_IROM1 0x00002000 0x0003E000 ; load region size_region
{ ER_IROM1 0x00002000 0x0003E000 ; load address = execution address { *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) }

RW_IRAM1 0x20000000 0x00010000 ; RW data { .ANY (+RW +ZI) }
}

This works, but I would like to put the status string at 0x3FFF0, but when I try to do that the linker complains that the image is too big. It seems to think that the image is only allowed to be 0x3E000, but isn't it really 0x2000 + 0x3E000 = 0x40000? The chip has 0x40000 flash.

I tried just changing the 0x3E000 to 0x40000 in the scatter file, and the location of the string to 0x3FFF0, but when I do that it builds fine, but Keil won't load the program. It says the flash times out.

What am I missing here?

  • I have tried to reproduce your error, but for me just adding the following line works like a charm.

    const char completeString[] __attribute__((at(0x00075000))) = "stat";
    

    Now I work on a an LPC1768 but it's also a cortex M3 architecture so close enough right ?

    I think you're problem is that you tried to flash from 0x2000 all the way to 0x3FF00+sizeof("stat"). And you don't realy need that. You can just flash you're application, and then the "stat" part. I don't know how big you program is but let's just says it is 20ko. Then you're scatter file could look like this

    LR_IROM1 0x00002000 0x0002500     ; load region size_region
    {
            ER_IROM1 +0 0x0002500   ; load address = execution address
            {
                    *.o (RESET, +First)
                    *(InRoot$$Sections)
                    .ANY (+RO)
            }
            RW_IRAM1 0x20000000 0x00010000   ; RW data
            {
                    .ANY (+RW +ZI)    ; initialisé à zero
            }
    }
    

    As you can see completeString won't fit in this load region, but the linker is smart, so it will create you're own cosy region just for the variable to fit in.
    Alternatively, you can explicitely create a load region and fill it with your string.

    Also, I don't get why you load your program at 0x2000, you have some kind of bootloader ?