This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MCU-PLUS-SDK-AM263X: Stack used in NoRTOS in bootloader

Part Number: MCU-PLUS-SDK-AM263X

hi Team,

Looks like in AM263x MCU+ SDK NoRTOS largely uses SVC stack for ISR in NoRTOS mode.
When a ISR is hit it starts in IRQ mode and therefore IRQ stack but then the IRQ handler switches to SVC mode therefore switching to SVC stack as well 

However the example linker.cmd file in examples/drivers/boot/sbl_uart/am263x-cc/r5fss0-0_nortos/ti-arm-clang/linker.cmd is setup wrong.

__IRQ_STACK_SIZE = 4096;
__FIQ_STACK_SIZE = 256;
__SVC_STACK_SIZE = 256;
__ABORT_STACK_SIZE = 256;
__UNDEFINED_STACK_SIZE = 256;

We should use more stack space for SVC and less for IRQ.
You will see issues if multiple interrupts are enabled in the bootloader, where in there is stack overflow and corruption/crash.

The hello world nortos application setups the stack sizes correctly.

I could be wrong in my understanding, but please check and fix if needed, also check comments and documentation for the same.

e.g
examples/hello_world/am263x-cc/r5fss0-0_nortos/ti-arm-clang/linker.cmd

Below comment can be improved to make it more clear which stack is used by ISR in NoRTOS mode
/* This is the size of stack when R5 is in IRQ mode
* In NORTOS,
* - Here interrupt nesting is enabled
* - This is the stack used by ISRs registered as type IRQ
* In FreeRTOS,
* - Here interrupt nesting is enabled
* - This is stack that is used initally when a IRQ is received
* - But then the mode is switched to SVC mode and SVC stack is used for all user ISR callbacks
* - Hence in FreeRTOS, IRQ stack size is less and SVC stack size is more
*/
I am using mcu_plus_sdk_am263x_08_06_00_34

thanks and regards
Kedar