fix(tools/idf-qemu): Add qemu_extra_args after monitor stdio -serial

This commit is contained in:
Rohan Fletcher
2025-05-17 17:00:53 +12:00
parent f9765d0316
commit 15e8d43468

View File

@@ -5,6 +5,7 @@ import binascii
import fnmatch
import json
import os
import shlex
import shutil
import socket
import subprocess
@@ -279,9 +280,6 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
if options.wait_for_gdb or gdb:
qemu_args += ['-gdb', f'tcp::{QEMU_PORT_GDB}', '-S']
if qemu_extra_args:
qemu_args += qemu_extra_args.split(' ')
if graphics:
qemu_args += ['-display', 'sdl']
else:
@@ -293,6 +291,12 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
# Launch QEMU!
if not options.bg_mode:
qemu_args += ['-serial', 'mon:stdio']
# Adding qemu_extra_args at the end ensures the monitor is the
# primary serial port if another -serial argument is present.
if qemu_extra_args:
qemu_args += shlex.split(qemu_extra_args)
yellow_print('Running qemu (fg): ' + ' '.join(qemu_args))
subprocess.run(qemu_args)
else:
@@ -301,6 +305,11 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
else:
qemu_args += ['-serial', f'tcp::{QEMU_PORT_SERIAL},server,nowait']
# Adding qemu_extra_args at the end ensures the monitor is the
# primary serial port if another -serial argument is present.
if qemu_extra_args:
qemu_args += shlex.split(qemu_extra_args)
yellow_print('Running qemu (bg): ' + ' '.join(qemu_args))
qemu_proc = subprocess.Popen(qemu_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
wait_for_socket(QEMU_PORT_SERIAL)