2016-11-02 04:58 PM
I'm using a STM32F411 with an audiocodec driven by I2S stream.
I'm runing out of RAM, so I'm trying to move OutputBuffer (the buffer that I use to create sound and used ond HAL_I2SEx_TransmitReceive_DMA). This buffer is 9600 x 4 (uint32_t) = 38Kbyte. But, I'm not sure why creating several const OutputBuffer's end on RAM overflow. I get this message: c:/ac6/systemworkbench/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.7.0.201602121829/tools/compiler/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: final_15_DP_TE_ConstStimuli.elf section `.bss' will not fit in region `RAM' c:/ac6/systemworkbench/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.7.0.201602121829/tools/compiler/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 336136 bytes Why making a big const table end on a RAM overflow? Thank2016-11-02 05:16 PM
I'm missing something
If I write: float32_t const tblStimuli_01[9600]; the I get arm-none-eabi-objcopy -O binary ''final_15_DP_TE_ConstStimuli.elf'' ''final_15_DP_TE_ConstStimuli.bin'' arm-none-eabi-size ''final_15_DP_TE_ConstStimuli.elf'' text data bss dec hex filename 307212 2244 119376 428832 68b20 final_15_DP_TE_ConstStimuli.elf but if I write: float32_t const tblStimuli_01[9600] = {0}; then I get: arm-none-eabi-size ''final_15_DP_TE_ConstStimuli.elf'' text data bss dec hex filename 345612 2244 80976 428832 68b20 final_15_DP_TE_ConstStimuli.elf I will have my stimuli table full of data in my implementation. But, now, I have doubt about it. Will I save RAM changing OutputBuffer from global variable to global const variable? Thank2016-11-02 05:33 PM
I don't see enough of the code, or the .MAP to be able to determine anything
To keep an array of constants in flash, use static const static const float32_t tblStimuli_01[9600] = { ... };2016-11-02 05:46 PM
Thank clive.
The thing is the difference between this: float32_t const tblStimuli_01[9600] = {0}; and this: float32_t const tblStimuli_01[9600]; In the first case, tblStiumli_01 will end in FLASH. But in the second case tblStimuli_01 will end in RAM (I get an error for RAM overflow). Doing this: float32_t static const tblStimuli_01[9600]; tblStiumli_01 will end in RAM (I get an error for RAM overflow) Thnak2016-11-02 07:23 PM
How many of these buffers are you allocating?
You could pretend the device has a lot of RAM (tweak .ld file), and look at the .MAP file to see all the symbols.2016-11-03 03:34 AM
Try to understand the difference between
float32_t const tblStimuli_01[] and const float32_t tblStimuli_01[] I am quite sure that tha latter will land in FLASH!2016-11-03 05:49 AM
IMHO correct.
It does matter where the 'const
' qualifier appears in the declaration ...2016-11-03 09:46 AM
The bigger issue here is having a truck load of buffers in RAM holding ''constants''
With strings that are defined there is at least an opportunity to fold them.Someone needs to look critically about why all these buffers are needed, and which can reasonably be consolidated or shared.The linker/compiler are just trying to accommodate the expectations the source defines, if that's not getting the results you want, you need to redefine those expectations and provide the level of clarity required.2016-11-03 04:36 PM
My application is working. I have a lot of code. Now I'm working on save some RAM.
My application use audio stream, I generate a pure tone and send it to AUDIO CODEC and at the same time the codec gives me the MIC reading and I store it on an InputBuffer. Those buffer are int32_t and has a lenght of 9600 points. I'm thinking on remove OutputBuffer from RAM and pass it to FLASH. OutputBuffer is the sound that I need to put on the loudspeaker and I have 5 of them. So I can change 1 OutputBuffer from RAM making 5 OutputBuffers on FLASH (each of them with the sound I need). So, I was testing how to do that. If I write const float32_t tblStimuli_01[5][9600]; OR float32_t const tblStimuli_01[5][9600]; then I get an error from the linker about RAM overflow. If I write float32_t const tblStimuli_01[5][9600] = {0}; OR const float32_t tblStimuli_01[5][9600] = {0}; I get an error from the linker about FLASH overflow. The thing here is not why am I overflowing the RAM or the FLASH, I know that I'm, trying to store more data than my RAM/FLASH space. The thing is that if I don't explicitly initialize the array, then it will goes to RAM. I need to explicitly initialize the constant array to make it goes to FLASH. I'm wondering why...2016-11-04 01:53 AM
>... I generate a pure tone and send it to AUDIO CODEC ...
> ... > ... then I get an error from the linker about RAM overflow. > ... > ... I get an error from the linker about FLASH overflow. Perhaps because RAM/Flash are actually overflowing ? Try to replace storage size with algorithm (''ingenuity'' - this is the root of the word ''engineer''). For a pure tone, you don't need to store a full wave period - a sine period has ''two symmetries'', i.e. a table with 1/4 period would suffice to generate a tone without any loss of accuracy. You can reduce resolution to the required minimum. You can produce this data algorithmically in real-time, instead of tabulation.