のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

prvPortStartFirstTaskのあと、HardFault

prvPortStartFirstTaskで、svc 0のあと、HardFaultになる。

f:id:none53:20190718035425p:plain
prvPortStartFirstTask

static void prvPortStartFirstTask( void )
{
    __asm volatile(
                    " ldr r0, =0xE000ED08    \n" /* Use the NVIC offset register to locate the stack. */
                    " ldr r0, [r0]           \n"
                    " ldr r0, [r0]           \n"
                    " msr msp, r0            \n" /* Set the msp back to the start of the stack. */
                    " mov r0, #0         \n" /* Clear the bit that indicates the FPU is in use, see comment above. */
                    " msr control, r0        \n"
                    " cpsie i                \n" /* Globally enable interrupts. */
                    " cpsie f                \n"
                    " dsb                    \n"
                    " isb                    \n"
                    " svc 0                  \n" /* System call to start first task. */
                    " nop                    \n"
                );
}
/*-----------------------------------------------------------*/

vPortSVCHandlerに、ブレークを設定したが、止まらなかった。

www.freertos.org

inc/FreeRTOSConfig.h:136

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names. */
#define vPortSVCHandler    SVC_Handler
#define xPortPendSVHandler PendSV_Handler

startup_stm32f429zitx.s

g_pfnVectors:
0  .word  _estack 
1 .word  Reset_Handler
2  .word  NMI_Handler
3  .word  HardFault_Handler

4  .word  MemManage_Handler
5  .word  BusFault_Handler
6  .word  UsageFault_Handler
7  .word  0

8  .word  0
9  .word  0
A  .word  0
B  .word  SVC_Handler

C  .word  DebugMon_Handler
D  .word  0
E  .word  PendSV_Handler
F  .word  SysTick_Handler

f:id:none53:20190718040612p:plain
nvic