AnsweredAssumed Answered

STM32F4 - Possible bug in compiler/linker/me? using large arrays in external ram

Question asked by Ferreira on Oct 6, 2015
Latest reply on Oct 6, 2015 by Ferreira

I recently run into a problem while using the following:

Crossworks v2.3.5.2014011021.20385 with a STM32F407ZG Cortex-M4

It goes like this:
I installed an external SRAM (AS6C4016A-45ZIN, 512KB) on the FSMC bus and configured it correctly. I know it's correctly configured because I can read and write successfully to any 8 or 16 bit register with custom functions I made. Since it's a static ram and I have a battery I even cut the power and read it in another day, everything is fine.

The problem comes with definitions like this:

int someVariable[someLength] __attribute__ ((section(".SOME_SECTION")));

If "someLength" is a small number (like 10 or 20) it's ok, it works. But if I increase the array size to, say, 1000, I get random reads and writes that are all over the place but somehow consistent, what makes me believe it is reading and writing to some register, just not the correct one. Is the compiler assuming the array length correctly? Are there any known bugs with this implementation?

Also, I just tried creating a 64 bit integer array and it does not work! I cannot correctly write to it as every single index always returns 0, no matter the size of the array, no matter how many times it is written with different values.

For reference, I declared the external RAM in the memorymap file like this:

 

<MemorySegment start="0x64000000" name="RAM_EXTERNA" size="0x80000" access="Read/Write"/>

Declared the corresponding section in the flash_placement.xml:

 

<MemorySegment name="RAM_EXTERNA">
<
ProgramSection alignment="2" load="Yes" name=".SRAM_SENSORES"/>
</MemorySegment>

And declared an array like this:

 

static int16_t sensores_ultimaLeitura[500] __attribute__ ((section(".SRAM_SENSORES")));

Outcomes