Go Down

Topic: Avrdude not working with Arduino Micro (Read 828 times) previous topic - next topic

tf68

#15
Jul 19, 2019, 11:19 pm Last Edit: Jul 19, 2019, 11:22 pm by tf68
Use ls /dev/ttyACM? to see if port has changed.
The ports enumerate based on the order they are discovered or devices are plugged in.
The port can change because the original port is still valid when a new port is discovered. It is sort of by chance.
I have never had the port change when using the reset button try holding the button down for second before releasing it.

dynasample

Well, the problems are that

1) ttyACM? does not show up in /dev anymore once you have initialized the reset.
2) the number does NOT change if you use the reset button. But it changes with the command line.

sterretje

What do dmsg and lsusb (??, not really a linux user (anymore)) say under the different conditions?

In windows my COM6 (in this case) disappears and COM7 shows up when either pressing the reset button or forcing a reset using the 1200 baud from a terminal program. COM6 is 'Arduino Leonardo', COM7 is 'Arduino Leonardo bootloader'.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

tf68

This works on my Linux system, it should work on yours.
On my system the Leo is on /dev/ttyACM1, /dev/ttyACM0 is being used by something else.
Open /dev/ttyACM1 at 1200 baud.
ls shows /dev/ttyACM1.
Close port, bootloader begins to run.
ls shows /dev/ttyACM1.
Upload with avrdude - success.

dynasample

Whatever I do the ttyACM number goes up by 1.


I'm suspecting that I don't open and close the port correctly.
I had asked this before but unfortunately I didn't get any answer so I'm asking again:

How do you open and close the ttyACM0 port correctly?
What is the exact command?

Thanks!

sterretje

The reset happens when you open and close the port with a baudrate of 1200.

You can try it manually with e.g. minicom. No idea how to script it, need a refresher in Linux.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

dynasample

Thanks!

Unfortunately I need to open and close from a shell and it looks like that's where the problem is.
The ttyACM0 is probably not closed properly for any reason so it reopens with a new increased number.

sterretje

I found https://unix.stackexchange.com/questions/22545/how-to-connect-to-a-serial-port-as-simple-as-using-ssh.

Hacked it a bit and it does reset a Leonardo (Ubuntu 12.04; yes I need an update)

Code: [Select]
#!/bin/sh

# connect.sh

# Usage:
# $ connect.sh <device> <port speed>
# Example: connect.sh /dev/ttyS0 9600

# Set up device
stty -F $1 $2

dmesg | tail -f

# Let cat read the device $1 in the background
cat $1 &

# Capture PID of background process so it is possible to terminate it when done
bgPid=$!

# Terminate background read process
kill $bgPid
dmesg | tail -f


I added dmesg to see, but not sure if it's useful.

Run with port and baudrate as parameters.

If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Go Up