Having trouble connecting to a CH340 USB Arduino Board

I’m not sure exactly what the problem is but I have installed the Arduino IDE on my Jetson Nano but I can’t upload any programs to the board, or use the serial monitor.

I do know that my board uses a CH340 USB driver.

So I tried to install it from the Jetson Hacks Github site. But I get the following message.

james@Jetson-Nano:~/installACMModule$ ./installCH341.sh
The Kernel version does not match the Module Version
Kernel Version: 4.9.140-tegra
Module Version: 4.4.38-tegra
Would you still like to install the module? [Y/n] y
You may have to force the module to be inserted, i.e.
$ sudo modprobe -f cp210x
‘ch341.ko’ → ‘/lib/modules/4.9.140-tegra/kernel/drivers/usb/serial/ch341.ko’
Installed ch341 Module
james@Jetson-Nano:~/installACMModule$

It says the kernel version doesn’t match the module version. I answered yes anyway, but it’s still not working.

I’m also not sure if this is even my problem as I’m also getting an error about not having permission to access the Serial device. I get this error from the Arduino IDE.

Error opening serial port ‘/dev/ttyUSB0’. Try consulting the documentation at Arduino Playground - All

I went to the Arduino Playground site and did what they suggested there but I continue to get the errors. I’ve been at this for several days now and I’ve rebooted many times. So I’m at a loss.

What I haven’t done yet is to force the installation of the CH340 driver as suggested above:

You may have to force the module to be inserted, i.e.
$ sudo modprobe -f cp210x
‘ch341.ko’ → ‘/lib/modules/4.9.140-tegra/kernel/drivers/usb/serial/ch341.ko’
Installed ch341 Module

I’m not convinced this will help, but I suppose I could give that a shot. Thought I’d post here first in case anyone has better suggestions.

Thanks for reading.

Since the driver seems to be installed, you can skip the driver installation.

【Driver install】
download CH341SER_LINUX.ZIP

make
sudo make load

【Check device permission】

ls -l /dev/ttyUSB0
58279 0 crw-rw---- 1 root dialout 188, 0 Jul 29 17:59 /dev/ttyUSB0

You can see that the device can access with root and dialout permissions.
If you only have root here or have different permissions, don’t worry. Proceed to the next step as it will be added later.

【Add user group】
If your account don’t have dialout group permission, add it.
Check group permission.

groups ${USER}
ubuntu : ubuntu adm cdrom sudo audio dip video plugdev lpadmin gdm sambashare

Login account “ubuntu” doesn’t have dialout group permission. Therefore add it.

sudo gpasswd --add ${USER} dialout

【Add device permission】
You need to find idVendor and idProduct values.

sudo su
echo 'KERNEL=="ttyUSB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0666", GROUP:="dialout",  SYMLINK+="hl-340"' >/etc/udev/rules.d/hl-340.rules

service udev reload
sleep 2
service udev restart
reboot

【Find device information】

lsusb -v

Bus 001 Device 016: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x1a86 QinHeng Electronics
  idProduct          0x7523 HL-340 USB-Serial adapter
  bcdDevice            2.54
  iManufacturer           0 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               96mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      1 
      bInterfaceProtocol      2 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               1

【Other】
If you use Arduino MEGA, then

ls -l /dev/ttyACM0 
102116 0 crw-rw---- 1 root dialout 166, 0 Jul 30 17:59 /dev/ttyACM0
sudo su
echo 'KERNEL=="ttyACM*", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0044", MODE:="0666", GROUP:="dialout",  SYMLINK+="arduino-mega-adk-r3"' >/etc/udev/rules.d/arduino-mega-adk-r3.rules

service udev reload
sleep 2
service udev restart
reboot

If you use Arduino MICRO, then

ls -l /dev/ttyACM0 
13647841 0 crw-rw---- 1 root dialout 166, 0  9月 24 16:32 /dev/ttyACM0
sudo su
echo 'KERNEL=="ttyACM*", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="8037", MODE:="0666", GROUP:="dialout",  SYMLINK+="arduino-micro"' >/etc/udev/rules.d/arduinomicro.rules

service udev reload
sleep 2
service udev restart
reboot

If you want to fix the number of /dev/ttyACM0, 1, 2… then add
ATTRS{bNumEndpoints}==“02”
If you want to use the same device, then add
ATTRS{bNumEndpoints} and ATTRS{bInterfaceNumber}

Ok, I’ve run the following commands and this is the results.

james@Jetson-Nano:~$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Feb 15 02:51 /dev/ttyUSB0

According to this the permissions are okay right?

Then I ran the following command and got this (along with a ton of other devices that I didn’t bother to post):

james@Jetson-Nano:~$ lsusb -v


Bus 001 Device 014: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x1a86 QinHeng Electronics
  idProduct          0x7523 HL-340 USB-Serial adapter
  bcdDevice            2.54
  iManufacturer           0 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               96mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      1 
      bInterfaceProtocol      2 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               1

I’m not sure what to do next?

I currently have an UNO connected. But I also have Mega boards that I’ll be using too.

In fact, I also hope to program STM32F104 boards, and ESP8266-01 boards too. I have more questions about the STM32 boards as I can’t get the libraries for those to load. But I thought I better get the IDE to work with an UNO before I go any further.

Based on everything I’ve read it should be working?

Could it have something to do with the original installation of the Arduino IDE?
Maybe I didn’t install it correctly?

It launches and appears to be working. But it won’t recognize that a board is attached even after having set the proper port and board. I’ve been using Arduino IDE for years on Windows, so I’m familiar with how to use the IDE. I just can’t seem to get it to communicate with the board.

【Add user group】
Check your group permissions with next command.

groups james

Maybe your login account doesn’t have dialout group permission.
Add the dialout group

sudo gpasswd --add james dialout

After this command, you can get dialout group permission.

groups james

I think this is enough, but if it doesn’t work, try the next one.

【Add device permission】

sudo su
echo 'KERNEL=="ttyUSB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0666", GROUP:="dialout",  SYMLINK+="hl-340"' >/etc/udev/rules.d/hl-340.rules

service udev reload
sleep 2
service udev restart
reboot

This should work.

I’m backsliding and getting worse.

Now the ttyUSB0 file is no longer being created when I plug in the UNO board. It was showing up before.

james@Jetson-Nano:~$ ls -l /dev/ttyUSB0
ls: cannot access '/dev/ttyUSB0': No such file or directory
james@Jetson-Nano:~$

It still shows up in the list when I run the lsusb -v command.

But it no longer shows up as a ttyUSB0 file.

I’ve also gone to the /dev directory and looked through all the tty files and there is no ttyUSBx files to be found.

So it seems like I’m going backwards here.

I have two Jetson Nanos, and when I plug the Arduino board into the other Nano it recognizes the ttyUSB0 file. But I don’t have the Arduino IDE on that Nano.

So now I’m wondering why I’ve lost the ttyUSB0 file? It was creating this before, but not now.

try

ls /dev/tty*

Check before and after connecting the Arduino UNO.
Are there any additional devices after connection? (/dev/ttyACM0)

If your device is /dev/ttyACM0, not /dev/ttyUSB0, you will need to rewrite the permission setting for ttyACM0.

Before connecting the Arduino:

james@Jetson-Nano:~$ ls /dev/tty*
/dev/tty    /dev/tty21  /dev/tty35  /dev/tty49  /dev/tty62   /dev/ttyp9
/dev/tty0   /dev/tty22  /dev/tty36  /dev/tty5   /dev/tty63   /dev/ttypa
/dev/tty1   /dev/tty23  /dev/tty37  /dev/tty50  /dev/tty7    /dev/ttypb
/dev/tty10  /dev/tty24  /dev/tty38  /dev/tty51  /dev/tty8    /dev/ttypc
/dev/tty11  /dev/tty25  /dev/tty39  /dev/tty52  /dev/tty9    /dev/ttypd
/dev/tty12  /dev/tty26  /dev/tty4   /dev/tty53  /dev/ttyGS0  /dev/ttype
/dev/tty13  /dev/tty27  /dev/tty40  /dev/tty54  /dev/ttyp0   /dev/ttypf
/dev/tty14  /dev/tty28  /dev/tty41  /dev/tty55  /dev/ttyp1   /dev/ttyS0
/dev/tty15  /dev/tty29  /dev/tty42  /dev/tty56  /dev/ttyp2   /dev/ttyS1
/dev/tty16  /dev/tty3   /dev/tty43  /dev/tty57  /dev/ttyp3   /dev/ttyS2
/dev/tty17  /dev/tty30  /dev/tty44  /dev/tty58  /dev/ttyp4   /dev/ttyS3
/dev/tty18  /dev/tty31  /dev/tty45  /dev/tty59  /dev/ttyp5   /dev/ttyTHS1
/dev/tty19  /dev/tty32  /dev/tty46  /dev/tty6   /dev/ttyp6   /dev/ttyTHS2
/dev/tty2   /dev/tty33  /dev/tty47  /dev/tty60  /dev/ttyp7
/dev/tty20  /dev/tty34  /dev/tty48  /dev/tty61  /dev/ttyp8

After connecting the Arduino

james@Jetson-Nano:~$ ls /dev/tty*
/dev/tty    /dev/tty21  /dev/tty35  /dev/tty49  /dev/tty62   /dev/ttyp9
/dev/tty0   /dev/tty22  /dev/tty36  /dev/tty5   /dev/tty63   /dev/ttypa
/dev/tty1   /dev/tty23  /dev/tty37  /dev/tty50  /dev/tty7    /dev/ttypb
/dev/tty10  /dev/tty24  /dev/tty38  /dev/tty51  /dev/tty8    /dev/ttypc
/dev/tty11  /dev/tty25  /dev/tty39  /dev/tty52  /dev/tty9    /dev/ttypd
/dev/tty12  /dev/tty26  /dev/tty4   /dev/tty53  /dev/ttyGS0  /dev/ttype
/dev/tty13  /dev/tty27  /dev/tty40  /dev/tty54  /dev/ttyp0   /dev/ttypf
/dev/tty14  /dev/tty28  /dev/tty41  /dev/tty55  /dev/ttyp1   /dev/ttyS0
/dev/tty15  /dev/tty29  /dev/tty42  /dev/tty56  /dev/ttyp2   /dev/ttyS1
/dev/tty16  /dev/tty3   /dev/tty43  /dev/tty57  /dev/ttyp3   /dev/ttyS2
/dev/tty17  /dev/tty30  /dev/tty44  /dev/tty58  /dev/ttyp4   /dev/ttyS3
/dev/tty18  /dev/tty31  /dev/tty45  /dev/tty59  /dev/ttyp5   /dev/ttyTHS1
/dev/tty19  /dev/tty32  /dev/tty46  /dev/tty6   /dev/ttyp6   /dev/ttyTHS2
/dev/tty2   /dev/tty33  /dev/tty47  /dev/tty60  /dev/ttyp7
/dev/tty20  /dev/tty34  /dev/tty48  /dev/tty61  /dev/ttyp8

No difference. At least nothing stood out to me.

The Arudino IDE gives me three serial ports to choose from:

/dev/ttyS0
/dev/ttyTHS1
/dev/ttyTHS2

The first two don’t do anything. /dev/ttyTHS2 does allow me to open the Serial Monitor. But it’s not displaying any information coming from the Arduino. It also tries to upload a sketch to the Arduino but after compiling tells me that the programmer is not responding.

Yesterday I actually had /dev/ttyUSB0 showing on the list.

/dev/ttyS0
/dev/ttyTHS1
/dev/ttyTHS2
/dev/ttyUSB0

It was on the list, but when chosen it wouldn’t open the Serial Monitor or upload a program. At that time it was complaining about permissions.

But now, I can’t even get /dev/ttyUSB0 to show up at all.

So now I’m worse off than I was yesterday and I don’t even know what I did to lose that. Although I did try to install a new CH340 driver. Maybe that’s what screwed everything up?

I got the driver from the Jetson Hacks GitHub page.

So I’m back sliding. I lost the /dev/ttyUSB0 that I used to have. It won’t create that file when I plug in the UNO like it did before. It was creating that file yesterday.

In the OP of this thread I pointed out that I did the following:

james@Jetson-Nano:~/installACMModule$ ./installCH341.sh
The Kernel version does not match the Module Version
Kernel Version: 4.9.140-tegra
Module Version: 4.4.38-tegra
Would you still like to install the module? [Y/n] y

I told it to go ahead and install the module even though it wasn’t the same version as the kernal.
Maybe this is where I shot myself in the foot?

I also DID NOT execute the following command to force the module to be inserted.

Maybe I should have?

You may have to force the module to be inserted, i.e.
$ sudo modprobe -f cp210x
'ch341.ko' -> '/lib/modules/4.9.140-tegra/kernel/drivers/usb/serial/ch341.ko'
Installed ch341 Module

It was bothering me that the numbers weren’t matching up.

Maybe I should go through the install procedure again and try forcing this install command?

I have a whole system on this system SD card. I’d hate to lose it and have to start over. I was going to clone this system SD card just as soon as I finished setting up the Arduino IDE and then this happened.

I have a ton of other AI programs on this System SD card that I haven’t yet backed up on another SD card. I don’t want to have to go back and reinstall all of those!

I should have backed up this SD card before trying to install the Arduino IDE, but I really didn’t think I was going to run into any problems. Once I get this all squared away my very need task will be to make a copy of the system SD card.

It’s a good idea to keep your current sd card until you find a solution.

What happens if you install and uninstall the Arduino IDE on new sdcard image?
It seems that the Arduino IDE does not support AARCH64 well.
https://github.com/arduino/Arduino/issues/7302