AnsweredAssumed Answered

RAM segments merging

Question asked by Maksim Salau on Jul 31, 2018
Latest reply on Aug 2, 2018 by Erich Styger



S32K14x devices have 2 RAM regions named SRAM_U and SRAM_L. They are arranged in continuous manner. E.g.: S32K142 has the following RAM regions: 1FFF_C000 to 1FFF_FFFF and 2000_0000 to 2000_2FFF.

The linker scripts shipped with an SDK has separate memory segments for them:

/* Specify the memory areas */
  /* SRAM_L */
  m_data                (RW)  : ORIGIN = 0x1FFFC000, LENGTH = 0x00004000

  /* SRAM_U */
  m_data_2              (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00003000


m_data is used to store code that should be in RAM, .data and interrupt vectors.

m_data_2 is used to store .customSection, .bss, heap and stack.


Since there is no gap between the sections, it feels natural to me to merge them into a single segment.


/* Specify the memory areas */
  /* SRAM_L + SRAM_U */
  m_data                (RW)  : ORIGIN = 0x1FFFC000, LENGTH = 0x00007000


This will make easier to manage big arrays, since you will have single RAM segment.


Are there any undesired consequences?

The only undesired consequence I can imagine of is unaligned access on the edge.


*(int32_t *)0x1FFFFFFF = 42;

But such reads/writes should be avoided in any case.


Thanks and regards,