[bug #52653] device initialization often fails in FT232R syncbb mode, due to glitchy start sequence

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[bug #52653] device initialization often fails in FT232R syncbb mode, due to glitchy start sequence

Joerg Wunsch-6

                 Summary: device initialization often fails in FT232R syncbb
mode, due to glitchy start sequence
                 Project: AVR Downloader/UploaDEr
            Submitted by: rai42
            Submitted on: Tue 12 Dec 2017 11:57:30 PM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: rai42
        Originator Email:
             Open/Closed: Open
                 Release: 6.2
         Discussion Lock: Any
     Programmer hardware: FTDI FT232RL
             Device type: ATmega8




Using a custom board with ATmega8 and FT232RL and the following

  id    = "ftdi_uni_uC";
  desc  = "FT232R Synchronous BitBang";
  type  = "ftdi_syncbb";
  connection_type = usb;
  baudrate = 38400;
  reset = 7; #RI
  sck   = 3; #CTS
  mosi  = 6; #DCD
  miso  = 5; #DSR

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
         this check.

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
work reliably).


File Attachments:

Date: Tue 12 Dec 2017 11:57:30 PM UTC  Name: ft245r.patch  Size: 1KiB   By:
Patch to ft245r.c


Reply to this item at:


  Message sent via/by Savannah

avrdude-dev mailing list
[hidden email]