libftdi-git Archives

Subject: utility to write the EEPROM connected to a FTDI USB-chip branch, master, updated. v0.3-8-g3cef016

From: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Sat, 14 Mar 2009 23:08:52 +0100 (CET)
The branch, master has been updated
       via  3cef01611b32299ef62e294db1a725c73ef7b6f8 (commit)
       via  316b8c40049f6d0ae57911bce4e9cf19831b0d34 (commit)
       via  13a25f0fce452792ba912b37d6cb87e512c864fb (commit)
       via  b53be740af9b76c412ec208186ef15c9c1abd5da (commit)
       via  57ed2a4a5ed98a6544272b45ffa491404eda5d9f (commit)
      from  aa028e8b0f9a222f9ec018fd581fcda6f0a22732 (commit)


- Log -----------------------------------------------------------------
commit 3cef01611b32299ef62e294db1a725c73ef7b6f8
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date:   Sat Mar 14 22:54:54 2009 +0100

    Updated ChangeLog

commit 316b8c40049f6d0ae57911bce4e9cf19831b0d34
Author: Marius Kintel <kintel@xxxxxx>
Date:   Mon Mar 2 18:39:42 2009 +0100

    Adapted to new decode size parameter, disable debug output

commit 13a25f0fce452792ba912b37d6cb87e512c864fb
Author: Marius Kintel <kintel@xxxxxx>
Date:   Wed Feb 25 18:14:11 2009 +0100

    uncommented decoding and debug printing of eeprom contents

commit b53be740af9b76c412ec208186ef15c9c1abd5da
Author: Marius Kintel <kintel@xxxxxx>
Date:   Thu Feb 19 17:37:47 2009 +0100

    Added code to test decode function

commit 57ed2a4a5ed98a6544272b45ffa491404eda5d9f
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date:   Sat Mar 14 22:33:52 2009 +0100

    Improve source package generator, remove unused "patch" version level

-----------------------------------------------------------------------

Summary of changes:
 CMakeLists.txt |    7 +++++--
 ChangeLog      |    3 ++-
 src/main.c     |   43 ++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b447b3f..a2bcb9b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,7 @@
 project(ftdi_eeprom)
 set(MAJOR_VERSION 0)
 set(MINOR_VERSION 4)
-set(PATCH_VERSION 0)
-set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION})
+set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
 set(VERSION ${MAJOR_VERSION}.${MINOR_VERSION})
 
 # CMake
@@ -58,6 +57,10 @@ if(${WIN32})
   set(CPACK_NSIS_MODIFY_PATH             "ON")
 endif(${WIN32})
 
+set(CPACK_SOURCE_GENERATOR             TGZ)
+set(CPACK_SOURCE_IGNORE_FILES          "\\\\.git")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME     ${CPACK_PACKAGE_FILE_NAME})
+
 set(CPACK_RESOURCE_FILE_LICENSE        ${CMAKE_SOURCE_DIR}/COPYING)
 
 # Subdirectories
diff --git a/ChangeLog b/ChangeLog
index 2e66b1f..0bfb2bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 New in 0.4 - 2009-XX-XX
 -----------------------
-* cmake support (Marius Kintel)
+* Ability to flash raw eeprom files (Marius Kintel)
+* cmake support (Marius Kintel and Intra2net)
 * Updated autoconf suite
 
 New in 0.3 - 2009-02-16
diff --git a/src/main.c b/src/main.c
index 7b0337b..f42f642 100644
--- a/src/main.c
+++ b/src/main.c
@@ -46,6 +46,7 @@ int main(int argc, char *argv[]) {
        CFG_STR("product", "USB Serial Converter", 0),
        CFG_STR("serial", "08-15", 0),
        CFG_STR("filename", "", 0),
+       CFG_BOOL("flash_raw", cfg_false, 0),
        CFG_END()
     };
     cfg_t *cfg;
@@ -103,7 +104,6 @@ int main(int argc, char *argv[]) {
 
     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");
@@ -125,11 +125,16 @@ int main(int argc, char *argv[]) {
     eeprom.product = cfg_getstr(cfg, "product");
     eeprom.serial = cfg_getstr(cfg, "serial");
 
+
     if (_read > 0 || _erase > 0 || _flash > 0) {
        i = ftdi_usb_open(&ftdi, eeprom.vendor_id, eeprom.product_id);
        
-       if (i != 0) {
+       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);
@@ -141,10 +146,31 @@ int main(int argc, char *argv[]) {
     }
 
     if (_read > 0) {
-        printf("FTDI read eeprom: %d\n", ftdi_read_eeprom(&ftdi, (char 
*)&eeprom_buf));
+      printf("FTDI read eeprom: %d\n", ftdi_read_eeprom(&ftdi, (char 
*)eeprom_buf));
+
+        ftdi_eeprom_decode(&eeprom, eeprom_buf, ftdi.eeprom_size);
+        /* Debug output */
+        /*
+        printf("vendor_id = \"%04x\"\n", eeprom.vendor_id);
+        printf("product_id = \"%04x\"\n", eeprom.product_id);
+        printf("BM_type_chip = \"%s\"\n", eeprom.BM_type_chip?"true":"false");
+        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);
+           fwrite (eeprom_buf, 1, 128, fp);
            fclose (fp);
        } else {
            printf("Warning: Not writing eeprom, you must supply a valid 
filename\n");
@@ -167,7 +193,14 @@ int main(int argc, char *argv[]) {
     }
 
     if (_flash > 0) {
-       printf ("FTDI write eeprom: %d\n", ftdi_write_eeprom(&ftdi, (char 
*)&eeprom_buf));
+      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, (char 
*)eeprom_buf));
     }
 
     // Write to file?


hooks/post-receive
-- 
utility to write the EEPROM connected to a FTDI USB-chip

--
libftdi-git - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread
  • utility to write the EEPROM connected to a FTDI USB-chip branch, master, updated. v0.3-8-g3cef016, libftdi-git <=