Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running an Linux Image (kernel 3.2.8) for beagleboard-xm on QEMU's 1.4.0 emulator Ubuntu distribution for 13.04. My image is created using Buildroot beagle_defconfig. I added some pkgs to be able to debug a little.

QEMU call cmd:

`$ sudo qemu-system-arm -M beaglexm -m 1024 -sd ./test.img -clock unix -serial stdio -device usb-mouse -device usb-kbd -serial pty -serial pty`
[sudo] password for emperador: 

char device redirected to /dev/pts/3 (label serial1)
char device redirected to /dev/pts/4 (label serial2)

What I want to do is to have a communication between guest and host across serial the 4 differents ttyO present on the guest. QEMU offer facilities to redirect the trafic to some device in the host side. My problem goes like this:

At the guest kernel boot Im able to see that my UART where enabled

[    2.682040] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    2.777947] omap_uart.0: ttyO0 at MMIO 0x4806a000 (irq = 72) is a OMAP UART0
[    2.794967] omap_uart.1: ttyO1 at MMIO 0x4806c000 (irq = 73) is a OMAP UART1
[    2.814942] omap_uart.2: ttyO2 at MMIO 0x49020000 (irq = 74) is a OMAP UART2
[    2.966825] console [ttyO2] enabled
[    2.984777] omap_uart.3: ttyO3 at MMIO 0x49042000 (irq = 80) is a OMAP UART3

In fact when I go see in to /proc/tty/driver and I do a cat on OMAP-SERIAL Im able to see this serinfo:1.0 driver revision:

0: uart:OMAP UART0 mmio:0x4806A000 irq:72 tx:0 rx:0 CTS|DSR|CD
1: uart:OMAP UART1 mmio:0x4806C000 irq:73 tx:0 rx:0 CTS|DSR|CD
2: uart:OMAP UART2 mmio:0x49020000 irq:74 tx:268 rx:37 RTS|CTS|DTR|DSR|CD
3: uart:OMAP UART3 mmio:0x49042000 irq:80 tx:0 rx:0 CTS|DSR|CD

I know that ttyO2 is working because my console is been redirected to it. The thing is that doing a set serial on any of the ttyO I get the following message:

 [root@enu driver]# setserial -a /dev/ttyO0
/dev/ttyO0, Line 0, UART: undefined, Port: 0x0000, IRQ: 72
    Baud_base: 3000000, close_delay: 50, divisor: 0
    closing_wait: 3000
    Flags: spd_normal

The same goes with ttyO2. I tried to set some settings to any of the ttyO with setserial but I always get the same message:

[root@enu ~]# setserial /dev/ttyO0 uart 8250                              
setserial: can't set serial info: Invalid argument
[root@enu ~]# setserial /dev/ttyO0 port 0x4806a000
setserial: can't set serial info: Invalid argument

While looking at guest /proc/tty/drives this is what we see

/dev/tty             /dev/tty        5       0 system:/dev/tty
/dev/console         /dev/console    5       1 system:console
/dev/ptmx            /dev/ptmx       5       2 system
/dev/vc/0            /dev/vc/0       4       0 system:vtmaster
sdio_uart            /dev/ttySDIO  249 0-7 serial
acm                  /dev/ttyACM   166 0-31 serial
ttyprintk            /dev/ttyprintk   5       3 console
OMAP-SERIAL          /dev/ttyO     253 0-3 serial
serial               /dev/ttyS       4 64-95 serial
pty_slave            /dev/pts      136 0-1048575 pty:slave
pty_master           /dev/ptm      128 0-1048575 pty:master
unknown              /dev/tty        4 1-63 console

Basically I want to establish a serial communication between a guest and a host, but the serial ports on the guest side aren't well configured.

/sys/class/tty show that tty drivers had been linked to a serial device.

has I showed up before, only omap uarts have been initialized and attached to ttyO*. notice that the console is been redirected ttyO2 by kernel configs. but because I added -serial stdio, console is been redirected to the terminal that invoked QEMU.

If I redirect the console using at first -serial pty instead of -serial stdio , I'm able to prompt the console in minicom by opening the pty created on the host side. Still nothing happen on the others pty created on the host side to communicate across other ports.

On host side I open /dev/pts/3 and /dev/pts/4 with minicom or by doing cat on them

On guest side:

Whent I do echo "test" > /dev/ttyO0 or 1 or 3 nothing. but when I do it on ttyO2, "test" prompt on the console terminal (which is normal).

now when using any of the ttyS:

echo "test" > /dev/ttyS0

I get

-bash: echo: write error: Input/output error

I made some research about this error and what I found is that is could be many things. But one thing that I noticed was that no device beside serial has been assigned to ttyS. and looking at /proc/tty/driver/serial we see this :

serinfo:1.0 driver revision:
0: uart:unknown port:00000000 irq:0
1: uart:unknown port:00000000 irq:0
2: uart:unknown port:00000000 irq:0
3: uart:unknown port:00000000 irq:0

also setserial -a /dev/ttyS0 confrim this:

/dev/ttyS0, Line 0, UART: unknown, Port: 0x0000, IRQ: 0
    Baud_base: 0, close_delay: 50, divisor: 0
    closing_wait: 3000
    Flags: spd_normal

I managed to do serial communication with muliples ports usig grml image on a x86 architecture. So its seems the host side is fine.

If anyone have ever made something like this work before on QEMU -M beaglexm or any other ARM architecture, I would gladly take any details on the VM used, QEMU's version and distribution as well as the kernel details and image configs used.

share|improve this question
    
Could it be that you only need to adjust baudrate? IRQ and uart seems to be automatically detected. What is the result of setserial -v /dev/ttyO0 autoconfig? How do you test if it works or not and how do you call qemu (the problem could also be on the host side)? –  jofel Jun 7 '13 at 7:11
    
Command used to call qemu: –  user40643 Jun 9 '13 at 22:57
    
Command used to call qemu: [sudo qemu-system-arm -M beaglexm -m 1024 -sd ./test.img -clock unix -serial stdio -device usb-mouse -device usb-kbd -chardev tty,id=mytty,path=/dev/ttyS0] I read qemu's forum's and the -chardev argument was the one proposed by people trying to do the same and qemu,s manual says it connect to a local tty device. So I just open minicom on host and do [echo "test" > /dev/ttyO0]. stty -F /dev/ttyO0 show up baud rate is 9600 and host ttyS0 is also set the same. [setserial -v /dev/ttyO0 autoconfig setserial: can't set serial info: Invalid argument] –  user40643 Jun 9 '13 at 23:09

2 Answers 2

The problem is on the host side:

You should use Pseudo-terminals (-serial pty) instead of connecting to "real" char-devices (-chardev tty,...).

qemu displays the pty /dev/pts/xx which it actually uses. You can now use this pty as a normal serial port from your host.

You can repeat this option to get more ptys connected to /dev/ttyS[0-*] on the guest (if you use -serial stdio, it is /dev/ttyS0 on the guest, the first pty is then /dev/ttyS1).

share|improve this answer
    
Hi jofel and thank you for taking time to look at my post. Plz coould you take a look at the last piece of information that I just added to the issue? Plus, If you have already make this work before for more than just one serial port. Could you give me details on for what VM you made this worked and also kernel used with configs, QEMU version and distribution as well. Thank you so much. –  user40643 Jun 11 '13 at 3:39
    
It should be /dev/ttyO* on your guest, not /dev/ttyS* - sorry for the mistake in my answer (with x86-guests, it would be /dev/ttyS* and works out-of-the-box). –  jofel Jun 11 '13 at 7:35
    
could you give me more details on the QEMU version and distribution used as also the kernel. I would like to try it my self in a known working environement. Thank you. –  user40643 Jun 11 '13 at 10:52
    
Also I would like to add that I'm using a buildroot defconfig for beaglexm to create my uImage. –  user40643 Jun 11 '13 at 11:11
1  
As long as the devices are automatically created /dev/ and have the correct permissions, udev should be fine. More probably is, that there is a bug/missing support in the (customized) qemu-version of linode which you uses. –  jofel Jun 14 '13 at 9:45
up vote 0 down vote accepted

I found what my problem was, QEMU ins't mapping the serial chardev of any extra -serial pty.

After doing the this Invoke command:

sudo qemu-system-arm -M beaglexm -m 1024 -sd ./test.img -clonix -serial stdio -device usb-mouse -device usb-kbd -serial pty -serial pty -monitor pty
char device redirected to /dev/pts/5 (label compat_monitor0)
char device redirected to /dev/pts/7 (label serial1)
char device redirected to /dev/pts/10 (label serial2)

We can see that 2 extra serials where created with the label serial 1 and 2. But if I look at the tree info

 (qemu) info qtree

dev: omap_uart, id "uart4"
    revision = 82
    mmio_size = 4096
    baudrate = 812500
    chardev = uart4
    irq 3
    mmio 0000000049042000/0000000000001000
  dev: omap_uart, id "uart3"
    revision = 82
    mmio_size = 4096
    baudrate = 812500
    chardev = serial0
    irq 3
    mmio 0000000049020000/0000000000001000
  dev: omap_uart, id "uart2"
    revision = 82
    mmio_size = 4096
    baudrate = 812500
    chardev = uart2
    irq 3
    mmio 000000004806c000/0000000000001000
  dev: omap_uart, id "uart1"
    revision = 82
    mmio_size = 4096
    baudrate = 812500
    chardev = uart1
    irq 3
    mmio 000000004806a000/0000000000001000

We clearly see that just the label serial0 was attached to a uart (the one setted to be the console). The other labels (serial1 and serial2) are no where to be found.

With the working image of grml that jofel was realy nice to tell me we see this:

  dev: i440FX-pcihost, id ""
    irq 0
    bus: pci.0
      type PCI
      dev: PIIX3, id ""
        addr = 01.0
        romfile = <null>
        rombar = 1
        multifunction = on
        command_serr_enable = on
        class ISA bridge, addr 00:01.0, pci id 8086:7000 (sub 1af4:1100)
        bus: isa.0
          type ISA
          dev: isa-serial, id ""
            index = 2
            iobase = 0x3e8
            irq = 4
            chardev = serial2
            wakeup = 0
            isa irq 4
          dev: isa-serial, id ""
            index = 1
            iobase = 0x2f8
            irq = 3
            chardev = serial1
            wakeup = 0
            isa irq 3
          dev: isa-serial, id ""
            index = 0
            iobase = 0x3f8
            irq = 4
            chardev = serial0
            wakeup = 0
            isa irq 4

all 3 serial lebels were attached to a chardev.

Now I just have to ask a new question about how making QEMU to link those lables to my beagleboard uarts.

Also I would like to add I think that setserial did not outputed any info about ttyO's because it doesn't support omap uarts. setserial ? shows what devices are supported. In the case of the ttyS's, I think its because the tty drivers are installed but there is no other type of uarts bisede omap uarts emulated for bealgeboard in QEMU.

Thanks alot for everyone that took a look on this question and specialy jofel.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.