feat: S08.01 FreeRTOS hello-world bring-up — QEMU mps2-an385 + GDB attach#273
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (26)
📝 WalkthroughWalkthroughThis PR introduces FreeRTOS hello-world support by adding a cross-compiled example targeting QEMU mps2-an385 (Cortex-M3), layered Docker images with FreeRTOS sources, ARM cross-compilation toolchain, startup code with linker script, conditional CMake build logic, new CI jobs for host and target builds, and updated devcontainer services and VS Code workflows for development and GDB debugging. ChangesFreeRTOS Hello-World Bring-Up (QEMU mps2-an385)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
Example/FreeRtos/HelloWorld/CMakeLists.txt (1)
27-37: ⚡ Quick winScope
-Wno-unused-parameterto FreeRTOS kernel sources only.The comment on lines 33-36 explains the suppression is "for the kernel-included sources", but
target_compile_options(... PRIVATE -Wno-unused-parameter)applies it to every translation unit in the target, includingmain.candstartup.c. Project sources should keep tripping the warning — applying this viaset_source_files_propertieskeeps the bar high for our code while still relaxing the kernel files.♻️ Proposed scoping
target_compile_options(SolidSyslogFreeRtosHelloWorld PRIVATE -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections -fno-common - # FreeRTOS-Kernel V11.1.0 uses non-prototype function declarations and - # type-narrowing constructs that trip our strict host warnings; relax - # for the kernel-included sources without lowering the bar everywhere. - -Wno-unused-parameter ) + +# FreeRTOS-Kernel V11.1.0 uses non-prototype function declarations and +# type-narrowing constructs that trip our strict host warnings; relax +# only on the kernel-included sources without lowering the bar on +# project code (main.c / startup.c). +set_source_files_properties( + ${FREERTOS_KERNEL_PATH}/tasks.c + ${FREERTOS_KERNEL_PATH}/queue.c + ${FREERTOS_KERNEL_PATH}/list.c + ${FREERTOS_PORT_DIR}/port.c + ${FREERTOS_KERNEL_PATH}/portable/MemMang/heap_4.c + PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter" +)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Example/FreeRtos/HelloWorld/CMakeLists.txt` around lines 27 - 37, The -Wno-unused-parameter flag is currently applied to the whole target via target_compile_options(SolidSyslogFreeRtosHelloWorld ...), but it should only apply to the FreeRTOS kernel sources; remove -Wno-unused-parameter from the target_compile_options call and instead call set_source_files_properties(...) for the kernel source files (e.g., the files under the FreeRTOS-Kernel directory or the variable that collects them) with PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter" so only the kernel translation units (not main.c/startup.c or other project code) get the warning suppressed..vscode/tasks.json (1)
10-10: ⚡ Quick winMake
build and testself-contained by configuring before build.Right now, on a clean workspace, pre-launch can fail with missing CMake cache because Line 10 runs build directly. Adding a configure call per CMake branch makes the task reliable from first run.
Proposed update
- "command": "case \"$BUILD_PRESET\" in '') behave Bdd/features/ ;; freertos-cross) cmake --build --preset \"$BUILD_PRESET\" --target SolidSyslogFreeRtosHelloWorld ;; *) cmake --build --preset \"$BUILD_PRESET\" --target SolidSyslogTests && ctest --preset \"$BUILD_PRESET\" --verbose --tests-regex '^SolidSyslogTests$' ;; esac", + "command": "case \"$BUILD_PRESET\" in '') behave Bdd/features/ ;; freertos-cross) cmake --preset \"$BUILD_PRESET\" && cmake --build --preset \"$BUILD_PRESET\" --target SolidSyslogFreeRtosHelloWorld ;; *) cmake --preset \"$BUILD_PRESET\" && cmake --build --preset \"$BUILD_PRESET\" --target SolidSyslogTests && ctest --preset \"$BUILD_PRESET\" --verbose --tests-regex '^SolidSyslogTests$' ;; esac",🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.vscode/tasks.json at line 10, The task's command runs cmake --build directly (using BUILD_PRESET) and can fail on a clean workspace; update the case branches that call cmake --build (the freertos-cross branch and the default branch that builds SolidSyslogFreeRtosHelloWorld and SolidSyslogTests/ctest) to run a configure step first by invoking the appropriate CMake configure preset (e.g. cmake --preset "$BUILD_PRESET") before cmake --build --preset "$BUILD_PRESET" --target ... and before running ctest, ensuring each branch that builds uses configure then build so the task is self-contained from a clean workspace.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 632-640: The smoke test currently masks the timeout exit by using
"|| true" so regressions can pass; remove the "|| true" and capture the command
exit code (e.g., run OUT=$(timeout 5 qemu-system-arm ... ) ; EXIT=$?), then echo
"$OUT" and assert expected outcomes: if EXIT == 124 treat as a timeout success
(allowed), elif EXIT != 0 fail the job (exit non-zero), else run the grep -q
"hello from FreeRTOS on QEMU mps2-an385" against OUT and fail if grep doesn't
match; reference the OUT variable, the timeout invocation, the EXIT code check,
and the grep -q call when making these changes.
In `@Example/FreeRtos/HelloWorld/main.c`:
- Around line 28-30: The call to xTaskCreate is ignoring its return value which
can hide task-creation failures; before calling vTaskStartScheduler(), capture
the BaseType_t result from xTaskCreate(HelloTask, "hello",
configMINIMAL_STACK_SIZE * 4, NULL, tskIDLE_PRIORITY + 1, NULL), check it equals
pdPASS, and on failure call an appropriate failure handler (e.g., log the error,
call configASSERT(0) or loop/halt) so the system fails fast instead of running
an idle-only scheduler.
In `@Example/FreeRtos/README.md`:
- Around line 47-49: The README has unlabeled fenced code blocks causing MD040;
update the two fenced blocks that contain
"build/freertos-cross/Example/FreeRtos/HelloWorld/SolidSyslogFreeRtosHelloWorld.elf"
and the block containing "hello from FreeRTOS on QEMU mps2-an385" to include a
fence language (e.g., use "text") so the opening triple-backtick becomes a
labeled fence for markdownlint compliance.
---
Nitpick comments:
In @.vscode/tasks.json:
- Line 10: The task's command runs cmake --build directly (using BUILD_PRESET)
and can fail on a clean workspace; update the case branches that call cmake
--build (the freertos-cross branch and the default branch that builds
SolidSyslogFreeRtosHelloWorld and SolidSyslogTests/ctest) to run a configure
step first by invoking the appropriate CMake configure preset (e.g. cmake
--preset "$BUILD_PRESET") before cmake --build --preset "$BUILD_PRESET" --target
... and before running ctest, ensuring each branch that builds uses configure
then build so the task is self-contained from a clean workspace.
In `@Example/FreeRtos/HelloWorld/CMakeLists.txt`:
- Around line 27-37: The -Wno-unused-parameter flag is currently applied to the
whole target via target_compile_options(SolidSyslogFreeRtosHelloWorld ...), but
it should only apply to the FreeRTOS kernel sources; remove
-Wno-unused-parameter from the target_compile_options call and instead call
set_source_files_properties(...) for the kernel source files (e.g., the files
under the FreeRTOS-Kernel directory or the variable that collects them) with
PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter" so only the kernel
translation units (not main.c/startup.c or other project code) get the warning
suppressed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 935a7b8d-b027-4ac6-9be3-a3e1335e2c5b
📒 Files selected for processing (26)
.devcontainer/devcontainer-lock.json.devcontainer/devcontainer.json.devcontainer/docker-compose.yml.github/workflows/ci.yml.vscode/launch.json.vscode/tasks.jsonCMakeLists.txtCMakePresets.jsonDEVLOG.mdExample/FreeRtos/CMakeLists.txtExample/FreeRtos/HelloWorld/CMakeLists.txtExample/FreeRtos/HelloWorld/FreeRTOSConfig.hExample/FreeRtos/HelloWorld/main.cExample/FreeRtos/HelloWorld/mps2-an385.ldExample/FreeRtos/HelloWorld/startup.cExample/FreeRtos/README.mdExample/FreeRtos/cmake/arm-none-eabi.cmakePlatform/FreeRtos/CMakeLists.txtPlatform/FreeRtos/Interface/.gitkeepPlatform/FreeRtos/Source/.gitkeepTests/CMakeLists.txtTests/FreeRtos/CMakeLists.txtTests/Support/FreeRtosFakes/CMakeLists.txtTests/Support/FreeRtosFakes/Interface/FreeRTOSConfig.hTests/Support/FreeRtosFakes/Source/.gitkeepdocs/containers.md
b80b721 to
55ecc38
Compare
…tach
Establish the foundational dev-container stack and a minimal FreeRTOS
hello-world running under QEMU mps2-an385 (Cortex-M3). Every subsequent
E08 story builds on the container architecture and CMake hooks introduced
here.
Container architecture — three tiers, two new images published from
the new CppUTestFreertosDocker repo at sha-44efeae:
- ghcr.io/davidcozens/cpputest-freertos (MIDDLE, FROM cpputest:sha-18f19e1)
adds FreeRTOS-Kernel V11.1.0, Plus-TCP V4.2.2, Plus-FAT main@8d38036
(Lab project, no tags), Mbed TLS v3.6.2 LTS sources at /opt/... +
FREERTOS_*_PATH / MBEDTLS_DIR env vars. Used for host-TDD of FreeRTOS
adapters against fakes.
- ghcr.io/davidcozens/cpputest-freertos-cross (TOP, FROM cpputest-freertos
at the same SHA) adds gcc-arm-none-eabi, libnewlib-arm-none-eabi,
gdb-multiarch (aliased as arm-none-eabi-gdb), and qemu-system-arm. Used
for cross builds, on-QEMU runs, and GDB attach.
Repo additions:
- Platform/FreeRtos/ — CMake INTERFACE library. FreeRTOS / FatFS / mbedTLS
are header-configured; their adapters must compile in the integrator's
project with the integrator's config, not as a precompiled libSolidSyslog.a
member. INTERFACE propagates the adapter sources and include path to
every consumer. Empty at S08.01; first content (mutex) lands at S08.04.
- Tests/Support/FreeRtosFakes/ — placeholder + host-suitable
FreeRTOSConfig.h for fake builds. First fakes land with S08.04.
- Tests/FreeRtos/ — placeholder; first test lands with S08.04.
- Example/FreeRtos/HelloWorld/ — single FreeRTOS task that prints \"hello\"
via newlib rdimon semihosting. Cortex-M3 startup (vector table,
Reset_Handler, weak default handlers), mps2-an385 linker script (FLASH
at 0x0, SRAM at 0x20000000).
- Example/FreeRtos/cmake/arm-none-eabi.cmake — cross toolchain file.
- Example/FreeRtos/README.md — build / run / GDB-attach instructions.
CMake hooks:
- if(DEFINED ENV{FREERTOS_KERNEL_PATH}) gate Platform/FreeRtos and the
Tests/FreeRtos subtrees — added in MIDDLE and TOP, skipped in BASE.
- if(CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR STREQUAL \"arm\")
gate Example/FreeRtos — only entered via the freertos-cross preset.
- find_package(CppUTest/Threads REQUIRED) and Tests subtree wrapped in
if(NOT CMAKE_CROSSCOMPILING) — bare-metal arm-none-eabi has no pthreads
and no CppUTest in the cross image.
CMake preset freertos-cross selects Example/FreeRtos/cmake/arm-none-eabi.cmake.
Devcontainer switching: change `service` field in the existing
.devcontainer/devcontainer.json to `freertos-host` or `freertos-target` and rebuild — same procedure as switching to `clang` or `behave`. Cortex-debug extension added to the BASE devcontainer for use after switching to `freertos-target`.
CI jobs added: build-freertos-host-tdd (configure+build under MIDDLE) and
build-freertos-target (cross-compile + QEMU smoke that asserts the
expected greeting in stdout). Both added to the summary job's needs list.
Branch-protection update to mark them as required checks waits until they
go green at least once on PR CI.
Verified locally on the WSL host:
- cmake --preset debug under BASE: unchanged behaviour.
- cmake -S . -B ... under MIDDLE (with FREERTOS_KERNEL_PATH set): full
test world builds clean.
- cmake --preset freertos-cross && cmake --build ... under TOP: produces
226 KiB ELF.
- qemu-system-arm -M mps2-an385 -kernel <elf> -semihosting-config
enable=on,target=native: prints \"hello from FreeRTOS on QEMU
mps2-an385\", scheduler keeps idling.
- arm-none-eabi-gdb attaches to :1234 gdbstub, breakpoint at main hits.
- analyze-format check: all new files pass clang-format --dry-run --Werror.
Closes #266
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
55ecc38 to
5a410d0
Compare
☀️ Quality Summary 🚦 build-linux-gcc: 100% successful (✔️ 1049 passed, 🙈 3 skipped) Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result. |
Purpose
Closes #266 — establish the foundational dev-container stack and a minimal
FreeRTOS hello-world running under QEMU
mps2-an385(Cortex-M3). Everysubsequent E08 story builds on the container architecture and CMake hooks
introduced here. Parent epic: #10.
Change Description
Container architecture — three tiers, two new images, both at sha-44efeae:
ghcr.io/davidcozens/cpputest-freertos(MIDDLE, FROMcpputest:sha-18f19e1) adds FreeRTOS-Kernel V11.1.0, Plus-TCP V4.2.2, Plus-FAT main@8d38036 (Lab project, no tags), Mbed TLS v3.6.2 LTS sources at/opt/...plusFREERTOS_*_PATH/MBEDTLS_DIRenv vars. For host-TDD of FreeRTOS adapters against fakes.ghcr.io/davidcozens/cpputest-freertos-cross(TOP, FROMcpputest-freertos) addsgcc-arm-none-eabi,libnewlib-arm-none-eabi,gdb-multiarch(aliased asarm-none-eabi-gdb), andqemu-system-arm. For cross builds, on-QEMU runs, GDB attach.CppUTestFreertosDockerrepo. One workflow publishes both on push; the cross build uses--build-arg BASE_TAG=sha-<short>so the FROM line is pinned in the same workflow run.Repo additions:
Platform/FreeRtos/as a CMake INTERFACE library — adapter sources will recompile in each consumer (Example/FreeRtos, Tests/FreeRtos, downstream apps) with the consumer'sFreeRTOSConfig.hon the include path. Empty at S08.01; first content (mutex) at S08.04. Captured as theproject_header_configured_platformsmemory.Tests/Support/FreeRtosFakes/(host-suitableFreeRTOSConfig.h+ Source/ placeholder) andTests/FreeRtos/placeholder. First fakes + tests at S08.04.Example/FreeRtos/HelloWorld/— single FreeRTOS task that printshellovia newlib rdimon semihosting. Cortex-M3 startup (vector table, Reset_Handler, weak handlers),mps2-an385.ldlinker script (FLASH at 0x0, SRAM at 0x20000000).Example/FreeRtos/cmake/arm-none-eabi.cmakecross toolchain file.freertos-crossCMake preset selects the toolchain.freertos-hostandfreertos-targetservices in.devcontainer/docker-compose.yml. The single.devcontainer/devcontainer.jsonnow has commented-outservicelines for one-line switching.Ctrl+Shift+Badapts via thebuild and testtask (case-branches on$BUILD_PRESET).F5runsDebug SolidSyslogTests (host)forgcc/clang/freertos-hostorDebug FreeRTOS HelloWorld (QEMU)(cortex-debug + qemu-system-arm) forfreertos-target. Plus arun on QEMU (FreeRTOS)task for one-shot ELF runs.CI hooks: new
build-freertos-host-tdd(configure+build under MIDDLE) andbuild-freertos-target(cross-compile + QEMU smoke that asserts the expected greeting in stdout). Added tosummaryjob'sneeds:list. Branch-protection update to mark them required-checks waits until they go green at least once on PR CI.Test Evidence
No TDD on this story by agreement (infrastructure-only — no production logic added;
Platform/FreeRtos/directories are intentionally empty placeholders). Acceptance verified manually on the WSL host:cmake --preset debugunder BASE: configure clean, no FreeRTOS subdirs added (gates evaluate false).cmake -S . -B …under MIDDLE (FREERTOS_KERNEL_PATH=/opt/freertos/kernel): configure clean,Platform/FreeRtosINTERFACE lib +Tests/Support/FreeRtosFakes+Tests/FreeRtosplaceholders all add cleanly, full host test world still builds.cmake --preset freertos-cross && cmake --build --preset freertos-crossunder TOP: produces 226 KiB ELF.qemu-system-arm -M mps2-an385 -kernel <elf> -semihosting-config enable=on,target=native: printshello from FreeRTOS on QEMU mps2-an385, scheduler keeps idling.arm-none-eabi-gdbattaches to QEMU's:1234gdbstub, breakpoint atmainhits, backtrace resolves.analyze-formatcheck (clang-format dry-run --Werror) passes on all new C/H files.debug/clang-debug/freertos-cross).CI's
build-freertos-host-tddandbuild-freertos-targetjobs reproduce the cross build + QEMU smoke automatically.Areas Affected
Platform/FreeRtos/,Example/FreeRtos/,Tests/Support/FreeRtosFakes/,Tests/FreeRtos/.CMakeLists.txt(env-gate FreeRTOS subdirs; cross-skip CppUTest/Tests),Tests/CMakeLists.txt,CMakePresets.json,.devcontainer/{devcontainer.json,docker-compose.yml},.github/workflows/ci.yml,.vscode/{tasks.json,launch.json},docs/containers.md.PRIVATE-into-\${PROJECT_NAME}pattern. Only header-configured platforms (FreeRtos, future FatFS/mbedTLS adapters) use INTERFACE.Summary by CodeRabbit
New Features
Chores