patchAVR Downloader/UploaDEr - Patches: patch #4330, Adds experimental FTDI bit bang...


You are not allowed to post comments on this tracker with your current authentication level.

patch #4330: Adds experimental FTDI bit bang mode interface

Submitter:  Johnathan Corgan <jcorgan>
Submitted:  Fri 19 Aug 2005 02:06:07 PM UTC
Category:  None Priority:  5 - Normal
Status:  Works For Me Privacy:  Public
Assigned to:  fischl Open/Closed:  Closed

( Jump to the original submission )

Sat 27 Nov 2021 08:48:04 PM UTC, comment #8: 

With the latest speedup, ft245r works pretty well and fast.

So I think this one can be closed finally.

Joerg Wunsch <joerg_wunsch>
Project Administrator
Fri 03 Feb 2012 10:09:45 PM UTC, comment #7: 

See also bug #30559 Ft232 bit-bang support

Rene Liebscher <rliebscher>
Project Member
Wed 08 Jun 2011 11:08:43 PM UTC, comment #6: 

I'm testing this patch with avrdude 5.10.

I have something wrong, and ig goes into an infinite loop:

ftbb: ATMEGA168 program enable received bad echo: expected 53 but was ff
ftbb: ATMEGA168 program enable received bad echo: expected 53 but was ff

(It seems that avrdude is not asserting "reset": my leds keep flashing...... )

Roger Wolff <rewolff>
Wed 29 Dec 2010 05:01:23 PM UTC, comment #5: 

I refreshed this patch to make it work on the latest avrdude and my FTDI cable based on a FT232R chip.

It's also available here :

(file #22316)

Piglop <piglop>
Mon 01 Jan 2007 06:17:55 PM UTC, comment #4: 

"Markers" ... just a name for a generic mechanism.  We can ensure that some pattern is found in the input data; so we do so, and use that to flag the data we might not otherwise be able to find.

Why libusb calls?  Because libftbb wasn't sufficient, and since anyway it relies on libusb to exist.  In ftdi_usb_open() the use is just to find the specified device.  In fastcmd() the comment explains the issue:  libftbb does buffer flushes in a bad order, and the direct call is used to minimize the amount of garbage sitting in the buffer (and maximize the amount of real data).

David Brownell <db>
Mon 01 Jan 2007 02:08:45 PM UTC, comment #3: 

Thanks for this hint, David. I had a look into your patch posted on the mailing list.

Because I run into problems with synchronizing when using the RX buffer, I switched back to read single pin states (with ftbb_read_pins). It seems, you have solved this problem with using "markers"?!

Why do you need libusb? You use libusb-functions in ftbb_open und fastcmd. Can't ftdi_usb_open and ftdi_write_data be used instead, so only the libftdi library is necessary?

Thomas Fischl <fischl>
Project Member
Sat 30 Dec 2006 11:48:33 AM UTC, comment #2: 

See also the patch I posted to the mailing list:

This uses libftdi on Linux, and looks forward to using the smarter capabilities on the c-rev ft232 chips ... it doesn't
bang individual bits, but bangs them in bulk, so that the
overall speed is a lot better.

Note that even at this much-improved speed, I needed to
also hack avrdude to avoid superfluous I/O.  Such as
writing every block, after they'd all been erased, and
a few other cases; ideally avrdude would grow a mode
whereby it only flashes bytes stored in the hexfile.

David Brownell <db>
Sat 30 Dec 2006 11:11:23 AM UTC, comment #1: 

I find this ftbb patch very useful! On target systems which works with a FTDI usb converter chip, the bitbang lines can be easily used for the isp signals. No additional isp connector is needed and the target controller can be programmed over USB without extra wiring.

I've attached an improved version of this ftbb patch. Jonathan ported it to libftdi, so it can be used on Linux systems. Because programming speed was not so fast, I modified his patch a bit. I changed only parts of ftbb.c, the rest is Jonathan's work (thanks!).

There are two main modifications:
1. On isp commands the sequence of outgoing singals is buffered. Readback is only done if necessary. This method prevent switching between sending and receiving from the FTDI chip on each bit.
2. Using own programming commands (paged_write) make writing faster. The output sequence can be better buffered on paged writes.

Here is a small list of writing and reading durations on my system (only tested under MacOS) with a 2240 byte testfile:
Without changes:
- Reading and writing both about 230s
With buffered mode but without paged writing:
- Reading and writing both about 43s
With buffered mode and with paged writing:
- Writing: 3.36s
- Reading: 43s

The code includes calls for the FTDI DLL, but that wasn't tested yet. Perhaps there are some modifications needed to compile it under windows with the FTDI DLL.

The patch was created for current cvs version (2006-12-30). To compile with ftdi-support type:
./configure --enable-ftdi-support


(file #11627, file #11628, file #11629, file #11630)

Thomas Fischl <fischl>
Project Member
Fri 19 Aug 2005 02:06:07 PM UTC, original submission:  

A new programmer type, 'ftbb', has been created.  Within avrdude.conf, you can now create a new programmer definition with type 'ftbb':

  id       = "ezdop";
  desc     = "AE6HO EZ-Doppler";
  type     = ftbb;
  baudrate = 230400;
  reset    = 5;
  sck      = 3;
  mosi     = 2;
  miso     = 1;

The baudrate parameter maps to the bit bang interface baudrate.  The above definition has been added to, copy and edit as needed.

Due to the check for a valid pin number between 1 and 17, the pin definitions correspond to the FTDI data bus pin + 1.  For example, with an FT232BM, 'reset = 5' means you are telling avrdude that RESET has been wired to the bit bang bus D4.  Thus valid values are 1 - 8 to correspond to bit bang bus D0-D7.

No support exists yet for specifying the port via -P.  The bit bang code is hardwired to use FTDI device number zero.  You will still have to invoke the command line parameter '-P ft0', and if this is missing or set to something besides 'ft0', the program will error out.

I've tested all the basic operations from the command line and from the terminal mode, with success, using an ATMega8 and an FT232BM.  I have no experience yet with the FT2232 part so I don't know if it would be supported at all.  FT245BM should work with no differences.

As has been mentioned previously, this implementation is very slow. Transmitting a byte to lower SCK, reading a byte to get MISO status, transmitting another byte to raise SCK to clock in, MOSI, etc., results in a ping-pong effect on the USB bus.  But this is required to return the data the AVR is clocking out the MISO line to the calling routine.  The FTDI USB latency timer does not seem to function in bit bang mode, so experimenting with this value hasn't made any difference.

I'll be working on an update to this implementation to clock out an entire command in a single USB packet for commands that don't need a response; this will at least improve things like writes.

Finally, the support exists for Cygwin only, and dynamically links to the FTDI FTD2XX DLL.  The changes have the location of the FTD2XX.h and FTD2XX.lib files (supplied by FTDI) hard coded; you'll need to fix these up to correspond to the location in your build environment.

Johnathan Corgan <jcorgan>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #22316:  ftbb-2010-12-29.diff added by piglop (23KiB - text/x-patch - refreshed patch)
file #11628:  ftbb.h added by fischl (1KiB - application/octet-stream - Patch to CVS 2006-12-30. Uses libftdi and faster programming methods.)
file #11629:  ftbb.c added by fischl (14KiB - application/octet-stream - Patch to CVS 2006-12-30. Uses libftdi and faster programming methods.)
file #11630:  ftbb_ftdi.m4 added by fischl (2KiB - application/octet-stream - Patch to CVS 2006-12-30. Uses libftdi and faster programming methods.)
file #11627:  patch-avrdude-ftbb-20061230.diff added by fischl (3KiB - application/octet-stream - Patch to CVS 2006-12-30. Uses libftdi and faster programming methods.)
file #9260:  PATCH-avrdude-ftbb-050813.diff added by jcorgan (12KiB - application/octet-stream - Patch to CVS 2005-08-18)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by joerg_wunsch (Posted a comment)
  • -email is unavailable- added by rliebscher (Posted a comment)
  • -email is unavailable- added by rewolff (Posted a comment)
  • -email is unavailable- added by piglop (Updated the item)
  • -email is unavailable- added by db (Posted a comment)
  • -email is unavailable- added by fischl (Updated the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.




    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-27 joerg_wunsch StatusNone Works For Me
        Open/ClosedOpen Closed
    2010-12-29 piglop Attached File- Added ftbb-2010-12-29.diff, #22316
    2007-01-01 fischl Assigned toNone fischl
    2006-12-30 fischl Attached File- Added ftbb.h, #11628
        Attached File- Added ftbb.c, #11629
        Attached File- Added ftbb_ftdi.m4, #11630
    2006-12-30 fischl Attached File- Added patch-avrdude-ftbb-20061230.diff, #11627
    2005-08-19 jcorgan Attached File- Added PATCH-avrdude-ftbb-050813.diff, #5049

    Back to the top

    Powered by Savane 3.9