Skip to content

Conversation

@ritesh006
Copy link
Contributor

This PR introduces a Python-based QEMU runner (scripts/west_commands/runners/qemu.py)
as part of the effort to deprecate the legacy cmake/emu/qemu.cmake.

Key points:

  • Implements a ZephyrBinaryRunner subclass for QEMU
  • Supports --qemu-binary, --qemu-arg, and serial backends (stdio, fifo, pty)
  • Provides RunnerCaps(run=True) for consistent west run integration
  • Cleans up temporary FIFOs safely after execution
  • Adds a deprecation shim in cmake/emu/qemu.cmake

Tested on:

  • qemu_x86 board running samples/hello_world (successful boot and output)
  • Zephyr SDK 0.16.x with QEMU 8.2.2

This addresses part of zephyrproject-rtos/zephyr#5501
and sets the foundation for full migration from CMake to Python-based QEMU runner.

@pdgendt
Copy link
Contributor

pdgendt commented Nov 12, 2025

Please fix compliance and CI issues, also since you considerately modified the file, remove it from the ruff excludes file and format it using ruff.

"./scripts/west_commands/runners/qemu.py",

@ritesh006
Copy link
Contributor Author

Please fix compliance and CI issues, also since you considerately modified the file, remove it from the ruff excludes file and format it using ruff.

"./scripts/west_commands/runners/qemu.py",

please take a look

@ritesh006 ritesh006 force-pushed the feat/qemu-runner-starter branch from d4d7316 to a8e0305 Compare November 16, 2025 13:42
list(APPEND QEMU_FLAGS
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=on
-rtc clock=vm)
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=on
Copy link
Contributor

Choose a reason for hiding this comment

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

these changes are not valid with this alignment

@ritesh006 ritesh006 force-pushed the feat/qemu-runner-starter branch 2 times, most recently from 044ccd6 to 45995c3 Compare December 7, 2025 15:49
@ritesh006 ritesh006 force-pushed the feat/qemu-runner-starter branch from 45995c3 to 26b0e4c Compare December 7, 2025 15:49
- Add scripts/west_commands/runners/qemu.py: starter
  ZephyrBinaryRunner for QEMU.
- Add cmake/emu/qemu.cmake shim that warns about deprecation.
- Add short note doc/contrib/qemu_runner_note.rst.

Fixes: zephyrproject-rtos#5501

Signed-off-by: Ritesh Kudkelwar <[email protected]>
@ritesh006 ritesh006 force-pushed the feat/qemu-runner-starter branch from 26b0e4c to 31b7a63 Compare December 7, 2025 16:02
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 7, 2025

Please retry analysis of this Pull-Request directly on SonarQube Cloud

Comment on lines +77 to +80
if not qemu_bin or not shutil.which(qemu_bin):
raise RuntimeError(
"QEMU binary not found: set --qemu-binary or install qemu-system-* on PATH"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use self.require(qemu_bin) instead?


class QemuBinaryRunner(ZephyrBinaryRunner):
'''Place-holder for QEMU runner customizations.'''
log = logging.getLogger(__name__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Runners already have a logger, as self.logger.

Comment on lines +130 to +140
def _platform_defaults(self):
# Minimal defaults. Extend per-board: memory, machine type etc.
# For common x86 qemu_x86: use -M pc -m 512M -nographic
board = (self.cfg.board or "").lower() if hasattr(self.cfg, "board") else ""
if "qemu_x86" in board or "qemu_x86" in str(self.cfg.board_dir):
return ["-M", "pc", "-m", "512", "-nographic"]
# cortex-m3 qemu example:
if "cortex_m3" in board or "qemu_cortex_m3" in str(self.cfg.board_dir):
return ["-M", "lm3s6965evb", "-nographic"]
# fall back to minimal no-graphic
return ["-nographic"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be done here, but instead passed as arguments from the boards. Search board_runner_args for examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants