0
\$\begingroup\$

Recently I have been trying to learn how to program Arduino in Code::Blocks. I used the AVR project wizard to create my project. The program compiles flawlessly into a .hex file that I want to upload using avrdude. I've already looked for about an hour for a solution, but none of them that I find actually work. I am running on Ubuntu, if that is important. Here is what I get in the command line:

me@mePC:~/Desktop/C++/AVRTest$ sudo avrdude -c avrisp -p m168 -P /dev/ttyUSB0/ -U flash:w:AVRTest.hex
avrdude: ser_open(): can't open device "/dev/ttyUSB0/": Not a directory
ioctl("TIOCMGET"): Invalid argument

avrdude done.  Thank you.

I am running avrdude in the directory that the .hex file is located. I looked in the Arduino IDE and the programmer is AVR ISP, the chip is ATmega168, and the port used is /dev/ttyUSB0/. I've already tried the arduino programmer option in avrdude. This is the Duemilanove board that I am using and it has an FTDI chip on it.

I am quite puzzled by this and any help would be appreciated. Thanks.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You shouldn't need sudo for this. If you add your user to the dialout group, which owns /dev/ttyUSB0, logout and log back in, you can do this without sudo (and you always try to use sudo as little as possible). \$\endgroup\$
    – user17592
    Commented Mar 23, 2015 at 15:19

4 Answers 4

3
\$\begingroup\$

I think the problem is that your port is /dev/ttyUSB0 and not /dev/ttyUSB0/

\$\endgroup\$
1
\$\begingroup\$

I solved following serial port related problems in ubuntu 18.04 as follows:

Problem 1 : Cannot open /dev/ttyACM0: Permission denied
Solution : Grant permissions to read/write to the serial port with this terminal command ---> sudo chmod a+rw /dev/ttyACM0 Here replace tty port with your respective ubuntu port.

Problem 2 : Failed to open /dev/ttyACM0 (port busy) Solution : This problem appears when serial port is busy or already occupied. So kill the busy serial port with command ---> fuser -k /dev/ttyACM0. Here replace tty port with your respective ubuntu port.

Problem 3 : Board at /dev/ttyACM0 is not available Solution : In this case your serial port in tools menu will be greyed out. I googled a lot for this, but I none of solution worked for me. Atlast I tried different arduino board and usb connector and it was working for me. So, if you are having old arduino board (can be solved using required drivers) or defected arduino board then only this problem arises.

\$\endgroup\$
0
\$\begingroup\$

This message means your operating system can't open the (virtual) serial port /dev/ttyUSB0. There are a few things to check:

  • Is the Arduino connected to your computer?
  • Do a ls /dev/ttyUSB*. Sometimes, when you disconnect and reconnect the Arduino, it gets a different name, like ttyUSB1.
\$\endgroup\$
-1
\$\begingroup\$

After a bit more trouble shooting, I found that avrdude needed the baud rate. I found this by looking at the terminal that the Arduino IDE uses while it was uploading. The baud rate needs to be set with -b 19200.

\$\endgroup\$
1
  • \$\begingroup\$ Error message in question clearly indicates that the trailing "/" in the serial port name (/dev/ttyUSB0/) is the problem. \$\endgroup\$
    – Turbo J
    Commented Nov 13, 2015 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.