# vTaskStartScheduler() hangs the system on QEMU

**URL:** <https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001>\
**Category:** Kernel\
**Created:** [April 28, 2025, 10:43pm UTC](https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001 "2025-04-28T22:43:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolver32](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@Wolver32](https://forums.freertos.org/u/Wolver32)\
**Post date:** [April 28, 2025, 10:43pm UTC](https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001/1 "2025-04-28T22:43:53Z")

</div>

Hello, I’m trying to run a FreeRTOS demo on a custom QEMU emulated board, CPU is Cortex-M7. Everything seems to be working just fine, but as soon as I try to launch the scheduler the system hangs, none of the newly created tasks will go in execution nor do I get a fail on the call (if that happened the instructions after vTaskStartScheduler() would be executed).  
I changed config parameters in FreeRTOSConfig.h multiple times, unfortunately without any success. I’m new to FreeRTOS, what do you think would cause vTaskStartScheduler() to hang?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![jefftenney](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/jefftenney/32/1314_2.png) [@jefftenney](https://forums.freertos.org/u/jefftenney)\
**Post date:** [April 29, 2025, 3:08am UTC](https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001/2 "2025-04-29T03:08:39Z")

</div>

FreeRTOS startup, invoked by `vTaskStartScheduler()`, contains several `configASSERT()` statements to help developers configure and integrate FreeRTOS correctly. Depending on how `configASSERT()` is defined, it might be the cause of the hanging you observe. Can you look in FreeRTOSConfig.h to see how `configASSERT()` is defined?

---

<div class="post-metadata">

**Author:** ![Wolver32](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@Wolver32](https://forums.freertos.org/u/Wolver32)\
**Post date:** [April 29, 2025, 8:36am UTC](https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001/3 "2025-04-29T08:36:30Z")

</div>

Thank you for your reply Jeff!  
configASSERT() is defined in the following way:

#define configASSERT(x) if((x)==0) { \_\_asm volatile ( " cpsid i " ::: “memory” ); for( ;; ); }

---

<div class="post-metadata">

**Author:** ![jefftenney](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/jefftenney/32/1314_2.png) [@jefftenney](https://forums.freertos.org/u/jefftenney)\
**Post date:** [April 29, 2025, 2:05pm UTC](https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001/4 "2025-04-29T14:05:51Z")

</div>

With that definition, the most likely explanation is a `configASSERT()` statement is hanging due to a configuration error. If you are using a debugger, you can use it to stop execution while it is hanging, and you can see which `configASSERT()` statement has identified the configuration error. If you don’t have a debugger, you can probably use a different definition of `configASSERT()` that allows QEMU to exit gracefully with a report about the failed assertion. See [here](https://github.com/FreeRTOS/FreeRTOS/blob/0d2a5ae534bf773f1d75a1932af24ebe5f1369e5/FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/FreeRTOSConfig.h#L115-L116) for an example.

---

<div class="post-metadata">

**Author:** ![Wolver32](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@Wolver32](https://forums.freertos.org/u/Wolver32)\
**Post date:** [April 29, 2025, 3:14pm UTC](https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001/5 "2025-04-29T15:14:19Z")

</div>

Thanks a lot for the suggestion!  
I’ve tried to follow the example that you shared and, while using GDB, I found out that the assertion that identifies the error is in GCC/ARM\_CM7/r0p1/port.c at line 331, which contains the following code:  
configASSERT( pxVectorTable[portVECTOR\_INDEX\_SVC] == vPortSVCHandler );

If I comment out that instruction or I define configCHECK\_HANDLER\_INSTALLATION 0 to skip all those checks, the system seems to be stuck in the infinite loop of the default handler. Before going in the default handler, the last function executed was prvPortStartFirstTask().

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [April 29, 2025, 3:40pm UTC](https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001/6 "2025-04-29T15:40:52Z")

</div>

Which shows the problem, you somehow haven’t configured your system to install the FreeRTOS SVC Handler into the interrupt vector table.

How you do this depends very much on the full tool-chain you are using.

---

<div class="post-metadata">

**Author:** ![jefftenney](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/jefftenney/32/1314_2.png) [@jefftenney](https://forums.freertos.org/u/jefftenney)\
**Post date:** [April 29, 2025, 4:04pm UTC](https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001/7 "2025-04-29T16:04:23Z")

</div>

You’ll have to get the vector table sorted out to get FreeRTOS up and running.

[Here](https://github.com/FreeRTOS/FreeRTOS/blob/0d2a5ae534bf773f1d75a1932af24ebe5f1369e5/FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/startup.c#L69) is the vector table in the example project I linked earlier. Take particular note of the `vPortSVCHandler`, `xPortPendSVHandler`, and `xPortSysTickHandler`, which must be in your vector table for FreeRTOS to function in its most common configuration.

If you can’t find your vector table in your project, then it might be provided for you by the tools and would likely be CMSIS compliant. In that case, you can #define the 3 handlers to their CMSIS names so they will be properly installed into the vector table. Something like this:

```auto
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler

```

---

<div class="post-metadata">

**Author:** ![Wolver32](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@Wolver32](https://forums.freertos.org/u/Wolver32)\
**Post date:** [April 29, 2025, 8:36pm UTC](https://forums.freertos.org/t/vtaskstartscheduler-hangs-the-system-on-qemu/23001/8 "2025-04-29T20:36:49Z")

</div>

That was it! Thank you so much Jeff and also to you Richard, you’ve both been of great help. I had to add #define vPortSVCHandler SVC\_Handler, now everything works correctly.
