1

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?

Graeme
  • 2,971
  • 21
  • 26

1 Answers1

2

You can place it at the explicit address like this:

uint32_t in_ram2 __attribute__((section(".ARM.__at_0x20000000")));
strange-corner
  • 404
  • 4
  • 13
  • Thanks, but I was already aware of this. Unfortunately there are some implications to using it. If the linker trys to place other variables at the same location (unfortunately it currently isn't smart enough not to), it will give an error, so it is best used to place outside of a configured region. Also, if you want to place multiple variables you need to be careful how you choose the addresses to avoid conflicts - something that's usually best left to the linker. – Graeme Oct 11 '21 at 17:53