This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

FreeRTOS debugging

Hi,

I am trying to debug my code in Eclipse using J-Link. Whenever the code executes vPortStartFirstTask() in vTaskStartScheduler() the debugger stops and I can't debug my program.

It happens when this code is executed:

__asm volatile(
                " ldr r0, =__isr_vector \n" /* Locate the stack using __isr_vector table. */
                " ldr r0, [r0]          \n"
                " msr msp, r0           \n" /* Set the msp back to the start of the stack. */
                " cpsie i               \n" /* Globally enable interrupts. */
                " cpsie f               \n"
                " dsb                   \n"
                " isb                   \n"
#ifdef SOFTDEVICE_PRESENT
                /* Block kernel interrupts only (PendSV) before calling SVC */
                " mov r0, %0            \n"
                " msr basepri, r0       \n"
#endif
                " svc 0                 \n" /* System call to start first task. */
                "                       \n"
                " .align 2              \n"
#ifdef SOFTDEVICE_PRESENT
                ::"i"(configKERNEL_INTERRUPT_PRIORITY  << (8 - configPRIO_BITS))
#endif
            );

Does anybody know why this happens and how I can fix this?

Thanks in advance!

  • The SVC handler (the function that executes when "svc 0" is executed) starts the scheduler, so it is not necessarily this function that is causing the problem, but maybe something after the scheduler has started.

    First, do you have the FreeRTOS SVC handler installed? See "Special note to ARM Cortex-M users" in the first numbered bullet on this page: www.freertos.org/FAQHelp.html

    If you are sure the SVC handler is installed, then try setting a break point in the SVC handler. It is called vPortSVCHandler() and is defined in whichever FreeRTOS/source/portable/[compiler]/ARM_CM[0,3,4,7]/port.c file you are building. Is the break point hit? If so, then it is not the code you show above that is the problem.

    If the break point is hit, step through the SVC handler until it returns. It should return into the first task that is selected to run.

  • Thank you, you are totally right!

Related