2017-12-01 04:51 AM
Hi All,
I want to allocate array[2000][160] on STM32H743I_Eval using STM32CubeMx.
Is it possible to allocate stack of this size?
Regards,
Manish
2017-12-01 08:41 AM
And what type is this?
Probably inadvisable, why do you need to do this as a local/auto variable? Could you use the heap? Preferable not to have the Stack on external memory. The stack or heap can be the entirety of the available memory if you want to do that.
In Keil Heap and Stack sizes are set in startup_stm32xyz.s
2018-04-17 01:45 AM
Thanks Clive.
Variable is 'char' type. Though, I could have chosen heap but i want to know that
1. How can we increase our stack size if there is need to do it ?
2. How can we segregate and allocate size to 'stack' , 'heap' etc. Basically, How can
we design our own memory layout in linker script file.
Regards,
Manish
2018-04-17 02:30 AM
Usually done within the toolchain.
Stack size and heap size are supposedly project properties, not part of the source code itself.
2018-04-17 06:58 AM
Let me put in other way.
Lets say that I choose D1 SRAM ( Address: 0x24000000, Length=512K) in my linker script then how will i
segregate stack, heap , bss and data sections so that i can be sure that from where my stack starts & ends or from where
my heap starts & ends etc.
Lets say that I choose D1 SRAM ( Address: 0x24000000, Length=512K) and choose _estack = 0x24080000( length 512k).
Now, if complete system is using 256K ( = stack + heap ) then does it mean that i can allocate rest of the 256K to my 'local stacked array' or
can malloc(256K) size of the memory ?
2018-04-17 07:48 AM
The default way of most toolchains I know is to put the stack at the top of a RAM block, i.e. TOS is the last RAM address.
The heap is put below the stack, depending on it's size.
Variables are allocated from the start of the RAM segment on.
When setting a stack size as project property, the toolchain will calculate addresses accordingly.
There is rarely any need to change this mechanism (and manually fiddle with sizes and addresses).
Not sure what your undisclosed toolchain is, and how it allocates the H7 RAM blocks.
My toolchains does not even support the H7xx yet.
... does it mean that i can allocate rest of the 256K to my 'local stacked array' or can malloc(256K) size of the memory ?
You might reconsider your algorithms and memory usage strategy.
The all-at-once method is good for machines with MMU and virtual memory, and rarely for microcontrollers.
You will have to implement malloc() yourself (or the crucial part of it),and thus need to plan your memory usage in a static fashion anyway.
2018-04-17 08:01 AM
Not clear what toolchain you're using.
GNU tools typically have you define the top of stack in the linker script, and heap allocator uses the space between the bottom of the stack and the top of the statics for the heap. You might have to modify the allocator to suit your specific needs.
https://github.com/32bitmicro/newlib-nano-1.0/blob/master/libgloss/tic6x/sbrk.c
As I said in the original response Keil defines the stack and heap size in the startup.s file, you can define the section of memory to be used, and you can describe the sections/placement in the scatter file.
2018-04-17 09:41 AM
Thanks
meyer.frank
Turvey.Clive.002
Turvey.Clive
for sharing valuable information.I am using STM32 AC6 Workbench on window machine. I do not know about much about toolchain.
Regards,
Manish