Can I place a variable inside a memory region using Keil/armclang/armlink?

1k views Asked by At

I have a linker scatter file generated by Keil that looks something like this:

LR_IROM1 0x08020000 0x001E0000  {
  ER_IROM1 0x08020000 0x001E0000  {
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20020000 0x00060000  {
   .ANY (+RW +ZI)
  }
  RW_IRAM2 0x20000000 0x00020000  {
   .ANY (+RW +ZI)
  }
}

Ideally I would like to continue using an IDE configured scatter file for various reasons. However, I don't see any way to have Keil add additional linker sections.

Naively, I thought I could place a variable in the RW_IRAM2 region using something like:

uint32_t in_ram2 __attribute__((section("RW_IRAM2")));

I also tried things like ".RW_IRAM2" and "".RW_IRAM2.bss", however the variable always ends up in the IRAM1 region. After looking at the documentation, I don't see any way to do this without ditching the scatter file configured/created by Keil. Am I missing something here?

1

There are 1 answers

1
strange-corner On

You can place it at the explicit address like this:

uint32_t in_ram2 __attribute__((section(".ARM.__at_0x20000000")));