XMC4700 PSRAM - 96 kb can not allocate more than 16 kb of stack

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User16409
Level 1
Level 1
Hello everybody,

I have analyzed a little and found that PSRAM is used by the flash code (so called RAM code) and by the CMSIS RTOS it loads and executes own code from the PSRAM therefore there is only 16-20 kb left.
Is there any way to allocate more stack? e.g. load RTOS to the RAM (even better to ROM)

Thanks,
madmat
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

You can modify the default linker file to fit your needs.

Regards,
Jesus
0 Likes
User16409
Level 1
Level 1
Hi Jesus,
I have made following changes to the linker_script.ld:

stack_size = DEFINED(stack_size) ? stack_size : 0x4000;

this means (I found myself) that inside ELF image stack section would become 16 kb, but when i create thread I put there 32kb stack size. In this case the loader allocates for the stack first 16 kb (little more) and it is followed by the flash (RAM code) and then coming RTOS.
In another words i have PSRAM:
PSRAM_1(!RX) : ORIGIN = 0x1FFE8000, LENGTH = 0x18000
size 96 kb, I reserve ~16kb for the stack, but inside the main thread I allocate 32 kb.
0x1FFE8000 - 0x1FFEC000 - reserved stack
0x1FFEC000 - 0x1FFExxxx - Flash loader
0x1FFExxxx - 0x1FFFFFFF - RTOS stuff

in this case it some time works when at time of stack initialization at address 0x1FFF0000 there is no important flash (RAM) code, otherwise it wont flash,
in case wen it flashes (later this code I guess is not used), and also the important parts of the RTOS were not corrupted by the stack, the application works fine, but this happens not too often
How I can modify linker script to load the RTOS somewhere else, or some another way to allocate 32kb of stack not so weird as I do now?
Thanks,
madmat
0 Likes