debian/0000755000000000000000000000000011575435161007176 5ustar debian/copyright0000644000000000000000000000122011575433761011130 0ustar This package was debianized by Aurelien Jarno on Wed, 31 Mar 2004 00:28:47 +0200. It was downloaded from http://www.intra2net.com/opensource/ftdi/index.php Upstream Author: Intra2net AG Copyright: Copyright (C) 2003 Intra2net AG This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. debian/control0000644000000000000000000000124411575434430010600 0ustar Source: ftdi-eeprom Section: utils Priority: optional Maintainer: Aurelien Jarno Build-Depends: debhelper (>= 5), autotools-dev, libconfuse-dev (>= 2.0), libftdi-dev (>= 0.19), pkg-config (>= 0.18) Standards-Version: 3.9.2 Homepage: http://www.intra2net.com/de/produkte/opensource/ftdi/ Package: ftdi-eeprom Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: Tool for reading/erasing/flashing FTDI USB chip eeproms ftdi-eeprom is a small tool for creating and uploading the configuration eeprom for the FTDI chip. This eeprom contains information such as vendor and product ID, manufacturer and product strings, revision, etc. debian/patches/0000755000000000000000000000000011575435151010624 5ustar debian/patches/02-ft2232c.diff0000644000000000000000000000142311575435151012762 0ustar --- ftdi-eeprom-0.3.orig/src/main.c +++ ftdi-eeprom-0.3/src/main.c @@ -205,8 +205,11 @@ int main(int argc, char *argv[]) i = ftdi_usb_open(&ftdi, 0x0403, 0x6001); if (i != 0) { - printf("Error: %s\n", ftdi.error_str); - exit (-1); + i = ftdi_usb_open(&ftdi, 0x0403, 0x6010); + if (i != 0) { + printf("Error: %s\n", ftdi.error_str); + exit (-1); + } } } } @@ -306,10 +309,9 @@ cleanup: if (_read > 0 || _erase > 0 || _flash > 0) { printf("FTDI close: %d\n", ftdi_usb_close(&ftdi)); + ftdi_deinit (&ftdi); } - ftdi_deinit (&ftdi); - cfg_free(cfg); printf("\n"); debian/patches/series0000644000000000000000000000003711575435134012042 0ustar 01-ft232r.diff 02-ft2232c.diff debian/patches/01-ft232r.diff0000644000000000000000000003223611575433642012727 0ustar diff --git a/src/main.c b/src/main.c index 7b0337b..81e6e93 100644 --- a/src/main.c +++ b/src/main.c @@ -25,35 +25,71 @@ #include #include -int main(int argc, char *argv[]) { +int str_to_cbus(char *str, int max_allowed) +{ + #define MAX_OPTION 14 + const char* options[MAX_OPTION] = { + "TXDEN", "PWREN", "RXLED", "TXLED", "TXRXLED", "SLEEP", + "CLK48", "CLK24", "CLK12", "CLK6", + "IO_MODE", "BITBANG_WR", "BITBANG_RD", "SPECIAL"}; + int i; + max_allowed += 1; + if (max_allowed > MAX_OPTION) max_allowed = MAX_OPTION; + for (i=0; i\n"); - - if (argc != 2 && argc != 3) { - printf("Syntax: %s [commands] config-file\n", argv[0]); - printf("Valid commands:\n"); - printf("--read-eeprom Read eeprom and write to -filename- from config-file\n"); - printf("--erase-eeprom Erase eeprom\n"); - printf("--flash-eeprom Flash eeprom\n"); - exit (-1); + + if (argc != 2 && argc != 3) + { + printf("Syntax: %s [commands] config-file\n", argv[0]); + printf("Valid commands:\n"); + printf("--read-eeprom Read eeprom and write to -filename- from config-file\n"); + printf("--erase-eeprom Erase eeprom\n"); + printf("--flash-eeprom Flash eeprom\n"); + exit (-1); } - - if (argc == 3) { - if (strcmp(argv[1], "--read-eeprom") == 0) - _read = 1; - if (strcmp(argv[1], "--erase-eeprom") == 0) - _erase = 1; - if (strcmp(argv[1], "--flash-eeprom") == 0) - _flash = 1; - - argc_filename = 2; - } else { - argc_filename = 1; + + if (argc == 3) + { + if (strcmp(argv[1], "--read-eeprom") == 0) + _read = 1; + if (strcmp(argv[1], "--erase-eeprom") == 0) + _erase = 1; + if (strcmp(argv[1], "--flash-eeprom") == 0) + _flash = 1; + + argc_filename = 2; + } + else + { + argc_filename = 1; } - if ((fp = fopen(argv[argc_filename], "r")) == NULL) { - printf ("Can't open configuration file\n"); - exit (-1); + if ((fp = fopen(argv[argc_filename], "r")) == NULL) + { + printf ("Can't open configuration file\n"); + exit (-1); } fclose (fp); @@ -99,14 +140,20 @@ int main(int argc, char *argv[]) { filename = cfg_getstr(cfg, "filename"); if (cfg_getbool(cfg, "self_powered") && cfg_getint(cfg, "max_power") > 0) - printf("Hint: Self powered devices should have a max_power setting of 0.\n"); + printf("Hint: Self powered devices should have a max_power setting of 0.\n"); ftdi_init(&ftdi); ftdi_eeprom_initdefaults (&eeprom); - eeprom.vendor_id = cfg_getint(cfg, "vendor_id"); eeprom.product_id = cfg_getint(cfg, "product_id"); - eeprom.BM_type_chip = cfg_getbool(cfg, "BM_type_chip"); + char *type = cfg_getstr(cfg, "chip_type"); + if (!strcmp(type, "BM")) { + eeprom.chip_type = TYPE_BM; + } else if (!strcmp(type, "R")) { + eeprom.chip_type = TYPE_R; + } else { + eeprom.chip_type = TYPE_AM; + } eeprom.self_powered = cfg_getbool(cfg, "self_powered"); eeprom.remote_wakeup = cfg_getbool(cfg, "remote_wakeup"); @@ -124,74 +171,147 @@ int main(int argc, char *argv[]) { eeprom.manufacturer = cfg_getstr(cfg, "manufacturer"); eeprom.product = cfg_getstr(cfg, "product"); eeprom.serial = cfg_getstr(cfg, "serial"); + eeprom.high_current = cfg_getbool(cfg, "high_current"); + eeprom.cbus_function[0] = str_to_cbus(cfg_getstr(cfg, "cbus0"), 13); + eeprom.cbus_function[1] = str_to_cbus(cfg_getstr(cfg, "cbus1"), 13); + eeprom.cbus_function[2] = str_to_cbus(cfg_getstr(cfg, "cbus2"), 13); + eeprom.cbus_function[3] = str_to_cbus(cfg_getstr(cfg, "cbus3"), 13); + eeprom.cbus_function[4] = str_to_cbus(cfg_getstr(cfg, "cbus4"), 9); + int invert = 0; + if (cfg_getbool(cfg, "invert_rxd")) invert |= INVERT_RXD; + if (cfg_getbool(cfg, "invert_txd")) invert |= INVERT_TXD; + if (cfg_getbool(cfg, "invert_rts")) invert |= INVERT_RTS; + if (cfg_getbool(cfg, "invert_cts")) invert |= INVERT_CTS; + if (cfg_getbool(cfg, "invert_dtr")) invert |= INVERT_DTR; + if (cfg_getbool(cfg, "invert_dsr")) invert |= INVERT_DSR; + if (cfg_getbool(cfg, "invert_dcd")) invert |= INVERT_DCD; + if (cfg_getbool(cfg, "invert_ri")) invert |= INVERT_RI; + eeprom.invert = invert; + + if (_read > 0 || _erase > 0 || _flash > 0) + { + i = ftdi_usb_open(&ftdi, eeprom.vendor_id, eeprom.product_id); - if (_read > 0 || _erase > 0 || _flash > 0) { - i = ftdi_usb_open(&ftdi, eeprom.vendor_id, eeprom.product_id); - - if (i != 0) { - printf("Unable to find FTDI devices under given vendor/product id: 0x%X/0x%X\n", eeprom.vendor_id, eeprom.product_id); - printf("Retrying with default FTDI id.\n"); - - i = ftdi_usb_open(&ftdi, 0x0403, 0x6001); - if (i != 0) { - printf("Error: %s\n", ftdi.error_str); - exit (-1); - } - } + if (i == 0) + { + printf("EEPROM size: %d\n", ftdi.eeprom_size); + } + else + { + printf("Unable to find FTDI devices under given vendor/product id: 0x%X/0x%X\n", eeprom.vendor_id, eeprom.product_id); + printf("Error code: %d (%s)\n", i, ftdi_get_error_string(&ftdi)); + printf("Retrying with default FTDI id.\n"); + + i = ftdi_usb_open(&ftdi, 0x0403, 0x6001); + if (i != 0) + { + printf("Error: %s\n", ftdi.error_str); + exit (-1); + } + } } - if (_read > 0) { - printf("FTDI read eeprom: %d\n", ftdi_read_eeprom(&ftdi, (char *)&eeprom_buf)); - if (filename != NULL && strlen(filename) > 0) { - FILE *fp = fopen (filename, "wb"); - fwrite (&eeprom_buf, 1, 128, fp); - fclose (fp); - } else { - printf("Warning: Not writing eeprom, you must supply a valid filename\n"); - } - - goto cleanup; + if (_read > 0) + { + printf("FTDI read eeprom: %d\n", ftdi_read_eeprom(&ftdi, eeprom_buf)); + + ftdi_eeprom_decode(&eeprom, eeprom_buf, ftdi.eeprom_size); + /* Debug output */ + /* + const char* chip_types[] = {"other", "BM", "R"}; + printf("vendor_id = \"%04x\"\n", eeprom.vendor_id); + printf("product_id = \"%04x\"\n", eeprom.product_id); + printf("chip_type = \"%s\"\n", + (eeprom.chip_type > 0x06) || (eeprom.chip_type & 0x01) ? "unknown": + chip_types[eeprom.chip_type>>1]); + printf("self_powered = \"%s\"\n", eeprom.self_powered?"true":"false"); + printf("remote_wakeup = \"%s\"\n", eeprom.remote_wakeup?"true":"false"); + printf("max_power = \"%d\"\n", eeprom.max_power); + printf("in_is_isochronous = \"%s\"\n", eeprom.in_is_isochronous?"true":"false"); + printf("out_is_isochronous = \"%s\"\n", eeprom.out_is_isochronous?"true":"false"); + printf("suspend_pull_downs = \"%s\"\n", eeprom.suspend_pull_downs?"true":"false"); + printf("use_serial = \"%s\"\n", eeprom.use_serial?"true":"false"); + printf("change_usb_version = \"%s\"\n", eeprom.change_usb_version?"true":"false"); + printf("usb_version = \"%d\"\n", eeprom.usb_version); + printf("manufacturer = \"%s\"\n", eeprom.manufacturer); + printf("product = \"%s\"\n", eeprom.product); + printf("serial = \"%s\"\n", eeprom.serial); + */ + + if (filename != NULL && strlen(filename) > 0) + { + FILE *fp = fopen (filename, "wb"); + fwrite (eeprom_buf, 1, 128, fp); + fclose (fp); + } + else + { + printf("Warning: Not writing eeprom, you must supply a valid filename\n"); + } + + goto cleanup; } - if (_erase > 0) { - printf("FTDI erase eeprom: %d\n", ftdi_erase_eeprom(&ftdi)); - } + if (_erase > 0) + { + printf("FTDI erase eeprom: %d\n", ftdi_erase_eeprom(&ftdi)); + } size_check = ftdi_eeprom_build(&eeprom, eeprom_buf); - if (size_check == -1) { - printf ("Sorry, the eeprom can only contain 128 bytes (100 bytes for your strings).\n"); - printf ("You need to short your string by: %d bytes\n", size_check); - goto cleanup; - } else { - printf ("Used eeprom space: %d bytes\n", 128-size_check); + + if (size_check == -1) + { + printf ("Sorry, the eeprom can only contain 128 bytes (100 bytes for your strings).\n"); + printf ("You need to short your string by: %d bytes\n", size_check); + goto cleanup; + } else if (size_check < 0) { + printf ("ftdi_eeprom_build(): error: %d\n", size_check); + } + else + { + printf ("Used eeprom space: %d bytes\n", 128-size_check); } - if (_flash > 0) { - printf ("FTDI write eeprom: %d\n", ftdi_write_eeprom(&ftdi, (char *)&eeprom_buf)); + if (_flash > 0) + { + if (cfg_getbool(cfg, "flash_raw")) + { + if (filename != NULL && strlen(filename) > 0) + { + FILE *fp = fopen(filename, "rb"); + fread(eeprom_buf, 1, 128, fp); + fclose(fp); + } + } + printf ("FTDI write eeprom: %d\n", ftdi_write_eeprom(&ftdi, eeprom_buf)); } // Write to file? - if (filename != NULL && strlen(filename) > 0) { + if (filename != NULL && strlen(filename) > 0) + { fp = fopen(filename, "w"); - if (fp == NULL) { - printf ("Can't write eeprom file.\n"); - exit (-1); - } else - printf ("Writing to file: %s\n", filename); - - fwrite(eeprom_buf, 128, 1, fp); - fclose(fp); + if (fp == NULL) + { + printf ("Can't write eeprom file.\n"); + exit (-1); + } + else + printf ("Writing to file: %s\n", filename); + + fwrite(eeprom_buf, 128, 1, fp); + fclose(fp); } cleanup: - if (_read > 0 || _erase > 0 || _flash > 0) { + if (_read > 0 || _erase > 0 || _flash > 0) + { printf("FTDI close: %d\n", ftdi_usb_close(&ftdi)); } ftdi_deinit (&ftdi); - + cfg_free(cfg); - + printf("\n"); return 0; } debian/ftdi_eeprom.10000644000000000000000000001051711575433762011566 0ustar .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH FTDI-EEPROM "1" "March 31, 2004" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME ftdi_eeprom \- Tool for reading/erasing/flashing FTDI USB chip eeproms .SH SYNOPSIS .B ftdi_eeprom .I [commands] config-file .SH DESCRIPTION .B ftdi_eeprom is a small tool for reading/erasing/flashing FTDI USB chip eeproms. It uses libftdi to access the chip, so you will need to have the required permissions on the device. The ftdi_sio module should not be loaded. You can prevent it to be automatically loaded by adding it to /etc/modprobe.d/blacklist. You have to unplug and replug your device to get the new values to be read. Otherwise, you will still get the old values. .SH COMMANDS .TP .B "\-\-read-eeprom" Read eeprom and write to \(hyfilename\(hy from config-file. .TP .B "\-\-erase-eeprom" Erase eeprom. .TP .B "\-\-flash-eeprom" Flash eeprom. .SH CONFIGURATION FILE .PP The configuration file contains a list of key-value pairs which will be used to flash an FTDI USB chip eeprom. Comments start with \fB#\fR. The beginning of such a file might look like the following: .PP .sp .RS .sp .nf vendor_id=0x0403 # Vendor ID product_id=0x6001 # Product ID max_power=0 # Max. power consumption: value * 2 mA. Use 0 if self_powered = true. ########### # Strings # ########### manufacturer="ACME Inc" # Manufacturer product="USB Serial Converter" # Product serial="08-15" # Serial .sp .fi .RE .sp .PP The example configuration file that could be found in \fI/usr/share/doc/ftdi-eeprom/examples\fR is quite well commented so you should be able to use it as a basis. The following keys are supported: .TP .B "vendor_id" Set the vendor ID of the device. This value could be entered in decimal or hexadecimal form, and should be in the range 0-65535 or 0x0000-0xffff, respectively. .TP .B "product_id" Set the product ID of the device. This value could be entered in decimal or hexadecimal form, and should be in the range 0-65535 or 0x0000-0xffff, respectively. .TP .B "max_power" Set the maximum current the device will use, in 2 mA unit. Use 0 if \fBself_powered\fR = true. .TP .B "manufacturer" Set the manufacturer string which normally holds the name of the manufacturer. .TP .B "product" Set the product string which normally holds the name of the product. .TP .B "serial" Set the serial string which normally holds the serial number of the product. .TP .B "self_powered" Specify if the device is self-powered or not. The value should be true or false. .TP .B "remote_wakeup" Specify if the device supports remote wake-ups. The value should be true or false. .TP .B "use_serial" If this value is set to true, the \fBserial\fR string will be used. Otherwise the default serial string will be used. .TP .B "BM_type_chip" This value have to be set to true if you are using a BM chip. .TP .B "in_is_isochronous" If set to true this option specify that the input endpoint is in isochronous mode. .TP .B "out_is_isochronous" If set to true this option specify that the output endpoint is in isochronous mode. .TP .B "suspend_pull_downs" If this value is set to true the pull downs are enabled during suspend for lower power consumption. .TP .B "change_usb_version" This value has to be set to true if you want to force the USB version using the \fBusb_version\fR key. Otherwise the default USB version will be used. .TP .B "usb_version" Set the USB version of the device. The \fBchange_usb_version\fR value has to be set to true. .TP .B "filename" Specify a filename if you want to dump the content of the eeprom into it. .SH AUTHOR ftdi_eeprom was written by Intra2net AG . .br This manual page was written by Aurelien Jarno for the Debian GNU/Linux system (but may be used by others). debian/examples0000644000000000000000000000002111575433762010735 0ustar src/example.conf debian/changelog0000644000000000000000000000466211575434373011064 0ustar ftdi-eeprom (0.3-2) unstable; urgency=low * Bumped Standards-Version to 3.9.2 (no changes). * Switched to 3.0 (quilt) format. * Backported FT232R support from git (closes: bug#602123). -- Aurelien Jarno Mon, 13 Jun 2011 18:20:11 +0200 ftdi-eeprom (0.3-1) unstable; urgency=low * New upstream version. -- Aurelien Jarno Fri, 27 Feb 2009 20:29:19 +0100 ftdi-eeprom (0.2-9) unstable; urgency=low * Add support for FT2232C (closes: bug#487570). * Bumped Standards-Version to 3.8.0 (no changes). -- Aurelien Jarno Mon, 23 Jun 2008 08:36:00 +0200 ftdi-eeprom (0.2-8) unstable; urgency=low * Bumped Standards-Version to 3.7.3 (no changes). * Use '\(hy' instead of '-' into the manpage. * Don't ignore make distclean errors. -- Aurelien Jarno Sun, 02 Mar 2008 18:32:17 +0100 ftdi-eeprom (0.2-7) unstable; urgency=low * Bumped Standards-Version to 3.7.2 (no changes). * Print a more detailed message in case of error, and added a note about ftdi_sio in the manpage. -- Aurelien Jarno Thu, 20 Jul 2006 23:10:24 +0200 ftdi-eeprom (0.2-6) unstable; urgency=low * Added a build-dependency on pkgconfig. -- Aurelien Jarno Mon, 23 Jan 2006 19:06:51 +0100 ftdi-eeprom (0.2-5) unstable; urgency=low * Fixed upstream URL. * Switch to pkg-config instead of libftdi-config * Build-depends on libftdi-dev (>= 0.7-2) to make sure the resulting binary is not linked with libusb-dev. -- Aurelien Jarno Sun, 22 Jan 2006 20:47:49 +0100 ftdi-eeprom (0.2-4) unstable; urgency=low * Don't segfault if a wrong command is passed (closes: bug#337239). * Bumped Standards-Version to 3.6.2 (no changes). -- Aurelien Jarno Thu, 3 Nov 2005 15:45:55 +0100 ftdi-eeprom (0.2-3) unstable; urgency=low * Build-Depends on libftdi-dev (>= 0.5-2) to make sure that it will be correctly build with the shared version of library on GNU/kFreeBSD. -- Aurelien Jarno Sat, 19 Mar 2005 00:57:10 +0000 ftdi-eeprom (0.2-2) unstable; urgency=low * Don't distribute upstream changelog as it is a zero byte file. -- Aurelien Jarno Mon, 7 Jun 2004 00:29:51 +0200 ftdi-eeprom (0.2-1) unstable; urgency=low * Initial Release (closes: bug#241149). -- Aurelien Jarno Wed, 31 Mar 2004 02:11:03 +0200 debian/compat0000644000000000000000000000000211575434103010367 0ustar 5 debian/source/0000755000000000000000000000000011575434021010470 5ustar debian/source/format0000644000000000000000000000001411575434021011676 0ustar 3.0 (quilt) debian/rules0000755000000000000000000000374211575434151010262 0ustar #!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) CFLAGS = -Wall CFLAGS += $(shell dpkg-buildflags --get CFLAGS) ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif build: build-stamp build-stamp: dh_testdir cp -f /usr/share/misc/config.sub config.sub cp -f /usr/share/misc/config.guess config.guess CFLAGS="$(CFLAGS)" ./configure \ --host=$(DEB_HOST_GNU_TYPE) \ --build=$(DEB_BUILD_GNU_TYPE) \ --prefix=/usr \ --mandir=\$${prefix}/share/man \ --infodir=\$${prefix}/share/info $(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp [ ! -f Makefile ] || $(MAKE) distclean -rm -f config.sub config.guess dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/ftdi-eeprom. $(MAKE) install DESTDIR=$(CURDIR)/debian/ftdi-eeprom # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installchangelogs dh_installdocs dh_installexamples # dh_install # dh_installmenu # dh_installdebconf # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime # dh_installinit # dh_installcron # dh_installinfo dh_installman dh_link dh_strip dh_compress dh_fixperms # dh_perl # dh_python # dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install debian/manpages0000644000000000000000000000002511575433762010716 0ustar debian/ftdi_eeprom.1