I want to allocate array on STM32H743I_Eval using STM32CubeMx.
Is it possible to allocate stack of this size?
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
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.
Usually done within the toolchain.
Stack size and heap size are supposedly project properties, not part of the source code itself.
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 ?
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.
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. newlib-nano-1.0/sbrk.c at master · 32bitmicro/newlib-nano-1.0 · GitHub
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.
Thanks AvaTar Clive One Clive One for sharing valuable information.
I am using STM32 AC6 Workbench on window machine. I do not know about much about toolchain.
Retrieving data ...