Difference between revisions of "Ftdi"
(do not erase the eeprom) |
|||
(2 intermediate revisions by one user not shown) | |||
Line 35: | Line 35: | ||
To re-program the eeprom, better read it before and have a backup. | To re-program the eeprom, better read it before and have a backup. | ||
* download the ftd2xx library http://www.ftdichip.com/Drivers/D2XX.htm | * download the ftd2xx library http://www.ftdichip.com/Drivers/D2XX.htm | ||
+ | * unpack it | ||
+ | * copy the header files to the right folders | ||
+ | cp release/WinTypes.h /usr/local/include | ||
+ | cp release/ftdi.h /usr/local/include | ||
* download http://svn.icmb.utexas.edu/svn/repository/trunk/zpub/sdkpub/usbkey_dlpd/macosx/d2xx/Samples/EEPROM/write/main.c | * download http://svn.icmb.utexas.edu/svn/repository/trunk/zpub/sdkpub/usbkey_dlpd/macosx/d2xx/Samples/EEPROM/write/main.c | ||
+ | * inside main.c, replace | ||
+ | ../../ftdi.h | ||
+ | by | ||
+ | ftdi.h | ||
+ | and delete the line containing | ||
+ | RIsVCP | ||
* compile it using | * compile it using | ||
gcc -o write main.c -L/root/Downloads/release/build/x86_64/ -lftd2xx -lpthread -ldl -lrt -Wl,-rpath,/usr/local/lib | gcc -o write main.c -L/root/Downloads/release/build/x86_64/ -lftd2xx -lpthread -ldl -lrt -Wl,-rpath,/usr/local/lib | ||
Line 43: | Line 53: | ||
* call the program to re-write the device's eeprom: | * call the program to re-write the device's eeprom: | ||
./write | ./write | ||
+ | |||
+ | = Do not erase the eeprom = | ||
+ | After erasing the eeprom it does not work any longer. Connecting the ftdi chip I get in dmesg | ||
+ | [17532.329381] usb 3-2: USB disconnect, device number 13 | ||
+ | [17533.524251] usb 3-2: new full-speed USB device number 14 using xhci_hcd | ||
+ | [17533.594733] usb 3-2: New USB device found, idVendor=0403, idProduct=6001 | ||
+ | [17533.594739] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 | ||
+ | [17533.594743] usb 3-2: Product: USB Serial Converter | ||
+ | [17533.594746] usb 3-2: Manufacturer: ACME Inc | ||
+ | [17533.594749] usb 3-2: SerialNumber: FT000008 | ||
+ | [17533.595216] xhci_hcd 0000:02:00.0: ERROR: unexpected command completion code 0x11. | ||
+ | [17533.595225] usb 3-2: can't set config #1, error -22 | ||
= understand the eeprom's bits = | = understand the eeprom's bits = |
Latest revision as of 11:33, 25 December 2012
Ok for programming electronics I got myself an ftdi chip buying this package. Now want to be able to invert the TX/RX/... signals so I can get some experiments working that I have in this book.
To do this we have to re-program the device's eeprom.
Contents |
read the eeprom
To read the EEPROM of the ftdi, use the software ftdi_eeprom.
- download the software
wget http://www.intra2net.com/en/developer/libftdi/download/ftdi_eeprom-0.3.tar.gz
- unpack it
tar xvzf ftdi_eeprom-0.3.tar.gz cd ftdi_eeprom-0.3
- build it
./configure && make -j4 && make install
- find out your ftdi's serial ID:
hwinfo --usb [...] Serial ID: "A7006Ys2" [...]
- configure ftdi_eeprom to use your serial id:
sed -i "s/^serial=.*/serial=\"A9VQ459E\"/" example.conf
- read your chip's eeprom:
ftdi_eeprom --read-eeprom example.conf
- find the file name where the eeprom is stored in:
ls -ltr [...] -rw-r--r-- 1 root root 128 Dec 15 12:59 eeprom.new
- verify that it is really an eeprom
# hexdump -C eeprom.new 00000000 00 40 03 04 01 60 00 00 a0 2d 08 00 00 00 98 0a |.@...`...-......| 00000010 a2 20 c2 12 23 10 05 00 0a 03 46 00 54 00 44 00 |. ..#.....F.T.D.| 00000020 49 00 20 03 46 00 54 00 32 00 33 00 32 00 52 00 |I. .F.T.2.3.2.R.| [...]
Re-program the eeprom
To re-program the eeprom, better read it before and have a backup.
- download the ftd2xx library http://www.ftdichip.com/Drivers/D2XX.htm
- unpack it
- copy the header files to the right folders
cp release/WinTypes.h /usr/local/include cp release/ftdi.h /usr/local/include
- download http://svn.icmb.utexas.edu/svn/repository/trunk/zpub/sdkpub/usbkey_dlpd/macosx/d2xx/Samples/EEPROM/write/main.c
- inside main.c, replace
../../ftdi.h
by
ftdi.h
and delete the line containing
RIsVCP
- compile it using
gcc -o write main.c -L/root/Downloads/release/build/x86_64/ -lftd2xx -lpthread -ldl -lrt -Wl,-rpath,/usr/local/lib
- remove the ftdi_sio driver
modprobe -r ftdi_sio
- disconnect all other FTDI chips
- call the program to re-write the device's eeprom:
./write
Do not erase the eeprom
After erasing the eeprom it does not work any longer. Connecting the ftdi chip I get in dmesg
[17532.329381] usb 3-2: USB disconnect, device number 13 [17533.524251] usb 3-2: new full-speed USB device number 14 using xhci_hcd [17533.594733] usb 3-2: New USB device found, idVendor=0403, idProduct=6001 [17533.594739] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [17533.594743] usb 3-2: Product: USB Serial Converter [17533.594746] usb 3-2: Manufacturer: ACME Inc [17533.594749] usb 3-2: SerialNumber: FT000008 [17533.595216] xhci_hcd 0000:02:00.0: ERROR: unexpected command completion code 0x11. [17533.595225] usb 3-2: can't set config #1, error -22
understand the eeprom's bits
Using the program ftdi_eeprom I can read the 128 bytes of user's eeprom from the FTDI RS232R chip. Using the "write" command compiled above I can change single values like InvertTXD in the eeprom. So let's set all Invert values to 0x00. The Invert values are:
InvertTXD InvertRXD InvertRTS InvertCTS InvertDTR InvertDSR InvertDCD InvertRI
Now I modify main.c so that all Invert values are 0x01, compile and run it and get eeprom-all1 via ftdi_eeprom. Then I modify main.c so that all Invert values are 0x00, compile and run it and get eeprom-all0 via ftdi_eeprom. Then I use the cmp to find out which values have changed:
# cmp -l eeprom-all0 eeprom-all1 12 0 377 127 107 273 128 176 175
Indeed, byte 12 is 00h in eeprom-all0 and FFh in eeprom-all1. Besides, the last two bytes of the 128 bytes-file seem to contain a checksum, they are different as well.
See also
- http://svn.icmb.utexas.edu/svn/repository/trunk/zpub/sdkpub/usbkey_dlpd/macosx/d2xx/Samples/EEPROM/write/main.c
- http://www.ftdichip.com/Support/Documents/ProgramGuides/D2XX_Programmer%27s_Guide%28FT_000071%29.pdf - good overview what the bytes in the EEPROM mean.