I’m digging px4esc-v1_default source on stmf446re nucleo board.
In final part of stm32_start.c, there is STACK_COLORATION part before os_start(). (I don’t know what is stack coloration.)
#ifdef CONFIG_STACK_COLORATION
/* Set the IDLE stack to the coloration value and jump into os_start() */
go_os_start((FAR void *)&_ebss, CONFIG_IDLETHREAD_STACKSIZE);
#else
/* Call os_start() */
os_start();
It always fails in go_os_start(). Program goes 0xfffffffe when I debug.
In defconfig file, CONFIG_STACK_COLORATION = y, and CONFIG_IDLETHREAD_STACKSIZE = 4096
I tried to change CONFIG_IDLETHREAD_STACKSIZE = 500 referencing the value in pixracer, but it also fails.
In go_os_start() function, there is assembly code which I don’t know.
static void go_os_start(void *pv, unsigned int nbytes)
{
/* Set the IDLE stack to the stack coloration value then jump to
* os_start(). We take extreme care here because were currently
* executing on this stack.
*
* We want to avoid sneak stack access generated by the compiler.
*/
__asm__ __volatile__
(
"\tmovs r1, r1, lsr #2\n" /* R1 = nwords = nbytes >> 2 */
"\tbeq 2f\n" /* (should not happen) */
"\tbic r0, r0, #3\n" /* R0 = Aligned stackptr */
"\tmovw r2, #0xbeef\n" /* R2 = STACK_COLOR = 0xdeadbeef */
"\tmovt r2, #0xdead\n"
"1:\n" /* Top of the loop */
"\tsub r1, r1, #1\n" /* R1 nwords-- */
"\tcmp r1, #0\n" /* Check (nwords == 0) */
"\tstr r2, [r0], #4\n" /* Save stack color word, increment stackptr */
"\tbne 1b\n" /* Bottom of the loop */
"2:\n"
"\tmov r14, #0\n" /* LR = return address (none) */
"\tb os_start\n" /* Branch to os_start */
);
}
I have two questioions.
1. CONFIG_STACK_COLORATION=y setting is necessary?
2. How can I find proper CONFIG_IDLETHREAD_STACKSIZE value?
Thank you.