Using QEMU how to redirect serial /dev/ttyS2 output of guest machine to host machine.

Alex Bennée alex.bennee at linaro.org
Sat Mar 18 03:06:43 AEDT 2023


Abhishek Singh Dagur <abhishek at drut.io> writes:

(cc aspeed maintainers)

> Hi all,
>
> We are using obmc-phosphor-image on an ast2500 board which is trying to communicate with other devices
> over serial port /dev/ttyS2.
> As we are trying to emulate the machine on qemu we need to redirect the request to the host machine so
> that it can handle this request and return appropriately.
> We tried using QEMU options like -serial ,-chardev but still not the
> concrete way we get to do it.

Yeah I'm afraid its non-obvious, certainly for built in serial ports.
Try something like:

  ./qemu-system-aarch64 -M ast2500-evb \
    -serial null -serial null -serial chardev:myserial \
    -chardev file,id=myserial,path=output.txt \
    $MORE_OPTIONS

You have to add a -serial for each serial port up to the one you care
about and then set the chardev for it.

If you where adding a device to the system then you can explicitly set
the target chardev for it with something like:

  -device isa-serial,iobase=nnn,irq=nnn,chardev=ID

> It will be very helpful if you can provide us some guidance on this.

Another quirk for the aspeed boards seems to be the default uart can be
an arbitrary one depending on the board model:

334:    aspeed_soc_uart_set_chr(s, amc->uart_default, serial_hd(0)); 
336:        if (uart == amc->uart_default) {                         
1112:    amc->uart_default = ASPEED_DEV_UART5;                       
1407:    amc->uart_default = ASPEED_DEV_UART1;                       

as a result ASPEED_DEV_UART5 will always be the first serial port
(serial_hd(0)). I don't know how Linux numbers them but worth being
aware of.

>
> Thank you,
> Abhishek


-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


More information about the openbmc mailing list