Skip to content

feat: S08.01 FreeRTOS hello-world bring-up — QEMU mps2-an385 + GDB attach#273

Merged
DavidCozens merged 1 commit into
mainfrom
feat/s08-01-freertos-bring-up
May 5, 2026
Merged

feat: S08.01 FreeRTOS hello-world bring-up — QEMU mps2-an385 + GDB attach#273
DavidCozens merged 1 commit into
mainfrom
feat/s08-01-freertos-bring-up

Conversation

@DavidCozens

@DavidCozens DavidCozens commented May 5, 2026

Copy link
Copy Markdown
Owner

Purpose

Closes #266 — 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. Parent epic: #10.

Change Description

Container architecture — three tiers, two new images, both 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/... plus FREERTOS_*_PATH / MBEDTLS_DIR env vars. For host-TDD of FreeRTOS adapters against fakes.
  • ghcr.io/davidcozens/cpputest-freertos-cross (TOP, FROM cpputest-freertos) adds gcc-arm-none-eabi, libnewlib-arm-none-eabi, gdb-multiarch (aliased as arm-none-eabi-gdb), and qemu-system-arm. For cross builds, on-QEMU runs, GDB attach.
  • Both images live in the new CppUTestFreertosDocker repo. 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's FreeRTOSConfig.h on the include path. Empty at S08.01; first content (mutex) at S08.04. Captured as the project_header_configured_platforms memory.
  • Tests/Support/FreeRtosFakes/ (host-suitable FreeRTOSConfig.h + Source/ placeholder) and Tests/FreeRtos/ placeholder. First fakes + tests at S08.04.
  • Example/FreeRtos/HelloWorld/ — single FreeRTOS task that prints hello via newlib rdimon semihosting. Cortex-M3 startup (vector table, Reset_Handler, weak handlers), mps2-an385.ld linker script (FLASH at 0x0, SRAM at 0x20000000).
  • Example/FreeRtos/cmake/arm-none-eabi.cmake cross toolchain file.
  • New freertos-cross CMake preset selects the toolchain.
  • freertos-host and freertos-target services in .devcontainer/docker-compose.yml. The single .devcontainer/devcontainer.json now has commented-out service lines for one-line switching.
  • VS Code workflow uniform across services: Ctrl+Shift+B adapts via the build and test task (case-branches on $BUILD_PRESET). F5 runs Debug SolidSyslogTests (host) for gcc/clang/freertos-host or Debug FreeRTOS HelloWorld (QEMU) (cortex-debug + qemu-system-arm) for freertos-target. Plus a run on QEMU (FreeRTOS) task for one-shot ELF runs.

CI hooks: new build-freertos-host-tdd (configure+build under MIDDLE) and build-freertos-target (cross-compile + QEMU smoke that asserts the expected greeting in stdout). Added to summary job's needs: 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 debug under BASE: configure clean, no FreeRTOS subdirs added (gates evaluate false).
  • cmake -S . -B … under MIDDLE (FREERTOS_KERNEL_PATH=/opt/freertos/kernel): configure clean, Platform/FreeRtos INTERFACE lib + Tests/Support/FreeRtosFakes + Tests/FreeRtos placeholders all add cleanly, full host test world still builds.
  • cmake --preset freertos-cross && cmake --build --preset freertos-cross 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 QEMU's :1234 gdbstub, breakpoint at main hits, backtrace resolves.
  • analyze-format check (clang-format dry-run --Werror) passes on all new C/H files.
  • Build task simulated for every BUILD_PRESET branch (empty / debug / clang-debug / freertos-cross).

CI's build-freertos-host-tdd and build-freertos-target jobs reproduce the cross build + QEMU smoke automatically.

Areas Affected

  • New: Platform/FreeRtos/, Example/FreeRtos/, Tests/Support/FreeRtosFakes/, Tests/FreeRtos/.
  • Modified: 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.
  • POSIX/Windows/OpenSSL platform code untouched — they keep the existing PRIVATE-into-\${PROJECT_NAME} pattern. Only header-configured platforms (FreeRtos, future FatFS/mbedTLS adapters) use INTERFACE.
  • DEVLOG entry appended.

Summary by CodeRabbit

  • New Features

    • Added FreeRTOS support with a HelloWorld example demonstrating cross-compilation and QEMU execution for ARM Cortex-M3 targets.
    • Enabled ARM cross-compilation via new CMake preset for embedded development.
    • Added debugging support for FreeRTOS applications via Cortex-Debug extension.
  • Chores

    • Updated development container with FreeRTOS build tooling and CI pipeline jobs.

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@DavidCozens has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 37 minutes and 27 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09da1001-ba21-4858-9031-6c34d4e1f56b

📥 Commits

Reviewing files that changed from the base of the PR and between b80b721 and 5a410d0.

📒 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.json
  • CMakeLists.txt
  • CMakePresets.json
  • DEVLOG.md
  • Example/FreeRtos/CMakeLists.txt
  • Example/FreeRtos/HelloWorld/CMakeLists.txt
  • Example/FreeRtos/HelloWorld/FreeRTOSConfig.h
  • Example/FreeRtos/HelloWorld/main.c
  • Example/FreeRtos/HelloWorld/mps2-an385.ld
  • Example/FreeRtos/HelloWorld/startup.c
  • Example/FreeRtos/README.md
  • Example/FreeRtos/cmake/arm-none-eabi.cmake
  • Platform/FreeRtos/CMakeLists.txt
  • Platform/FreeRtos/Interface/.gitkeep
  • Platform/FreeRtos/Source/.gitkeep
  • Tests/CMakeLists.txt
  • Tests/FreeRtos/CMakeLists.txt
  • Tests/Support/FreeRtosFakes/CMakeLists.txt
  • Tests/Support/FreeRtosFakes/Interface/FreeRTOSConfig.h
  • Tests/Support/FreeRtosFakes/Source/.gitkeep
  • docs/containers.md
📝 Walkthrough

Walkthrough

This 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.

Changes

FreeRTOS Hello-World Bring-Up (QEMU mps2-an385)

Layer / File(s) Summary
Build System Configuration
CMakeLists.txt, CMakePresets.json
CMake now conditionally includes Platform/FreeRtos when FREERTOS_KERNEL_PATH is defined, adds Example/FreeRtos only for ARM cross-compilation, and skips test enablement during cross-builds. New freertos-cross configure and build presets added for ARM toolchain selection.
Cross-Compilation Toolchain
Example/FreeRtos/cmake/arm-none-eabi.cmake
ARM cross-compiler configuration for arm-none-eabi-gcc/g++ targeting generic bare-metal Cortex-M systems, with CMake find-path restrictions to prevent host tool contamination.
Bootloader & Runtime Initialization
Example/FreeRtos/HelloWorld/startup.c, Example/FreeRtos/HelloWorld/mps2-an385.ld
Cortex-M3 Reset_Handler initializes .data from FLASH, zeros .bss, runs static initializers, then calls main(). Linker script defines FLASH/SRAM memory regions and lays out ELF sections with correct load/runtime placement and boundary symbols for C runtime support.
FreeRTOS Configuration & Application
Example/FreeRtos/HelloWorld/FreeRTOSConfig.h, Example/FreeRtos/HelloWorld/main.c, Example/FreeRtos/HelloWorld/CMakeLists.txt
FreeRTOS kernel config sets scheduler/heap/task parameters and Cortex-M3 priority macros. Main creates a HelloTask that prints via semihosting, then starts the scheduler. CMake build links FreeRTOS kernel sources and the startup sequence into a .elf output with semihosting and map-file generation.
Example & Platform Scaffolding
Example/FreeRtos/CMakeLists.txt, Platform/FreeRtos/CMakeLists.txt, Tests/CMakeLists.txt
Example and platform subdirectories conditionally included via environment checks. Platform/FreeRtos defines an INTERFACE library exposing adapter headers. Test support directories added for FreeRtos fakes (placeholder CMakeLists and host-suitable FreeRTOSConfig.h).
Test Infrastructure
Tests/FreeRtos/CMakeLists.txt, Tests/Support/FreeRtosFakes/CMakeLists.txt, Tests/Support/FreeRtosFakes/Interface/FreeRTOSConfig.h
FreeRtos test placeholder and fakes infrastructure established for future host-side adapter unit tests using real FreeRTOS headers with fake implementations.
Developer Experience
.devcontainer/devcontainer.json, .devcontainer/docker-compose.yml, .devcontainer/devcontainer-lock.json
Added freertos-host and freertos-target Docker Compose services with appropriate build presets and environment. Devcontainer now references cortex-debug extension and includes GitHub CLI feature. Enables VSCode service switching.
VS Code Workflows
.vscode/tasks.json, .vscode/launch.json
Task dispatcher updated to dispatch by BUILD_PRESET: BDD, FreeRTOS target cross-build, or host SolidSyslogTests. New QEMU one-shot task for FreeRTOS ELF execution. Launch config updated for preset-aware executable path; new cortex-debug config for QEMU + GDB attach on QEMU's gdbserver port.
CI Integration
.github/workflows/ci.yml
Two new jobs: build-freertos-host-tdd (smoke build in MIDDLE image) and build-freertos-target (cross-build ELF and run under QEMU for 5 seconds, asserting expected semihosting output). PR summary job now waits for both.
Documentation
Example/FreeRtos/README.md, docs/containers.md, DEVLOG.md
Example README documents VSCode and CLI build/run/GDB workflows. Container docs list new images and service-switching instructions. DEVLOG records S08.01 decisions (adapter layering, semihosting, FreeRTOS pinning, cross-build skips) and verification status.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • The changes directly implement all objectives of linked issue #266 (S08.01: FreeRTOS hello-world bring-up — QEMU mps2-an385 + GDB attach), including container architecture, CMake hooks, example code, devcontainer configurations, CI matrix jobs, and acceptance criteria.

Possibly related PRs

  • DavidCozens/solid-syslog#208: Both PRs modify .vscode/tasks.json to scope the default "build and test" task; this PR integrates that scoping into a preset-based dispatch mechanism.
  • DavidCozens/solid-syslog#127: Both PRs modify .vscode/tasks.json task definitions and command dispatching logic, sharing common concerns around build task routing.

Poem

🐰 A rabbit hops into the FreeRTOS dawn,
Cortex-M3 boots, the startup's warm,
QEMU spins the cross-compiled song,
From semihosting, "hello" shines strong!
GDB attaches, the debugger's throne—
The little kernel's no longer alone. 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: a FreeRTOS hello-world bring-up for QEMU mps2-an385 with GDB attach support, matching the PR's core objective.
Description check ✅ Passed The description is comprehensive and well-structured, covering Purpose, Change Description, Test Evidence, and Areas Affected sections that align with the template and provide detailed context.
Linked Issues check ✅ Passed The PR fully addresses issue #266 requirements: three-tier container architecture, CMake conditional includes, FreeRTOS repo scaffolding, devcontainer configs, VS Code workflow, and CI jobs all implemented and verified.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #266 scope. No unrelated modifications detected; infrastructure additions, configuration changes, and example code are all foundational components explicitly required.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/s08-01-freertos-bring-up

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
Example/FreeRtos/HelloWorld/CMakeLists.txt (1)

27-37: ⚡ Quick win

Scope -Wno-unused-parameter to 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, including main.c and startup.c. Project sources should keep tripping the warning — applying this via set_source_files_properties keeps 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 win

Make build and test self-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

📥 Commits

Reviewing files that changed from the base of the PR and between 9c70c84 and b80b721.

📒 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.json
  • CMakeLists.txt
  • CMakePresets.json
  • DEVLOG.md
  • Example/FreeRtos/CMakeLists.txt
  • Example/FreeRtos/HelloWorld/CMakeLists.txt
  • Example/FreeRtos/HelloWorld/FreeRTOSConfig.h
  • Example/FreeRtos/HelloWorld/main.c
  • Example/FreeRtos/HelloWorld/mps2-an385.ld
  • Example/FreeRtos/HelloWorld/startup.c
  • Example/FreeRtos/README.md
  • Example/FreeRtos/cmake/arm-none-eabi.cmake
  • Platform/FreeRtos/CMakeLists.txt
  • Platform/FreeRtos/Interface/.gitkeep
  • Platform/FreeRtos/Source/.gitkeep
  • Tests/CMakeLists.txt
  • Tests/FreeRtos/CMakeLists.txt
  • Tests/Support/FreeRtosFakes/CMakeLists.txt
  • Tests/Support/FreeRtosFakes/Interface/FreeRTOSConfig.h
  • Tests/Support/FreeRtosFakes/Source/.gitkeep
  • docs/containers.md

Comment thread .github/workflows/ci.yml
Comment thread Example/FreeRtos/HelloWorld/main.c Outdated
Comment thread Example/FreeRtos/README.md Outdated
@DavidCozens DavidCozens force-pushed the feat/s08-01-freertos-bring-up branch from b80b721 to 55ecc38 Compare May 5, 2026 20:18
…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>
@DavidCozens DavidCozens force-pushed the feat/s08-01-freertos-bring-up branch from 55ecc38 to 5a410d0 Compare May 5, 2026 20:25
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1049 passed, 🙈 3 skipped)
   🚦   build-linux-clang: 100% successful (✔️ 998 passed, 🙈 3 skipped)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 998 passed, 🙈 3 skipped)
   🚦   integration-linux-openssl: 100% successful (✔️ 9 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 9 passed)
   🚦   bdd-linux-syslog-ng: 100% successful (✔️ 46 passed)
   🚦   bdd-windows-otel: 67% successful (✔️ 31 passed, 🙈 15 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 911 passed, 🙈 1 skipped)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: No warnings


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

@DavidCozens DavidCozens merged commit 3fdff50 into main May 5, 2026
18 checks passed
@DavidCozens DavidCozens deleted the feat/s08-01-freertos-bring-up branch May 5, 2026 20:42
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.

S08.01: FreeRTOS hello-world bring-up — QEMU mps2-an385 + GDB attach

1 participant