[Troubleshooting] The Linux virtual machine cannot recognize the serial port and ttyUSB

Virtual machine serial port connection failure problem


My little brother's Linux system is installed on a virtual machine. Recently, I just need to use a serial port to communicate with Linux. After connecting the hardware, I found that the serial port cannot be found on the virtual machine.

After querying, it was found that the system started by the virtual machine cannot use the serial port for communication under normal circumstances, and the following configuration is required.


1. When the virtual machine is in the shutdown state, open the settings (it cannot be set in the non-shutdown state)

insert image description here

2. Click [Add], select [Serial Port], and click [Finish]

insert image description here


3. Check [Connect at startup], select [Use physical serial port], the port number corresponds to the port number recognized on the Windows system, and then click [OK]

The COM option is not occupied. For example, I chose COM3 and 4 before, but later found that it was occupied by Bluetooth, so after turning off Bluetooth, it will be fine to connect again.

insert image description here

4. After the setting is completed, the port in use will be displayed on the setting home page.
insert image description here

5. Click Virtual Machine > Removable Devices > serial port 2 to connect successfully

insert image description here

If the connection fails here, it shows that it cannot be connected, check that it may be because the selected serial port is occupied, as follows;

insert image description here




But it's not that simple

ls /dev/tty*If everything goes well, you should be able to see a /dev/ttyUSB* device when typing in Linux , but it is useless, indicating that Linux has not recognized the serial port. It may be that my virtual machine does not have the CH340 driver installed.
insert image description here

The solution is as follows:

1. lsmod | grep usbserialCheck whether the USB to TTL device is supported by using it; if there is usbserial as shown in the figure, it means that it is supported, and it may be caused by other reasons that the USB cannot be recognized;
if not, you need to install the driver, which was the reason for me at the time, then continue Follow the steps below to install the driver
insert image description here

2. CH340LINUX driver installation, see this blog post for specific operations https://blog.csdn.net/Brushyss/article/details/117192558

3. After installation, you can see that there is already ttyUSB0, and finally the communication between the virtual machine and the serial port can be realized.

insert image description here

Looking at a short article, it has actually been checked for a long time, and I recorded it

Reference article
https://blog.csdn.net/zxw1473474655/article/details/126102955

Guess you like

Origin blog.csdn.net/weixin_44517500/article/details/129455186