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)
2. Click [Add], select [Serial Port], and click [Finish]
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.
4. After the setting is completed, the port in use will be displayed on the setting home page.
5. Click Virtual Machine > Removable Devices > serial port 2 to connect successfully
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;
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.
The solution is as follows:
1. lsmod | grep usbserial
Check 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
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.
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