PlatformIO Community

Troubleshooting CH340G issues on macOS

The CH340G USB-to-UART chip is used by a number of inexpensive development boards (e.g. WEMOS and LOLIN branded boards) and USB-to-serial adapters. It is manufactured by a Chinese company called WinChipHead or WCH (International web site, Chinese web site). Unfortunately, it often causes problems on macOS. This guide helps you resolve any problems you might have with the boards and adapters.

CH340G chip

Like many USB-to-serial solutions, it requires a driver that creates the serial port when the board or adapter is plugged into a USB port of your Mac. Starting with macOS 10.14 Mojave, macOS provides suitable drivers out of the box, implemented by Apple itself. So no additional software is needed.

Main issues

There are three main issues:

  1. Most boards only work for upload speeds / data rates up to 460,800 bps.
  2. Many users have additional drivers from WCH or Repleo installed, either from earlier macOS versions or because of obsolete tips and instructions on the internet. With the additional drivers, two serial ports will be created and one of them will be non-functional. Furthermore PlatformIO will no longer be able to automatically select the port.
  3. There are many forums and web pages with instructions how to install the WCH driver. Unfortunately, they are obsolete. While they were helpful back then, they now cause additional trouble.

Setup

Do not install any additional software for the CH340G if you are using the macOS 10.14 Mojave or later (including macOS Big Sur). macOS includes all the required components. Additional software will cause additional problems.

In your PlatformIO project, add the below line to platformio.ini and you should be ready to upload your sketch:

upload_speed = 460800

If you have an older macOS version and cannot upgrade to the latest version, you can download the driver from here.

How to check for Apple drivers

macOS Catalina, macOS Big Sur and later:

ls -l /System/Library/DriverExtensions/com.apple.DriverKit-AppleUSBCHCOM.dext

should result in something like:

total 40
-rw-r--r--  1 root  wheel   2552 Jun  6  2020 Info.plist
drwxr-xr-x  3 root  wheel     96 Sep 26 11:36 _CodeSignature
-rwxr-xr-x  1 root  wheel  41280 Sep 22 02:45 com.apple.DriverKit-AppleUSBCHCOM
-rw-r--r--  1 root  wheel    535 Jun  6  2020 version.plist

For macOS Mojave, check with ls -l /System/Library/Extensions.

How to check for other drivers

You can check for additional drivers by executing (in a terminal):

ls -l /Library/Extensions

The output will look something like this:

drwxr-xr-x  3 root  wheel      96 Apr 24  2018 ACS6x.kext
drwxr-xr-x  3 root  wheel      96 May  8  2018 ATTOCelerityFC8.kext
drwxr-xr-x  3 root  wheel      96 May  7  2018 ATTOExpressSASHBA2.kext
drwxr-xr-x  3 root  wheel      96 May  7  2018 ATTOExpressSASRAID2.kext
drwxr-xr-x  3 root  wheel      96 Sep  6  2017 ArcMSR.kext
drwxr-xr-x  3 root  wheel      96 Sep  1  2013 CalDigitHDProDrv.kext
drwxr-xr-x  3 root  wheel      96 May  4  2018 HighPointIOP.kext
drwxr-xr-x  3 root  wheel      96 Dec  5  2017 HighPointRR.kext
drwxr-xr-x  3 root  wheel      96 Mar 31  2017 PromiseSTEX.kext
drwxr-xr-x  3 root  wheel      96 Apr 25  2018 SoftRAID.kext
drwxr-xr-x  3 root  wheel      96 Jul  4  2018 usbserial.kext

The last entry usbserial.kext is the WCH driver. You should uninstall it (see below). The same would apply to the driver from Repleo. It’s called osx-ch341.kext.

If you can’t see any of these drivers, also check ls -l /System/Library/Extensions.

How to uninstall the WCH driver

To uninstall the driver:

  1. Unplug all boards/adapters with a CH340G chip
  2. Execute the following commands to first unload and then uninstall the driver:
sudo kextunload /Library/Extensions/usbserial.kext/
sudo rm -rf /Library/Extensions/usbserial.kext/

If you remove the driver without first unloading it, you will have to reboot your Mac. If you stick to the order, no reboot is required.

If you want to remove a different driver or a driver in a different location, modify the command line, e.g.:

sudo kextunload /System/Library/Extensions/osx-ch341.kext/
sudo rm -rf /System/Library/Extensions/osx-ch341.kext/

How to limit the upload speed

The CH340G and/or its driver do not reliably work with speeds of 921,600, yet that’s the default in PlatformIO for many boards. So the below line is required in platformio.ini:

upload_speed = 460800

Monitor speed is usually 115,200 and therefore does not need to be changed.

Checking for the serial port

When you plug in your board, the serial port should appear in /dev and have a name starting with ‘cu.’:

ls -l /dev/cu.*
crw-rw-rw-  1 root  wheel   18,   5 Sep  7 10:54 /dev/cu.Bluetooth-Incoming-Port
crw-rw-rw-  1 root  wheel   18,   3 Sep  7 10:54 /dev/cu.MALS
crw-rw-rw-  1 root  wheel   18,   1 Sep  7 10:54 /dev/cu.SOC
crw-rw-rw-  1 root  wheel   18,  15 Sep  8 23:09 /dev/cu.usbserial-1410

This is the list of all serial ports. /dev/cu.usbserial-1410 is the serial port created by Apple’s driver.

If the output however looks like so, there is a problem:

crw-rw-rw-  1 root  wheel   18,   5 Sep  7 10:54 /dev/cu.Bluetooth-Incoming-Port
crw-rw-rw-  1 root  wheel   18,   3 Sep  7 10:54 /dev/cu.MALS
crw-rw-rw-  1 root  wheel   18,   1 Sep  7 10:54 /dev/cu.SOC
crw-rw-rw-  1 root  wheel   18,  15 Sep  8 23:09 /dev/cu.usbserial-1410
crw-rw-rw   1 root  wheel   18,  14 Sep  8 23:09 /dev/cu.wchusbserial1410

Two entries have been created for the same board because two drivers for the CH340G chip are installed. One of the ports will work, the other one will cause an error when a connection is attempted. The solution is to uninstall all non-Apple drivers (see above).

Troubleshooting

The general approach for troubleshooting is:

  1. Uninstall the WCH driver
  2. Limit the upload speed
  3. Reboot

Specific problems

Resource busy: ‘/dev/cu.usbserial-1410’

If a resource busy error, occurs, the selected serial port is most likely blocked by a second driver. Uninstalling the WCH driver or other non-Apple drivers (see above) should fix it.

Timed out waiting for packet content*

If a Timed out waiting for packet content error occurs, the upload speed is likely too high. Limit the upload speed (see above) to fix the issue.

5 Likes

I just updated to Big Sur, and can no longer connect to my ESP8266s.

Following the discussion above, I saw that there were no ch340 drivers in either directory.

I installed the driver installation from the mfg, and rebooted.

The usbserial.kext driver appears in the /Library/Extensions folder. However there is are no /dev/cu.wcusbserial devices on my system.

I don’t have macOS Big Sur installed yet. But for all I know it includes drivers for WCH CH340, different FTDI chips and Silicon Labs CP2102. They are found in /System/Library/DriverExtensions and are called:

  • com.apple.DriverKit-AppleUSBCHCOM.dext
  • com.apple.DriverKit-AppleUSBFTDI.dext
  • com.apple.DriverKit-AppleUSBSLCOM.dext

The earlier posts referred to macOS versions before macOS Catalina.

What’s the exact error message you are getting? Is the board visible as /dev/cu..... It would likely be named /dev/cu.usbserial-14....

 /dev/cu.usbserial-14120

Success uploading to ESP8266!!!

Thank you so much for your post and help. I can now continue to use the Mac for development.

As an explanation of what I struggled with - I kept looking to connect to a device ‘cu.wchusbserial14120’. I was thinking the Apple driver would implement the dual scheme for the serial port that I was used to seeing… [BTW The Arduino IDE 1.8.10 is unable to obtain board info through this driver.]

Thank you.

If two drivers for the same device are installed, they both create an entry in /dev. But only one will work.

/dev/cu.wchusbserial14120 is the defunct one. I suggest you uninstall the WCH drivers at /Library/Extensions/usbserial.kext.

Then only one entry will be created and PlatformIO will likely pick the right one automatically.

Driver removed. Thank you.

Thanks for excellent write up. Unfortunately its not working for me on macOS Catalina 10.15.7. I’m trying to connect Platform IO to Wemos D1 Mini PRO which has an CH340C. The board is not visible at all under /dev/cu… I cannot find Apple’s driver AppleUSBCHCOM.kext under /System/Library/Extensions and I don’t have any additional drivers installed. it seems Apple made some changes here?

On macOS Cataling already, the driver is under /System/Library/DriverExtensions/com.apple.DriverKit-AppleUSBCHCOM.dext. I’m sure you’ll find it on your system as well.

Since it’s not working, try:

  • Check if the device is visible in the System Report (Apple Menu / About This Mac… / System Report… / Hardware / USB). If it is visible, what are the Product ID and Vendor ID?
  • Use a different USB cable. Some inexpensive USB cables are for power supply only and don’t have the wires for data. Or it might simply be defective.
  • If you are using a USB hub, try different USB ports on the hub.
  • Restart your Mac. If a device draws excessive current, devices stop to work until the next startup. I’m not sure if this is a deliberate features of macOS or rather a partial crash of the USB stack.

Thanks appreciate the help. I flashed the device using Platform IO on a PC so got the software running with no issues. Based on your advice I gave mac another try and I can locate the driver on my system and after connecting the board I can also see the device under System Report. It also shows up under /dev. Must have been an unfortunate combination of two faulty USB cables because I tried connecting using two different mac both running 10.15.7 Catalina and none of them found the device and I was careful not to use a power only USB cable. Anyway I’m back on track now :slight_smile: