I used avrdude 6.2 (but the relevant file ft245r.c is identical with 6.3).
THE PROBLEM: I find that device initialization often (about 50% of tries)
fails as follows:
$ sudo ./avrdude -p m8 -c ftdi_uni_uC -P ft0
avrdude: Device is not responding to program enable. Check connection.
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
Investigating with an oscilloscope, I found that during ft245r_open() the
signals behave as follows:
1) start with RESET=1, SCK=0
2) calling ftdi_set_bitmode (line 614) => sets RESET=0
3) calling ft245r_drain (line 638) =>
shortly pulses RESET=1 and SCK=1 simultaneously, then back to 0
This seems to happen due to the switching of bitmodes back&forth in
4) calling ft245r_send (line 640) - set output to ft245r_out => sets RESET=1
This is followed by the actual init sequence in ft245r_initialize().
It appears that the simultaneous pulsing of RESET and SCK (step 3 above) puts
the ATmega (already powered up since VCC is not controlled) in an undefined
state. This is not (always) fixed by the folloiwing init sequence, despite
pulsing RESET high in accorance with the datasheet.
I assume that programmers that control VCC will not be affected by this
problem, since the AVR is not powered up before ft245r_initialize() runs.
PROPOSED PATCH (see attached ft245r.patch):
* change ft245r_drain() to use ftdi_read_data until buffer is empty, instead
of bitmode switching
* call ft245r_drain() before setting up the reader thread, rather than after
(make sure reader thread starts with empty buffer).
This fixed the issue for me (i.e. initialization and further operations now