The default SVC handler: vPortSVCHandler is making an exception due to lr error on the CM3/4 with armgcc.
The implementation of the vPortSVCHandler() is simplely adding a function in the main.c:
void SVC_Handler(void)
{
vPortSVCHandler();
}
When entering the SVC mode, beginning address of SVC_Handler(), the lr value is correct: 0xfffffff9. But when stepping in, after entering vPortSVCHandler, the lr will changed to the SVC_Handler() ! It is supposed to 0xffffff9 as the default SVC handler code:
" orr r14, #0xd \n"
" bx r14 \n"
So is this a compiler issue or code issue? If we add a "mov r14, #0xfffffff9 \n" before the "orr r14, #0xd \n", the code will working. But the same code works on the IAR EWARM and codesourcery.
The armgcc version is arm-none-eabi-gcc.exe (crosstool-NG 1.13.1 - Atmel build: 13) 4.6.1
“The default SVC handler: vPortSVCHandler is making an exception due to lr error on the CM3/4 with armgcc.
The implementation of the vPortSVCHandler() is simplely adding a function in the main.c:
void SVC_Handler(void)
{
vPortSVCHandler();
}”
I have no idea where you got that code from, or why you think it is the default implementation. There are lots of official examples that run on the Cortex-M cores, and none do it like that.
Where did this code come from?
“So is this a compiler issue or code issue?”
Neither. Please either install the vectors directly in the Cortex-M vector table, or map the FreeRTOS handler functions to their CMSIS names. For example, see
http://www.freertos.org/FreeRTOS_Support_Forum_Archive/January_2012/freertos_LPC1768_FreeRTOS_4964917.html
Regards.
“The code is from unzipped FreeRTOSV7.2.0.exe, \FreeRTOSV7.2.0\FreeRTOS\Source\portable\GCC\ARM_CM3\port.c, line 145. That's why i call it as a default.”
Are you saying that when you look at line 145 of that file you are seeing the code:
void SVC_Handler(void)
{
vPortSVCHandler();
}
...because when I unzip the same file and look at line 145, I see the correct code (reformatted to fit the screen):
void vPortSVCHandler( void )
{
__asm volatile (
" ldr r3, pxCurrentTCBConst2 \n"
" ldr r1, [r3] \n"
" ldr r0, [r1] \n"
" ldmia r0!, {r4-r11} \n"
" msr psp, r0 \n"
" mov r0, #0 \n"
" msr basepri, r0 \n"
" orr r14, #0xd \n"
" bx r14 \n"
" \n"
" .align 2 \n"
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
);
}
And looking in SVN, I see the same thing:
http://freertos.svn.sourceforge.net/viewvc/freertos/tags/V7.2.0/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c?revision=1773&view=markup
So I am still confused as to what you are looking at, and/or where the code you have came from?
Regards.
Sorry, the void SVC_Handler(void) is a newly added function and this is the standard exception handler for SVC. The default code meant is the later one you pointed out.
The vector table is set to the right address.
typedef struct _DeviceVectors
{
/* Stack pointer */
void* pvStack;
/* Cortex-M handlers */
void* pfnReset_Handler;
void* pfnNMI_Handler;
void* pfnHardFault_Handler;
void* pfnMemManage_Handler;
void* pfnBusFault_Handler;
void* pfnUsageFault_Handler;
void* pfnReserved1_Handler;
void* pfnReserved2_Handler;
void* pfnReserved3_Handler;
void* pfnReserved4_Handler;
void* pfnSVC_Handler;
void* pfnDebugMon_Handler;
void* pfnReserved5_Handler;
void* pfnPendSV_Handler;
void* pfnSysTick_Handler;
...
}
So you are reporting a problem in your own code ;o) If you revert your changes you should find it works fine.
Regards.