Skip to content

Commit 84c26c2

Browse files
authored
Merge pull request #10 from openmv/qemu_support
backends: Add Qemu support.
2 parents 49fd3d9 + df20c18 commit 84c26c2

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A simple CLI tool that starts a GDB server and automatically attaches GDB to deb
44

55
## ✨ Features
66

7-
- 🔌 **Multiple backends** - Supports J-Link and ST-Link debug probes
7+
- 🔌 **Multiple backends** - Supports J-Link, ST-Link, and QEMU
88
- 🔍 **Auto-discovery** - Automatically finds STM32CubeProgrammer installation
99
- 🧹 **Clean lifecycle** - Starts the server, attaches GDB, and cleans up when done
1010
- ⚙️ **Configurable** - JSON-based backend configuration for easy customization
@@ -25,6 +25,7 @@ gdbrunner <backend> [options] elf
2525

2626
- `jlink` - J-Link GDB server
2727
- `stlink` - ST-Link GDB server
28+
- `qemu` - QEMU ARM emulator
2829

2930
### Examples
3031

@@ -40,6 +41,9 @@ gdbrunner jlink --device STM32H743VI --dryrun firmware.elf
4041

4142
# 📺 Show server output for debugging connection issues
4243
gdbrunner stlink --show-output firmware.elf
44+
45+
# 🖥️ Start QEMU and attach GDB
46+
gdbrunner qemu --machine mps2-an500 firmware.elf
4347
```
4448

4549
Run `gdbrunner --help` for all options.

src/gdbrunner/backends.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2+
"qemu": {
3+
"command": "qemu-system-arm",
4+
"fixed_args": ["-nographic", "-monitor", "null", "-semihosting", "-S", "-serial", "pty"],
5+
"elf_arg": "-kernel",
6+
"arguments": [
7+
{"flag": "--machine", "cmd": "-machine", "required": true, "help": "QEMU machine type (e.g., mps2-an500, mps3-an547)"},
8+
{"flag": "--port", "cmd": "-gdb", "prefix": "tcp::", "type": "int", "default": 1234, "help": "GDB server port (default: 1234)"}
9+
]
10+
},
211
"jlink": {
312
"command": "JLinkGDBServer",
413
"fixed_args": ["-nogui", "1"],

src/gdbrunner/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ def build_command(config, args):
8989
if value:
9090
cmd.append(arg["cmd"])
9191
else:
92-
cmd.extend([arg["cmd"], str(value)])
92+
prefix = arg.get("prefix", "")
93+
cmd.extend([arg["cmd"], f"{prefix}{value}"])
94+
95+
# Add ELF file if backend requires it (e.g., QEMU uses -kernel)
96+
if "elf_arg" in config:
97+
cmd.extend([config["elf_arg"], args.elf])
9398

9499
return cmd
95100

0 commit comments

Comments
 (0)