queezythegreat / arduino-cmake

Arduino CMake Build system
648 stars 216 forks source link

make upload timeout with mega2560 #27

Closed ghost closed 12 years ago

ghost commented 12 years ago

avrdude times out on when I call make ${name}-upload. I get the following messages over and over again:

avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer

However, I do not get this problem when uploading from the Arduino SDK. I am able to upload immediately.

Turns out, I can get the upload to work if I push the reset button and then command the upload within a very short period. After some research on arduino's forums, it looks like this may have to do with not having a DTR pulse (or not have the correct pulse width). Is there a way to fix this without having to manually reset (like the Arduino SDK)?

I am using a mega2560- Specifically an Ardupilot with a sensor shield (IMU Shield).

queezythegreat commented 12 years ago

This issue may be related to avrdude not being patched (the one installed on the system). Arduino SDK ships with a patched version of avrdude in _${ARDUINOSDK}/hardware/tools. When Arduino CMake detects avrdude on the system path it uses that one, instead of the one bundled with the Arduino SDK. What OS are you using?

When generating the build system you can set ARDUINO_AVRDUDE_PROGRAM explicitly to the path of avrdude bundled with Arduino SDK. That should solve your problem.

queezythegreat commented 12 years ago

I think it's a good idea to use the avrdude bundled with the Arduino SDK. In that case it might be also be good to use the avrdude config file bundled with Arduino.

johnyb commented 12 years ago

avrdude config should be prefered over the one from /etc/avrdude see this code:

    find_program(ARDUINO_AVRDUDE_CONFIG_PATH
                 NAMES avrdude.conf
                 PATHS ${ARDUINO_SDK_PATH} /etc/avrdude
                 PATH_SUFFIXES hardware/tools
                               hardware/tools/avr/etc)

So, at least for the standard use-case, where the user just specifies the path to the arduino sdk (or it is found in the systems path somewhere), everything will be used from the same arduino sdk. (Except for the avrdude binary, if you use current master. But this will be changed by #31)