How to modify the stack location?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to modify the stack location?

Jump to solution
1,166 Views
muis
Contributor II

I'm using the LPC11Uxx and since it has no stack-checking and my main RAM is completely full, I decided to put the stack in the USB RAM bank, to make sure its completely seperated from the heap.

I did this by creating a custom linker script, and modifying this line:

PROVIDE(_vStackTop = __top_RamUsb2 - ${STACK_OFFSET});

I hope this doesn't have any effect on performance (?), and it has always worked perfectly. But the latest LPCXpresso uses a different format for linker scripts (FreeMarker) and the conversion of my old-style template was unsuccesfull. It gives an error about the 'rodata' section, and maybe that is fixable but I really dont want to mess with custom linker scipts anymore.

So does anyone have an idea how I can modify the stack location on the LPC11U68? Preferably without using FreeMarker templates?

Labels (1)
0 Kudos
1 Solution
763 Views
lpcxpresso_supp
NXP Employee
NXP Employee

I'm not familiar enough with the internal bus architecture to comment on your first question. You will probably need to be clear on exactly what part you are using to get any answer on this too.

But with regards to the second, this is because for parts which have RAM blocks disabled by default in hardware, generally the LPCXpresso startup code will enable these - unless you turn off this portion of the startup code. Look for the block starting :

#if !defined (DONT_ENABLE_DISABLED_RAMBANKS)

The new project wizards also will generally give you the ability to stop this enabling of the disabled RAM banks if you use them to create a new project from scratch.

Regards,

LPCXpresso Support

View solution in original post

0 Kudos
3 Replies
763 Views
muis
Contributor II

Two more questions:

 - Are there any performance considerations when moving the stack to another RAM bank? I have read somewhere that the BUS access differs between parts of the memory, so that sometimes access takes more than one cycle depending on the location of the data. Or is there no impact at all?

- How is it possible that I can move the stack to RAM banks that are not powered by default? For example, I have to explicitly set the power config to enable RAM2 or USB ram, and I do this from my initalization code. So I expected them to be unusable for stack, but it seems there is no problem to boot even though during startup they shouldn't be active normally?

0 Kudos
764 Views
lpcxpresso_supp
NXP Employee
NXP Employee

I'm not familiar enough with the internal bus architecture to comment on your first question. You will probably need to be clear on exactly what part you are using to get any answer on this too.

But with regards to the second, this is because for parts which have RAM blocks disabled by default in hardware, generally the LPCXpresso startup code will enable these - unless you turn off this portion of the startup code. Look for the block starting :

#if !defined (DONT_ENABLE_DISABLED_RAMBANKS)

The new project wizards also will generally give you the ability to stop this enabling of the disabled RAM banks if you use them to create a new project from scratch.

Regards,

LPCXpresso Support

0 Kudos
763 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Simplest way to relocate the stack without modifying a linker script template would be to add the linker option:

--defsym=__user_stack_top=__top_RAM2

to MCU Linker - Miscellaneous - Other Options box in Project Properties. You can move the heap in the same way if required, as described in Heap allocation/checking in Redlib 

Note: Check the *_memory.ld" file for the correct memory bank name for your particular part (or look at the memory configuration editor).

Regards,

LPCXpresso Support

0 Kudos