Split: SAMS70Q21 difference between LMA and VMA

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0



I am having a new issue that slows down the development, again.


I use SAM S70Q21 and  C/C++. The project is contains only some components yet and is a simple "GCC C++ executable" project. (Atmel Studio 7)

While developing the code (fonts, text print and draw functions), sometimes the LCD was left black, not even a backlight and a 2-color LED indicated that it's one pin is pulled up by MCU, the other is driven to low. So I checked what the code did with my pin configuration...


I use a simple array of pointers (PIO controller addresses) used by my Pin_Configure() function.


Pio* piolist[] = { PIOA, PIOB, PIOC, PIOD, PIOE, NULL, NULL, NULL };


For development, I run the code from SRAM yet, configuration is done by the given ld script, so all my constant data are present after the code (in address).

Depending on how many instructions are compiled to the code section, pointer to this array is okay or points BEFORE by 4 bytes to the real content in memory. With another words, the content is 8-byte aligned and the pointer is 4-byte aligned.


I tried to use the latest toolchain (gcc-arm-none-eabi-5.2_2015q4) but with the same result.

"const", "volatile" etc. do not have effect.

Any other preinitialized variables have the same 4-byte offset, if I add them. The .lss file shows something weird:


Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         000024dc  20400000  20400000  00008000  2**2
  1 .relocate     00000098  204024dc  204024e0  0000a4dc  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00025aa4  20402574  20402578  0000a574  2**2
  3 .stack        00000400  20428018  2042801c  0000a574  2**0
  4 .heap         00000200  20428418  2042841c  0000a574  2**0
  5 .DTCM_stack   00000400  20000000  20000000  00008000  2**0


LMA and VMA addresses differ by 4. Why is it this way?


Of course, aligning them to 8-bytes solves the problem but which one...? There is no guarantee which will be linked to be the first.

Thank You if anyone could tell me what I don't know about! Or is it a weird bug in GCC?

Last Edited: Fri. Dec 22, 2017 - 03:01 PM