Skip to content

Add QEMU testing to CI for all Raspberry Pi configurations#6

Merged
jbltx merged 7 commits intomasterfrom
copilot/run-qemu-with-configs
Nov 12, 2025
Merged

Add QEMU testing to CI for all Raspberry Pi configurations#6
jbltx merged 7 commits intomasterfrom
copilot/run-qemu-with-configs

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

Implements QEMU testing in CI for BCM2835 (Pi 0/1), BCM2836 (Pi 2), and BCM2837 (Pi 3) to validate builds before deployment to hardware.

Changes

Makefile

  • Dynamic toolchain detection: Automatically discovers arm-none-eabi-gcc or aarch64-linux-gnu-gcc (no hardcoded paths)
  • Correct kernel naming: kernel.img (ARMv6), kernel7.img (ARMv7), kernel8.img (ARMv8) per Raspberry Pi bootloader convention
  • QEMU configuration: Per-SoC machine selection (raspi0/raspi2b/raspi3b), appropriate RAM, and serial port setup (-display none -serial stdio)
  • Dynamic libgcc resolution: Uses gcc -print-libgcc-file-name instead of hardcoded version paths

CI Workflow

  • Matrix strategy: Builds and tests all three BCM variants in parallel for faster CI execution
  • Each matrix job includes BCM-specific configuration (kernel name, Pi model, QEMU machine, memory, binary)
  • Separate job for integration tests that runs after all builds complete
  • Individual artifact uploads per BCM variant (kernel-bcm2835-kernel.img, kernel-bcm2836-kernel7.img, kernel-bcm2837-kernel8.img)
  • Security: Explicit permissions: {contents: read} on all jobs to limit GITHUB_TOKEN scope
  • Installs cross-toolchains (gcc-arm-none-eabi, gcc-aarch64-linux-gnu) and QEMU

Integration Tests

  • Fixed BCM2835 test to check for kernel.img instead of kernel7.img
  • Tests now validate correct kernel filename for each BCM variant

Boot Sequence (aarch32)

  • Simplified boot.S: Refactored to match proven reference implementation from dwelch67/raspberrypi-zero
  • Removed complex CPU mode switching (FIQ, IRQ, Abort modes)
  • Direct stack pointer initialization (sp = _start, grows downward)
  • Proper r0/r1/r2 register initialization before calling kernel_main
  • Cleaner BSS section zeroing

Known Issues

UART on 32-bit ARM: BCM2835/2836 kernels execute but produce no UART output (reproducible on real Pi Zero hardware). BCM2837 (64-bit) outputs correctly. After reviewing reference implementations and testing both PL011 UART0 and Mini UART (AUX), the issue appears to be a deeper peripheral initialization problem beyond the boot sequence, possibly related to clock initialization, GPIO configuration timing, or memory barriers specific to 32-bit ARM bare metal.

# BCM2837 works:
$ make run BCM=2837
*************** PIP-OS(R) V7.1.0.8 ***************
COPYRIGHT 2075 ROBCO IND.
...

# BCM2835/2836 execute silently (kernel runs, no crashes):
$ make run BCM=2835
[kernel loads, runs, but no output]

[!WARNING]

Original prompt

Try to run qemu with the three configs (pi 0/1, pi 2 and pi 3). the run must happen in the CI to check if everything is good after build. You will probably need to modify build/Makefile to make it work properly. Also make sure that cross-compiler GCC is found dynamically in the makefile (not hardcoded paths). If any run goes wrong, you will have to fix errors until it works properly. Verify well the boot.S for example for each arch. Making it work with Qemu will be a good first step before testing on a real Pi board.
Open a PR with theses changes.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 12, 2025 18:04
…ming

Co-authored-by: jbltx <1284323+jbltx@users.noreply.github.com>
Co-authored-by: jbltx <1284323+jbltx@users.noreply.github.com>
Co-authored-by: jbltx <1284323+jbltx@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CI process to run QEMU with multiple Pi configurations Add QEMU testing to CI for all Raspberry Pi configurations Nov 12, 2025
Copilot AI requested a review from jbltx November 12, 2025 18:28
@jbltx
Copy link
Contributor

jbltx commented Nov 12, 2025

@copilot Please review carefully others references for Pi 0 boot:

This should help reviewing and fixing boot.S file and others C files for 32-bits ARM. Qemu supports UART, so an output must happen!

Co-authored-by: jbltx <1284323+jbltx@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot Please review carefully others references for Pi 0 boot:

I've reviewed the dwelch67/raspberrypi-zero reference code and simplified the aarch32 boot.S to match that proven implementation (commit b9a1c41). Changes include:

  • Removed complex CPU mode switching
  • Simplified stack initialization (sp = _start, grows downward)
  • Proper r0/r1/r2 initialization before calling kernel_main
  • Cleaner BSS zeroing

I tested with both PL011 UART0 and Mini UART (as the reference uses). Unfortunately, BCM2835/2836 still produce no UART output in QEMU, while BCM2837 (64-bit) works perfectly with full output.

The kernels load and execute (no crashes - they run the full timeout), but UART is silent. Since this also doesn't work on real Pi Zero hardware (as you mentioned), the issue appears to be a fundamental peripheral initialization problem beyond the boot sequence, possibly related to clock initialization, GPIO configuration timing, or memory barriers specific to 32-bit ARM bare metal.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@jbltx
Copy link
Contributor

jbltx commented Nov 12, 2025

@copilot In GHA use a matrix for each build/test/run. Also you have to edit the integration test to check for kernel.img presence instead of kernel7.img for BCM2835

Co-authored-by: jbltx <1284323+jbltx@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot In GHA use a matrix for each build/test/run. Also you have to edit the integration test to check for kernel.img presence instead of kernel7.img for BCM2835

Done in commit 7801b12. Changes:

  • CI now uses a matrix strategy to build/test all three BCM variants (2835, 2836, 2837) in parallel
  • Each matrix job includes BCM-specific config: kernel name, Pi model, QEMU machine, memory, and binary
  • Integration tests moved to a separate job that runs after all builds complete
  • Fixed run_tests.sh to check for kernel.img (not kernel7.img) for BCM2835 build validation

Co-authored-by: jbltx <1284323+jbltx@users.noreply.github.com>
@jbltx jbltx marked this pull request as ready for review November 12, 2025 19:57
@jbltx jbltx merged commit 4f795c7 into master Nov 12, 2025
12 checks passed
@jbltx jbltx deleted the copilot/run-qemu-with-configs branch November 12, 2025 19:58
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.

2 participants