From 244148a8838a046859e890f94c5791f499c35ecd Mon Sep 17 00:00:00 2001 From: Stephanos Ioannidis Date: Thu, 2 Jan 2020 15:09:42 +0900 Subject: [PATCH] cmake: qemu: Use chardev for console The current QEMU console configuration directly connects the console serial port to the backend using '-serial' option. This is less than ideal because only single console instance can be connected to a backend and aggregation of multiple console outputs is not possible (e.g. multiple console serial ports and semihosting console to single console backend). In order to solve this problem, single multiplexed chardev console backend is declared and all consoles are connected to it. Signed-off-by: Stephanos Ioannidis --- cmake/emu/qemu.cmake | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/cmake/emu/qemu.cmake b/cmake/emu/qemu.cmake index 3e5a8ed0dcb..4b2cceb50fe 100644 --- a/cmake/emu/qemu.cmake +++ b/cmake/emu/qemu.cmake @@ -35,33 +35,23 @@ else() list(APPEND QEMU_FLAGS qemu${QEMU_INSTANCE}.pid) endif() -# We can set "default" value for QEMU_PTY & QEMU_PIPE on cmake invocation. +# Set up chardev for console. if(QEMU_PTY) - # Send console output to a pseudo-tty, used for running automated tests - set(CMAKE_QEMU_SERIAL0 pty) + # Redirect console to a pseudo-tty, used for running automated tests. + list(APPEND QEMU_FLAGS -chardev pty,id=con,mux=on) +elseif(QEMU_PIPE) + # Redirect console to a pipe, used for running automated tests. + list(APPEND QEMU_FLAGS -chardev pipe,id=con,mux=on,path=${QEMU_PIPE}) else() - if(QEMU_PIPE) - # Send console output to a pipe, used for running automated tests - set(CMAKE_QEMU_SERIAL0 pipe:${QEMU_PIPE}) - else() - set(CMAKE_QEMU_SERIAL0 mon:stdio) - endif() + # Redirect console to stdio, used for manual debugging. + list(APPEND QEMU_FLAGS -chardev stdio,id=con,mux=on) endif() -# But also can set QEMU_PTY & QEMU_PIPE on *make* (not cmake) invocation, -# like it was before cmake. -if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") - list(APPEND QEMU_FLAGS - -serial - \${if \${QEMU_PTY}, pty, \${if \${QEMU_PIPE}, pipe:\${QEMU_PIPE}, ${CMAKE_QEMU_SERIAL0}}} - # NB: \$ is not supported by Ninja - ) -else() - list(APPEND QEMU_FLAGS - -serial - ${CMAKE_QEMU_SERIAL0} - ) -endif() +# Connect main serial port to the console chardev. +list(APPEND QEMU_FLAGS -serial chardev:con) + +# Connect monitor to the console chardev. +list(APPEND QEMU_FLAGS -mon chardev=con,mode=readline) # Add a BT serial device when building for bluetooth, unless the # application explicitly opts out with NO_QEMU_SERIAL_BT_SERVER.