Ram Area for stack

cancel
Showing results for 
Search instead for 
Did you mean: 

Ram Area for stack

1,911 Views
kensu
Contributor V

Dears

I am using 1857 and MCUExpresso, I run the freeRtos sample project,

When I add more task, I find the app crash when I run.

I guess the crash cause is the stack not enough, because of the following test:

I calculate my total stack is about 36K. It's bigger than RAMLoc32,

I switch the RamLoc40 to the first Ram Area.

The app can run successfully.

At first, I thought the compiler will allocate all stack automatically with all RAMLoc32,  RAMLoc40, RAMAHB32, RAMAHB40 since the project had add these RAM.

Should I do special process for using other RAM area if my stack is not enough, not automatically by compiler?

(I saw some discussion about using other RAM for stack.)

Thanks

Ken

0 Kudos
7 Replies

484 Views
lpcxpresso_supp
NXP Employee
NXP Employee

You can't merge those RAM blocks - they aren't contiguous. But you could locate your stack into the 40KB block instead of the 32KB block by changing the "Heap and Stack Placement" dialog in the Linker Settings.

Regards,

MCUXpresso IDE Support

0 Kudos

484 Views
kensu
Contributor V

Hi

Thanks, I understood now.

The internal ram can not merge, so if my application stack is more than heap total size,

I need to allocate some some application memory to other internal SRAM.

Thanks

Ken

0 Kudos

484 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Sorry - I'm not sure what you are asking. You need to explain in more detail what you want to do.

But there is lot of information in the MCUXpresso IDE v10.0.0 User Guide, Chapter 12: "Memory Configuration and Linker Scripts" on controlling the layout of your image and its use of memory.

Regards,

MCUXpresso IDE Support

0 Kudos

484 Views
kensu
Contributor V

Hi,

Sorry I write too short.

I am using LPC1857JET256 with MCUXpresso, I run the freertos sample code, and I add 9 task,

each task is using 4K stack, so total stack is more than 36K (RamLoc32), so the application seems crash.

pastedImage_1.png

So I follow the guild of MCUXpresso user guild, I add second ram with the linker setting.

pastedImage_3.png

I want to confirm firstly, 

Is my setting correct? (If I want to add second ram to stack use.)

RamLoc32 + RamLoc40 should be 72K size, but my application still have problem when I keep to add the tasks.

For example:

I add a task which do nothing, my purpose is to test the stack size. When I add a task, other task function is not correct.

And I decrease all task stack size, the task function work fine again.

So I think there are still something wrong with the stack size setting.

Could you check my setting is correct?

Thanks

Ken

0 Kudos

484 Views
lpcxpresso_supp
NXP Employee
NXP Employee

MCUXpresso IDE offers two modes of stack placement - LPCXpresso style and MCUXpresso style. For an LPC18xx project, your project is likely to be configured by default to LPCXpresso style.

But in either case, the stack is always by default placed at the end of the RAM region listed first in the memory configuration editor (and the application data and heap are placed at the start of the first RAM region). But this is completely configurable.

The easiest way to move the stack is probably to switch to using MCUXpresso style heap/stack placement and use the table provided in the Managed Linker Script page of the Project Properties to chage the RAM region your stack is placed into....

MCUX_SettingsmanagedLS1.jpg

For more information, please read the MCUXpresso IDE v10.0.0 User Guide, in particular section 12.9: "More advanced heap/stack placement".

Regards,

MCUXpresso IDE Support

0 Kudos

484 Views
kensu
Contributor V

Dears

I want to confirm again. for 3'rd, 4'rd RAM that I want to use.

Should I just add it into link setting? Same as the second RAM I want to use,

Ken

0 Kudos

484 Views
kensu
Contributor V

Hi

Thanks you for fast reply, I follow the step, and my problem is solved. "It is so easy".

Actually, I am not totally understand the setting of stack/heap, I will keep to study it.

Thanks

Ken

0 Kudos