Gcc STM32上具有FreeRTOS的任务开关出现硬故障
我正在将我的应用程序从Tiva TM4C123gh6pm(Cortex-M4)移动到STM32F446(也是Cortex-M4) 我对这两个应用程序都使用了一个通用的初始化例程,它在基本应用程序中运行良好Gcc STM32上具有FreeRTOS的任务开关出现硬故障,gcc,stm32,freertos,Gcc,Stm32,Freertos,我正在将我的应用程序从Tiva TM4C123gh6pm(Cortex-M4)移动到STM32F446(也是Cortex-M4) 我对这两个应用程序都使用了一个通用的初始化例程,它在基本应用程序中运行良好 __attribute__(( naked )) void ResetISR(void) { /* * This function is already started in Thread mode. * First the Control register will be set to
__attribute__(( naked ))
void ResetISR(void)
{
/*
* This function is already started in Thread mode.
* First the Control register will be set to use
* the process stack.
*
* For more details about stacks, see page 2-2 of the DUI0553A
* and page 74 of the Data Sheet.
*/
/*
* Stack for the Thread Mode is selected by the ASP flag
* of the Control register.
*
* For more details about the register, see
* pp. 2-9 - 2.10 of the DUI0553A and
* pp. 88 - 89 of the Data Sheet.
*/
__asm volatile(" MRS r0, control "); /* r0 = control */
__asm volatile(" ORR r0, r0, #0x00000002 "); /* r0 |= 2 */
__asm volatile(" MSR control, r0 "); /* control = r0 */
__asm volatile(" ISB "); /* wait until synced */
/*
* After the Thread Mode stack has been set,
* its stack pointer must be set.
*/
__asm volatile(" LDR r1, =_psp "); /* r1 = &_psp */
__asm volatile(" LDR r0, [r1] "); /* r0 = *r1 */
__asm volatile(" MOV sp, r0 "); /* sp = r0 */
__asm volatile(" ISB ");
/*
* Then initialize the BSS section.
* Note that the BSS section may include the stack,
* in this case initialization would also overwrite
* local variables (in the stack), so the implementation
* in C would probably not execute correctly. For this
* reason, this task must be implemented in assembler.
*/
__asm volatile(" LDR r0, =_bss "); /* r0 = &_bss */
__asm volatile(" LDR r1, =_ebss "); /* r1 = &_ebss */
__asm volatile(" MOV r2, #0 "); /* r2 = 0 */
__asm volatile(" .thumb_func ");
__asm volatile("bss_zero_loop: ");
__asm volatile(" CMP r0, r1 "); /* if (r0<r1) */
__asm volatile(" IT lt "); /* { */
__asm volatile(" STRLT r2, [r0], #4 "); /* *(r0++) = r2 */
__asm volatile(" BLT bss_zero_loop "); /* goto bss_zero_loop } */
/*
* Most likely the compiler will be able to
* copy data initializers without pushing
* these local variables to stack.
*/
uint32_t* src;
uint32_t* dest;
/*
* Copy the data segment initializers from flash to SRAM.
*/
src = &_etext;
for( dest = &_data; dest < &_edata; )
{
*dest++ = *src++;
}
_init();
main();
}
(这是在延迟之后)
我对两者使用相同的编译器选项
CFLAGS += -mlittle-endian -mcpu=cortex-m4 -march=armv7e-m -mthumb
CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
TI和ST的CM4之间是否存在一些我不知道的细微差异
我还尝试为STM32F446核子编译一个不同的FreeRTOS项目,一位同事成功创建了该项目并与Keil一起运行。
它与我的arm none eabi gcc(15:4.9.3+SVN27297-1)4.9.3 20150529(预发布)
配置一起崩溃
(我以前使用过gcc 4.8.4,结果也一样,我升级了,希望它能解决这个问题)注意下页的粗体红色文本,它突出显示了STM32部件所需的额外步骤: 如果这就是问题所在,那么定义configASSERT()将为您解决:
2015-11-30 18:59:11,722 - INFO # starting scheduler
2015-11-30 18:59:11,722 - INFO # starting blinky
2015-11-30 18:59:16,654 - INFO # --|Hard Fault|--
2015-11-30 18:59:16,660 - INFO # r0: 0 r12: a5a5a5a5
2015-11-30 18:59:16,661 - INFO # r1: 20000fe4 lr: 8002263
2015-11-30 18:59:16,665 - INFO # r2: 10000000 pc: 80020de
2015-11-30 18:59:16,672 - INFO # r3: e000ed04 psr: 61000000
2015-11-30 18:59:16,672 - INFO # HFSR: 40000000 CFSR: 40000
CFLAGS += -mlittle-endian -mcpu=cortex-m4 -march=armv7e-m -mthumb
CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard