Problem to map serial port (win host linux guest)

Discussions about using Linux guests in VirtualBox.
Post Reply
maulum
Posts: 3
Joined: 5. Jan 2021, 04:18

Problem to map serial port (win host linux guest)

Post by maulum »

Hello,
I have problems to map a host serial port (Windows) into the guest serial port (Linux). Virtual box version is 6.1.16 r140961 QT 5.6.2

The host is Windows 10 and I attached a ST Microelectronics usb to serial adapter. It is mapped to COM3. I tested it in windows host and window guest and the ST serial usb adapter work flawlessly

The issue is about the setting when the guest is LInux (Ubuntu), it seems the /dev/ttyS0 is not working. As soon as virtual machine starts, and exception is raised on screen. See attachment

It seems a problem with the mapping, for some reason the slash I entered into vbox serial port configuration is modified to backslash and then Linux does not recognize it

After that, the slash is modified to backslash in the user interface of virtual box

The issue is the mapping, and no way to solve this up to now

Thanks
Attachments
screenshots of the error, usb serial adapter, and the serial port screen configuration
screenshots of the error, usb serial adapter, and the serial port screen configuration
serialporterror.jpg (70.47 KiB) Viewed 14480 times
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Problem to map serial port (win host linux guest)

Post by mpack »

Why are you using the USB panel? If the device exists on the host then why not just use the normal serial setup in the VM settings?

USB devices allow one master only. If they are in use on the host then they can't be attached to a VM. The easiest way to ensure that nothing on the host is already using a USB device is: don't plug it in until the VM is ready for it.

Or see the first para.
Martin
Volunteer
Posts: 2560
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: Problem to map serial port (win host linux guest)

Post by Martin »

The "device path" field is for the host address of the serial port, in your case "COM3".
Windows doesn't have a "/dev/ttyS0" ;)
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Problem to map serial port (win host linux guest)

Post by mpack »

I think we need to clarify whether this serial port is being grabbed as a host RS232 serial port, or as a USB device (and if the latter, why). I don't know what the first picture shows (as Martin says, it appears to show a Linux device name being displayed in a Windows error dialog). The second picture clearly shows the USB panel.

Worst case would be setting it up both ways, that would definitely cause lots of confusion.
maulum
Posts: 3
Joined: 5. Jan 2021, 04:18

Re: Problem to map serial port (win host linux guest)

Post by maulum »

Hello,
let me recap. I just add the usb panel for completion but I removed the usb from it and the problem is the same.
What I need to do is to map a serial port in windows host (com3 native at hardware) into a linux serial port
If I complete the serial port setting as in the last attachment I dont get the error in the early stage of booting
but the port is not seen in linux
What I need is the recipe what I need to enter in this dialog
Attachments
this setting does not throw an error but linux dont see the port
this setting does not throw an error but linux dont see the port
serialportsetting.jpg (56.22 KiB) Viewed 14455 times
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Problem to map serial port (win host linux guest)

Post by mpack »

For future reference, all modern Windows installs includes the "Snipping tool" (use Start menu to find it) which allows you to select a rectangle anywhere on the screen and it will save the contents as a crystal clear PNG, so there's no need for fuzzy screenshots taken with a camera.


Why are you configuring the virtual port to work as COM3? Please set it back to COM1, and don't forget to reset the I/O port to 0x3F8. You need to understand that what the guest OS calls a VIRTUAL port has nothing to do with what the host calls the physical port.
p.s. Since you configured this port to appear as COM3(ttyS2) in the VM there would be no way you could access it on COM1(ttyS0). However you will be able to do so after correcting the bad config.

I see you also chose "COM3" as the host device name. This may well be correct, but I'd want to see some evidence of that, e.g. a screenshot of the (opened) "Ports (COM & LPT)" branch of the host device manager.
maulum
Posts: 3
Joined: 5. Jan 2021, 04:18

Re: Problem to map serial port (win host linux guest)

Post by maulum »

Hello
just to understand the dialog structure:

the fields PORT NUMBER and PORT MODE is how the linux guest will see the serial port

the field Path/address is the physical one that is linked to the windows host and therefore the actual serial port

My mistake was not to fully understand what part is the host and what the guest in this dialog

Ill set to COM1 in the PORT NUMBER then to map it as ttyS0 in linux

regards
m
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Problem to map serial port (win host linux guest)

Post by mpack »

It's the same with all virtual hardware, e.g. the disk drive which you call "C:" inside a Windows guest has nothing to do with the actual drive C: of your Windows host.

Or even more similar to CD drives: as usual the guest OS can apply any label it likes to its CD drive, this has nothing to do with what the host OS calls any of its drives. However, if you want to map the virtual CD drive to a host physical CD drive then you need some way to indicate which host drive you mean.

Serial ports can be left unmapped, or mapped to a physical host serial device, or a host pipe. It make no difference to what hardware the guest OS sees.
Eric L
Posts: 4
Joined: 24. May 2021, 02:49

Re: Problem to map serial port (win host linux guest)

Post by Eric L »

Search and find this discussion. I have a similar but a little different issue, so instead of create a separate one, update this with my addition.

Host: Windows 10
Guest: CentOS Linux
VBox: 6.1
USB-Serial adapter: Prolific USB-to-Serial converter
Port of USB-Serial converter on Windows 10
Port of USB-Serial converter on Windows 10
Windows10_COM3_USB_Serial_Convert.JPG (12.07 KiB) Viewed 14151 times
VBox Serial port configuration
VBox Serial port setup
VBox Serial port setup
VBox_Serial_Setup.JPG (52.42 KiB) Viewed 14151 times
As this serial port seen on Windows host is USB-Serial converter, I expect to see /dev/ttyUSB* on Linux guest. but it does not shown.
My understand is /dev/ttyS* are for physical comport.

Thanks if someone could point out anything I missed.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Problem to map serial port (win host linux guest)

Post by mpack »

Eric L wrote: As this serial port seen on Windows host is USB-Serial converter, I expect to see /dev/ttyUSB* on Linux guest. but it does not shown.
My understand is /dev/ttyS* are for physical comport.

Thanks if someone could point out anything I missed.
The guest OS only sees USB devices if they are connected to the virtual USB controller.

It does not matter whether actual host devices are or aren't connected to host USB. The VM doesn't care how a host device is connected to the host so, as configured the guest will see ttys0.

I really don't understand why people have trouble with this. The VM is a separate PC. It doesn't see or know anything about the host hardware except the CPU. It doesn't need to know that. It only sees virtual devices that you describe in the VM settings. That's why the VM sees an Intel Ethernet card, even when the host has RealTek WiFi. It's why the VM doesn't see your host's NVidia graphics, or the host disk drives - or any other host hardware!
Eric L
Posts: 4
Joined: 24. May 2021, 02:49

Re: Problem to map serial port (win host linux guest)

Post by Eric L »

Thanks for reply.

I am kind of new to virtualbox, so the confusion I made.

Ok, the serial port's configuration is not changed, it is supposed to be mapped to /dev/ttyS0, as you mentioned.

I would like to verify if the mapping works.

Using minicom -s to configure serial port as /dev/ttyS0:
ttyS0_config_onGuest.JPG
ttyS0_config_onGuest.JPG (25.09 KiB) Viewed 14095 times
I also verify that I am in dialout group (in /etc/group)

Then I connect tx/rx of the cable to loop-back

start two terminals on Guest,
on terminal 1: cat /dev/ttyS0
on terminal 2: echo "test" > /dev/ttyS0

I expect that "test" will be shown on terminal 1, but nothing.

Is there a way to test the serial port on Guest?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Problem to map serial port (win host linux guest)

Post by mpack »

This is not the place to give you CentOS tuition, even if I knew anything about CentOS! However the obvious way to test a serial port would be to use a configuration and software that you know works to talk to a serial device that you know works.

But plenty of people use the VirtualBox serial devices, so I'm not sure what you'd be proving. As with all RS232 I/O, just make sure that both ends are set up with correct serial parameters. Don't configure flow control for your initial tests - and even in the long term that will probably be unreliable in a VM. I would leave that turned off and rely on the host to provide buffered comms.

p.s. Using some kind of control panel app to globally configure the serial port is likely to be nonsense IMO. That config would probably only apply to OS use of the port for shell redirection and the like. Any serial app will configure the port to its own needs.
Eric L
Posts: 4
Joined: 24. May 2021, 02:49

Re: Problem to map serial port (win host linux guest)

Post by Eric L »

Update,

The cat/echo on /dev/ttyS0 does work :D It could be the connection issue last time.
I see "test" continually printed on output terminal. That is not a problem.
mpack wrote:I'm not sure what you'd be proving.

I was doing thing step by step and want to verify each step. Try to avoid the situation where all steps are completed when see things not working and not know at which step is the cause.

Thanks again for helping out!
Eric L
Posts: 4
Joined: 24. May 2021, 02:49

Re: Problem to map serial port (win host linux guest)

Post by Eric L »

This second update is to further clarify previous confusion if it did.

I find that my USB-Serial converter does get recognized by CentOS guest, which shown under:
Devices->USB->myUSB-Serial-Converter.
By click it, it is mapped to /dev/ttyUSB0 in my case.
$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 May 31 00:55 /dev/ttyUSB0

Previous Serial Ports config in VirtualBox Setting is not needed for me.
Actually, it only cause problem, sometimes guest does not start with that enabled.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Problem to map serial port (win host linux guest)

Post by scottgus1 »

When passing a USB device into the VM, the VM OS handles the device, not the host. So the serial port is being made directly inside the VM instead of hooking into a host serial port.

Glad you're up and running!
Post Reply