VirtualBox

Opened 4 years ago

Closed 3 years ago

#19889 closed defect (fixed)

Serial ports (uart) don't work on VB 6.1.10, 6.1.12 and 6.1.14

Reported by: parsival Owned by:
Component: uart Version: VirtualBox 6.1.14
Keywords: serial port uart Cc:
Guest type: Windows Host type: Linux

Description

Serial ports (uart) don't work on VB 6.1.10 and 6.1.14

Host: Debian GNU/Linux 10, buster, Kernel 4.19.0, ttyS0 native on motherboard (uart 16550A), ttyS1 and ttyS3 on a PCIe card (uart 16650V2)

Guest: Win XP SP3

Virtual Box 6.1.10 or 6.1.14 does not work. Opening a connection to serial ports from guest freezes (via ttyS0) the virtual machine or stops the application (via ttyS1) with a SerialIOportError. The cable and the serial ports were tested under a non virtual Windows 10 without any problems.

Serial ports doesn't work at all on VB 6.1.10, 6.1.12 and 6.1.14 for me.

Attachments (8)

VBox.log (133.6 KB ) - added by parsival 4 years ago.
lspci_output (8.8 KB ) - added by parsival 4 years ago.
arcp2000-led_out.jpeg (250.0 KB ) - added by parsival 4 years ago.
arcp2000-led_on.jpeg (250.3 KB ) - added by parsival 4 years ago.
VBox.log-17102020 (133.8 KB ) - added by parsival 4 years ago.
SerialTrace (170.0 KB ) - added by parsival 4 years ago.
serial-strace.log (67.2 KB ) - added by parsival 3 years ago.
VBox24102020.log (134.9 KB ) - added by parsival 3 years ago.

Download all attachments as: .zip

Change History (27)

by parsival, 4 years ago

Attachment: VBox.log added

comment:1 by aeichner, 4 years ago

Does the hosts kernel log (dmesg) contain anything related to serial ports? What happens if you move everything to the hosts ttyS0, do you still get the error or does it work? What kind of PCIe card are you using exactly?

comment:2 by KRML, 4 years ago

I have experience similar problems with 6.1.4 and 6.1.14 using:

  • motherboard ttyS0 (16550A)
  • PCIe card ttyS2 and ttys3 (Startech PEX2S952LP - 16950 UART)
  • USB serial adapter (FTDI)

Two VMs connected using null modem cable (cable/ports tested and working on CentOS 7.5 host)

Version 6.1.4 did not output an error message but 6.1.14 provided the following when opening/closing ports or unplugging the null modem cable:

The host serial port "/dev/ttyS0" encountered a fatal error and stopped functioning. This can be caused by bad cabling or USB to serial converters being unplugged by accident. To restart I/O transfer suspend and resume the VM after fixing the underlying issue..

Error ID: SerialPortIOError Severity: Warning

After experiencing the problem ran dmesg | grep ttyS with no obvious errors reported.

by parsival, 4 years ago

Attachment: lspci_output added

in reply to:  2 comment:3 by parsival, 4 years ago

Sorry for the long time you waited for my answer.

Output of dmesg | grep ttyS listed:

[ 1.095039] 00:01: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A [ 1.116437] 0000:01:00.0: ttyS1 at I/O 0xe010 (irq = 16, base_baud = 115200) is a ST16650V2 [ 1.137548] 0000:01:00.1: ttyS2 at I/O 0xe000 (irq = 17, base_baud = 115200) is a ST16650V2

It doen't matter if I change the ttyS*. I got always the same error:

The host serial port "/dev/ttyS0" encountered a fatal error and stopped functioning. This can be caused by bad cabling or USB to serial converters being unplugged by accident. To restart I/O transfer suspend and resume the VM after fixing the underlying issue..

Error ID: SerialPortIOError Severity: Warning

My PCIe card is a Syba SD-PEX15022

I have tested the serial ports with a loopback adapter:

cat /dev/ttyS0 echo "filename" > /dev/ttyS0

All word fine

Perhaps KRML can tell me where to get Debianpackages for download. On me todo list is to investigate the ttyS* with a serial port monitor. I try to attach the output of the lspci -v command.

comment:4 by aeichner, 4 years ago

Nothing like that reproducible here locally unfortunately. The log by the OP shows that even setting the serial parameters fails with EIO which is very unusual. Is there anything special about the null modem connection, like are you trying to use hardware flow control, etc.? Can you describe step by step what the setup looks like and what kind of applications you are using to trigger that error? We also need a special trace from the serial operations which can be enabled with the following commands:

VBoxManage setextradata <VM name> "VBoxInternal/PDM/DriverTransformations/SerialTrace/AboveDriver"                         "Host Serial"
VBoxManage setextradata <VM name> "VBoxInternal/PDM/DriverTransformations/SerialTrace/AttachedDriver/Config/TraceFilePath" "<trace/log/file/path>"
VBoxManage setextradata <VM name> "VBoxInternal/PDM/DriverTransformations/SerialTrace/AttachedDriver/Driver"               "IfTrace"

<VM name> needs to be changed to the VM name you are using and <trace/log/file/path> needs to point to a writeable location (including filename which should not exist already). Also make sure that the VM has only one host serial attachment or starting the VM with the above config will fail. We also need a VBox.log from the run which created the trace file.

comment:5 by parsival, 4 years ago

Application: ARCP2000 from Kenwood Device: TS2000, Kenwood, serial settings: 9600,8,1,N,rts/cts

The Applikation is used to control my hamradio transceiver TS2000 from Kenwood with CAT (Computer aidet tuning) commands.

  1. Testing ttyS0 without any configuration

To test my ttyS0 I don't use a null modem connection. It is a normal RS232 cable. On one side of the cable is the ttyS0 on the other side is a loopback adapter plugged in. I'm opening two seperate terminal windows. In one I am typing

cat /dev/ttyS0

and in the other

echo "filename" > /dev/ttyS0.

I am seeing the tx and rx out- and input at the same time. There is no flow control at this time. All worked fine.

  1. Test with minicom

The configuration from minicom is done with following settings: 9600,8,1,N,rts/cts. The connection to the TS2000 works well.

  1. Configuration

The configuration is done with two commands, one with root permissions and the other with user permissions:

sudo setserial /dev/ttyS0 uart 16550A port 0x03f8 irq 4 base_baudrate 115200 divisor 12 skip_test spd_cust sudo setserial /dev/ttyS1 uart none sudo setserial /dev/ttyS1 uart none stty -F /dev/ttyS0 raw -parity -cstopb crtscts

  1. Running virtualbox, win xp and arcp2000

Starting a virtual xp and arcp2000: I had to push the "con" button; when the led in this button burns yellow, then I push the "power" button to switch on the TS2000. Soon after this action I got the wellknown error.

After collecting the infos and files I am going to post the results here.

by parsival, 4 years ago

Attachment: arcp2000-led_out.jpeg added

by parsival, 4 years ago

Attachment: arcp2000-led_on.jpeg added

comment:6 by tfmeier, 4 years ago

I can confirm this issue. My setup is as follows:

  • Host = Fedora
  • Guest = Home Assistant (HassOS)
  • Serial device connected to /dev/ttyS0 (on motherboard)

Enabling /dev/ttyS0 on VB5.x works without any issues. Doing the same on VB6.1 throws the error

The host serial port "/dev/ttyS0" encountered a fatal error and stopped functioning.
This can be caused by bad cabling or USB to serial converters being unplugged by accident.
To restart I/O transfer suspend and resume the VM after fixing the underlying issue..
Last edited 4 years ago by tfmeier (previous) (diff)

comment:7 by parsival, 4 years ago

I uploaded two files: VBox.log-17102020 and SerialTrace. The last run of virtualbox produced the same error and message.

by parsival, 4 years ago

Attachment: VBox.log-17102020 added

by parsival, 4 years ago

Attachment: SerialTrace added

comment:8 by aeichner, 4 years ago

Thanks for the new logs, unfortunately the trace doesn't show anything which could explain the error. To be able to continue investigation I'd need an strace log of the serial port operations of the VM and a new matching set of trace logs and VBox.log. This can be achieved by doing the following:

  • Start the VM and pause it immediately
  • Execute the following command. It should produce two matches, note down the two numbers in the first colum:
    ps axH -o 'tid comm' |grep -E 'SerIo|IPRT-SerPortMon'
     <tid1> IPRT-SerPortMon
     <tid2> SerIo
    
  • Execute the following command replacing the numbers with the output from the previous command:
    sudo strace -s 4096 -v -p <tid1> -p <tid2> -o serial-strace.log
    
  • Resume VM and execute steps necessary to reproduce the error
  • Stop the VM and kill the strace
  • Attach new set of logs, you can also send everything to alexander (dot) eichner (at) oracle (dot) com directly if you don't want to attach them here or in case they get too big.

Thanks!

in reply to:  6 comment:9 by pv32768, 3 years ago

I had the same error in VB 6.1.16.

The host serial port "/dev/ttyS0" encountered a fatal error and stopped functioning.


After VB, stty -a -F /dev/ttyS0 outputs -clocal.


I fixed it by:

--- /var/tmp/portage/app-emulation/virtualbox-6.1.16/work/VirtualBox-6.1.16/src/VBox/Runtime/r3/posix/serialport-posix.cpp
+++ /var/tmp/portage/app-emulation1/virtualbox-6.1.16/work/VirtualBox-6.1.16/src/VBox/Runtime/r3/posix/serialport-posix.cpp
@@ -470,6 +470,8 @@
         tcflag_t const fCFlagMask = (CS5 | CS6 | CS7 | CS8 | CSTOPB | PARENB | PARODD | CMSPAR);
         tcflag_t fCFlagNew = 0;
 
+        fCFlagNew |= CLOCAL;
+
         switch (pCfg->enmDataBitCount)
         {
             case RTSERIALPORTDATABITS_5BITS:

comment:10 by parsival, 3 years ago

Since now I don't have tested the posted workaround.

For about three years I had running VB under Debian 9 (called stretch) witch worked well with my serial ports. This version of VB was from the 5.x.x branch; perhaps it was 5.1.28 or 5.2.20. This version isn't installable under Debian 10 (buster) because of the VB kernel modules. Were the differences in the source code of the serial ports between the branches 5.x.x and 6.x.x big?

by parsival, 3 years ago

Attachment: serial-strace.log added

by parsival, 3 years ago

Attachment: VBox24102020.log added

comment:11 by pv32768, 3 years ago

VB 6.1.18 - without changes: cleared CLOCAL flag + noise on unconnected DCD line -> hangup state in Linux driver -> VB serial port fatal error.

comment:12 by ScannerDev, 3 years ago

Ran into this problem on 6.1.16 and installed 6.1.18 r142142 this morning. Still get the issue. FWIW, same guest OS; host is Mint Tricia 19.3. The guest VM in question has a number of radio-control programs installed; these all use serial ports to communicate with attached hardware. Upon communication being initiated to any attached device, the error referenced in the original posting will display.

In my case, the problem is extremely easy to reproduce: Connect a serial cable to the host's physical COM ports, jumper pins 2 and 3 then start VirtualBox and the guest XP-SP3 VM. As soon as the guest's various device drivers begin to initialize you'll get the SerialIOportError. /dev/ttyS0 is an onboard port (Intel motherboard) while /dev/ttyS4 through S7 are part of a PCIe 4-port add-in card. Doesn't matter which physical hardware is used; results are the same.

If I use the "screen" utility within the host OS and open the ports with the loopback cable installed, characters can be echoed without an issue. Similarly, setserial was empirically used to change UART type - to no effect when the guest is started.

Older (DOS-based, Win 3.11) guest platforms will use the serial port successfully for several hours but eventually will lock up and require the VM to be force closed.

ETA:

Tried this with a Win98SE and an Ubuntu 18.04 guest - if the serial port driver is present in the guest OS and VirtualBox has assigned the host's resources accordingly, the guest will produce the error upon startup. No serial port driver or resources not being assigned via VirtualBox Settings Manager results in a clean guest boot.

Last edited 3 years ago by ScannerDev (previous) (diff)

comment:13 by parsival, 3 years ago

During the last weeks I was searching for a VB version as a amd64 package, that works with my application ARCP2000, the serial ports and Debian 10. In the Debian 9-Repo I found VB 5.2.24 as 64-bit software. She was working fine, but requiered a downgrade of some packages and my Debian 10 remained back with 56 broken packages. For me it's not usable. I need not only clocal, crtscts is needed too.

What must be done, that this patch, I hope he works for me too - I am not a programmer, will find a permanently entry in the source code?

comment:14 by aeichner, 3 years ago

Please try the latest testbuild from here, it includes the fix mentioned in comment 9 (thanks a lot for spotting this!).

comment:15 by ScannerDev, 3 years ago

Installed and tested the 142946 build over the last couple of days. At the moment I have a Win10-Pro VM with two serial ports and an XP-SP3 VM with one port that are concurrently controlling three serial devices (radio scanners). The Win10 VM ports are running at 19.2K and the XP VM's port is at 9.6K. These are putting a lot of traffic through the COM ports and thus far, all is well. Will continue to monitor and report if anything amiss is observed. Thank you to whomever finally fixed this - you've cured a big headache.

comment:16 by parsival, 3 years ago

Yesterday I tried the early testing version of VB. In a few words: She don't works together with the software ARCP2000, the Kenwood transceiver TS2000 and the serial ports. My software can't connect to the TS2000 via /dev/ttyS1; the screen remains black. From VB I have got no error messages.

What now?

I put a serial-port-tester between the two RS232 ports (PC and transceiver). When I switch the power at my TS2000 on, the LEDs of the RTS and CTS pins went from undefined (black) to low (red).

Which options offers the "flag" fCFlagNew? Perhaps someone could please explain me that.

Thanks

comment:17 by parsival, 3 years ago

During the last days I found the reason why it didn't work: The serial PCIe card was broken. After changing the card, all was okay.

Thank your help.

comment:18 by AA, 3 years ago

Trying to boot android-x86_64 guest in VBox 6.1.18 on mac os x host with Serial Port COM1 enabled disconnected hangs the boot process. Unchecking the serial port in the virtual machine configuration allows android to boot. Without the serial port enabled, you cannot use bluetooth within android. Would be great to have this issue resolved! Unfortunately, I cannot access any logs because the hang happens very early in the boot process.

UPDATE: I tried this using test build 143777 and android can now boot.

Last edited 3 years ago by AA (previous) (diff)

comment:19 by aeichner, 3 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use