Skip to content

platform: fix FreeRTOS scheduler on Zynq-A9 QEMU#69

Merged
zevorn merged 1 commit intomainfrom
fix/zynq-freertos-scheduler
Mar 18, 2026
Merged

platform: fix FreeRTOS scheduler on Zynq-A9 QEMU#69
zevorn merged 1 commit intomainfrom
fix/zynq-freertos-scheduler

Conversation

@zevorn
Copy link
Copy Markdown
Owner

@zevorn zevorn commented Mar 18, 2026

Summary

Fix three issues that prevented FreeRTOS from scheduling tasks on the Zynq-A9 QEMU platform. After this fix, claw_init() runs to completion with all services initialized.

Root causes

  1. Vector table overlap.freertos_vectors section lacked "ax" flags, so the linker assigned it the same VMA as .text. The IRQ vector at VBAR+0x18 pointed to Xil_In32 instead of FreeRTOS_IRQ_Handler

  2. VFP not enabledvPortRestoreTaskContext uses VPOP {d0-d15} / VPOP {d16-d31} to restore FPU context (configUSE_TASK_FPU_SUPPORT=2), but CP10/CP11 coprocessor access and FPEXC.EN were never set. This caused an Undefined Instruction exception on the first context switch

  3. Priority overflowconfigMAX_PRIORITIES was 8 but CLAW_GW_THREAD_PRIO and CLAW_AI_WORKER_PRIO are 15, triggering configASSERT(uxPriority < configMAX_PRIORITIES) in xTaskCreate()

Changes

File Fix
FreeRTOS_asm_vectors.S Add "ax" flags to .freertos_vectors section
link.ld Add ALIGN(32) to .freertos_vectors (ARM VBAR requirement)
startup.S Enable VFP (CPACR CP10/CP11 + FPEXC.EN), run main in SVC mode
FreeRTOSConfig.h configMAX_PRIORITIES 8 → 32

Boot output after fix

rt-claw: Zynq-A9 QEMU (FreeRTOS) - Real-Time Claw

  +-----------------------------------------+
  |          rt-claw v0.1.0                 |
  |  Real-Time Claw / Swarm Intelligence    |
  +-----------------------------------------+

[I/init] init: gateway
[I/gateway] started / initialized
[I/init] init: sched
[I/init] init: swarm
[I/init] init: net
[I/init] init: tools
[I/init] init: ai_engine
[I/ai] engine ready (model: claude-sonnet-4-6, tools: 1)
[I/init] init: ai_skill
[I/init] start: swarm

Test plan

  • make run-zynq-a9-qemu — full boot, all services initialize
  • make test-smoke-zynq — boot banner test passes
  • Verify ESP32 and vexpress-a9 builds unaffected

Three issues prevented FreeRTOS from scheduling tasks:

1. Vector table overlap: .freertos_vectors section lacked "ax" flags,
   causing the linker to assign it the same VMA as .text.  IRQ vector
   pointed at Xil_In32 instead of FreeRTOS_IRQ_Handler.  Fix: add
   "ax" flag and ALIGN(32) for ARM VBAR requirement.

2. VFP not enabled: vPortRestoreTaskContext uses VPOP to restore FPU
   context (configUSE_TASK_FPU_SUPPORT=2), but CP10/CP11 access and
   FPEXC.EN were not set.  This caused an Undefined Instruction
   exception on the first context switch.  Fix: enable VFP in
   startup.S before setting up stacks.

3. Priority range: configMAX_PRIORITIES was 8 but claw services use
   priorities up to 15.  Fix: increase to 32.

Verified: full claw_init() boot on QEMU — gateway, scheduler, swarm,
network, tools, AI engine all initialize successfully.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
@zevorn zevorn merged commit 9fa4ceb into main Mar 18, 2026
6 checks passed
@zevorn zevorn deleted the fix/zynq-freertos-scheduler branch March 19, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant