platform: fix FreeRTOS scheduler on Zynq-A9 QEMU#69
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Vector table overlap —
.freertos_vectorssection lacked"ax"flags, so the linker assigned it the same VMA as.text. The IRQ vector atVBAR+0x18pointed toXil_In32instead ofFreeRTOS_IRQ_HandlerVFP not enabled —
vPortRestoreTaskContextusesVPOP {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 switchPriority overflow —
configMAX_PRIORITIESwas 8 butCLAW_GW_THREAD_PRIOandCLAW_AI_WORKER_PRIOare 15, triggeringconfigASSERT(uxPriority < configMAX_PRIORITIES)inxTaskCreate()Changes
FreeRTOS_asm_vectors.S"ax"flags to.freertos_vectorssectionlink.ldALIGN(32)to.freertos_vectors(ARM VBAR requirement)startup.SFreeRTOSConfig.hconfigMAX_PRIORITIES8 → 32Boot output after fix
Test plan
make run-zynq-a9-qemu— full boot, all services initializemake test-smoke-zynq— boot banner test passes