cancel
Showing results for 
Search instead for 
Did you mean: 

Allocate Big Stack Size on STM32H743I_Eval Using STM32CubeMX

Manish Sharma
Associate III
Posted on December 01, 2017 at 13:51

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

7 REPLIES 7
Posted on December 01, 2017 at 17:41

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 17, 2018 at 08:45

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

Posted on April 17, 2018 at 09:30

Usually done within the toolchain.

Stack size and heap size are supposedly project properties, not part of the source code itself.

Posted on April 17, 2018 at 13:58

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 ?

Posted on April 17, 2018 at 14:48

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.

Posted on April 17, 2018 at 15:01

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 17, 2018 at 16:41

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