Hi,
I am trying to bring up CPU1 on ARM v7 architecture (assume CPU0 already bring up & set c-environment)
using below code, but it hitting with error: "stack smashing detected"
ldr sp, =cpu1_stack
b start_task2
* cpu1_stack define here :
int new_stack[1024]__attribute__ ((aligned(16)))
I used PSCI framework to switch to cpu1
Please share some pointers/inputs whats going wrong here.
Thanks all, appricieate quick help really helpful was able to bring cpu1.
Consider also that the ARM ABI defines a "full descending stack" so the stack pointer should be initialized to the top (limit) of the stack region.
However, if Peter happens to see this, I'm quite sure he would be able to give a more helpful answer
No pressure
To get the current CPU ID you'll need to use some assembler to access the System Control co-processor. You don't say what CPU you are using, but assuming some form of ARMv7A CortexA core you'll need to look at the bottom two bits of the Multiprocessor Affinity Register.
For ARM-v7 32-bit code see: ARM Information Center
For ARMv8 64-bit code see: ARM Information Center
HTH, Pete
Though this is not really my field, I think you'd have to check which CPU is currently executing the code.
Eg. If I had 4 CPUs, I'd create 4 stacks and set SP = stack[currentCPU];
I think the page, which peterharris is referring to, will help you find the currently running CPU.
Please know that I'm not an expert on the Cortex-A; so there's a good chance I'm wrong.
However, if Peter happens to see this, I'm quite sure he would be able to give a more helpful answer.
Its global allocation & declaration in C file.
I can allocate it in BSS section but how to assign it to particular CPU ?
Might be that the second CPU is already running; which is why you get the 'stack smashing detected' error ?
...is that a global or local allocation ?
Perhaps it's better to allocate the stack in your assembly-source (in the BSS section) instead of allocating it in your C-source ?
View all questions in Cortex-A / A-Profile forum