You are not logged in.

#1 2015-12-09 19:58:27

shane1027
Member
Registered: 2015-10-20
Posts: 7

avrdude cannot get serial port settings on /dev/ttyUSB0

I'm trying to program an Arduino Nano v3.0 that uses a CH340 interface.  I've successfully programmed such a device using the arduino IDE from the AUR as well as via the command line using avrdude.


I recently updated via

 sudo pacman -Syu 

- Now, for some reason, I'm receiving this error upon trying to program any of my three CH340 devices: 

 avrdude -p m328p -c avrispv2 -P /dev/ttyUSB0 
 avrdude: Cannot get serial port settings. ioctl returned -1
avrdude: ser_open(): can't set attributes for device "/dev/ttyUSB0": Inappropriate ioctl for device

avrdude done.  Thank you.

I can still program my legitimate Ardunio UNO which runs on port

 /dev/ttyACM0 

and can interact with the sketch that was previously loaded on the Nano's via

 minicom -D /dev/ttyUSB0 

.  My permissions are set correctly to interface with the serial ports (my user is a part of groups lock, uucp, and tty), I can select /dev/ttyUSB0 in the IDE, and the problem persists when running avrdude and the IDE as root.




Using

 dmesg -w 

I get:

[  651.403897] usb 3-1: new full-speed USB device number 3 using xhci_hcd
[  651.579310] ch341 3-1:1.0: ch341-uart converter detected
[  651.580372] usb 3-1: ch341-uart converter now attached to ttyUSB0

This shows that the kernel still recognizes the device...  Not sure what to do from here.  I can't seem to make sense out of what

 ioctl returned -1 

means, even after reading through man pages for both avrdude and ioctl, as well as googlin' around. 

One last potentially helpful bit of info is that I read about UDEV rules under the Arduino page of the Arch wiki and did not make any for my setup, as it worked 'as-is' up until recently.

Any ideas guys?

Thanks!

Offline

#2 2015-12-09 21:43:15

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: avrdude cannot get serial port settings on /dev/ttyUSB0

This means that avrdude tries to perform some operation on the ch340 which isn't implemented in the driver (or possibly isn't supported by the hardware at all).

strace will tell what exactly if you are curious.

Maybe this can be omitted with command line switches or by editing /etc/avrdude.conf, maybe you'd need to edit avrdude source code. Maybe google knows something.

Other options: make sure you are running the latest kernel, try different UART chip, fix the driver smile

Last edited by mich41 (2015-12-09 21:45:17)

Offline

#3 2015-12-10 01:30:32

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: avrdude cannot get serial port settings on /dev/ttyUSB0

BTW The 6.2 avrdude has several severe bugs so it had been reverted back to 6.1 https://projects.archlinux.org/svntogit … 24fb5af3a8

Try 6.1 version from testing if it makes a difference for you


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#4 2015-12-10 02:51:47

shane1027
Member
Registered: 2015-10-20
Posts: 7

Re: avrdude cannot get serial port settings on /dev/ttyUSB0

anatolik wrote:

BTW The 6.2 avrdude has several severe bugs so it had been reverted back to 6.1 https://projects.archlinux.org/svntogit … 24fb5af3a8

Try 6.1 version from testing if it makes a difference for you



This!!  I went through the trouble of tracing avrdude with strace, downgrading my kernel, finding semi-updated driver package of CH341SER_LINUX.ZIP, making a few custom make files, and eventually getting the following to register in the kernel:

 
[ 1777.573484] usbcore: registered new interface driver ch34x
[ 1777.573519] usbserial: USB Serial support registered for ch34x
[ 1849.922242] usb 3-1: USB disconnect, device number 3
[ 1849.922568] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 1849.922607] ch341 3-1:1.0: device disconnected
[ 1852.484966] usb 3-2: new full-speed USB device number 4 using xhci_hcd
[ 1852.659984] ch341 3-2:1.0: ch341-uart converter detected
[ 1852.661017] usb 3-2: ch341-uart converter now attached to ttyUSB0

So the updated kernel module successfully installed a new interface module that seemed to be needed, and yet when reconnecting the device Arch still recognized it as a ch341-uart converter and assigned it a different driver than the ch34x  yikes

I was about ready to pull my hair out!

Thanks a lot for the help guys.  All is well now after using

downgrade

from the AUR, and hey, at least I learned a bit about kernels and tracing processes!

Offline

Board footer

Powered by FluxBB