portRESTORE_CONTEXT crashes on LPC2148 in Thu
Hello,
I’ve been working with FreeRTOS in ARM mode successfully for a while
but Thumb mode always crahes when portRESTORE_CONTEXT() is called
in vPortISRStartFirstTask() to start the scheduler:
portRESTORE_CONTEXT crashes on LPC2148 in Thu
I cannot see anything wrong. It is odd as I normally run in THUMB mode myself.
I think lr=0x40000a20 is a valid address.
Your compiler options look fine. Small comments would be I use -mcpu=arm7tdmi but I don’t think this is the problem as you have the -mtune option, and this does not look like a code generation problem anyway.
I have never used winarm, but this is assembly code so I don’t see how the compiler could make any difference.
What does the -DYes do?
Are you using the same linker script for ARM and THUMB compilation?
Does this problem just happen when using the debugger or all the time?
portRESTORE_CONTEXT crashes on LPC2148 in Thu
This is curious, there is nothing on that line to cause offence, provided your processor is in Supervisor mode. I recall somebody else mentioning this a while back, unless that was you?
In port.c, there is the following code:
#ifdef THUMB_INTERWORK
{
/* We want the task to start in thumb mode. */
*pxTopOfStack |= portTHUMB_MODE_BIT;
}
#endif
Can you check that this definately gets included in the build by placing a break point on the *pxTopOfStack line.
I’ve just tried on an LPC2138 and have the following status when the line "ldmia lr, {r0-lr}^" is executed:
lr = 0x40004380
pxCurrentTCB->pxTopOfStack = 0x40004378
pxCurrentTCB->pxStack = 0x400041c0
Are you using both the same startup file and the same linker script when switching between ARM and Thumb modes?
What is the value of the CPSR immediately before the execution of the line that crashes? Mine is 0x000000d3.
Regards.