Send commitlog mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r1719 - developers/werner ([EMAIL PROTECTED])
   2. r1720 - developers/werner/notes ([EMAIL PROTECTED])
--- Begin Message ---
Author: werner
Date: 2007-04-10 06:19:31 +0200 (Tue, 10 Apr 2007)
New Revision: 1719

Added:
   developers/werner/openocd-multiple-usb-ids.patch
Log:
src/jtag/ft2232.c: support multiple USB ID pairs (ft2232_vid_pid)



Added: developers/werner/openocd-multiple-usb-ids.patch
===================================================================
--- developers/werner/openocd-multiple-usb-ids.patch    2007-04-09 21:22:49 UTC 
(rev 1718)
+++ developers/werner/openocd-multiple-usb-ids.patch    2007-04-10 04:19:31 UTC 
(rev 1719)
@@ -0,0 +1,276 @@
+--- openocd/src/jtag/ft2232.c.orig     2007-04-09 22:33:13.000000000 -0300
++++ openocd/src/jtag/ft2232.c  2007-04-10 00:57:02.000000000 -0300
+@@ -77,8 +77,11 @@
+ char *ft2232_device_desc = NULL;
+ char *ft2232_serial = NULL;
+ char *ft2232_layout = NULL;
+-u16 ft2232_vid = 0x0403;
+-u16 ft2232_pid = 0x6010;
++
++#define MAX_USB_IDS   8
++/* vid = pid = 0 marks the end of the list */
++static u16 ft2232_vid[MAX_USB_IDS+1] = { 0x0403, 0 };
++static u16 ft2232_pid[MAX_USB_IDS+1] = { 0x6010, 0 };
+ 
+ typedef struct ft2232_layout_s
+ {
+@@ -1227,55 +1230,23 @@
+       return ERROR_OK;
+ }
+ 
+-int ft2232_init(void)
+-{
+-      u8 latency_timer;
+-      u8 buf[1];
+-      int retval;
+-      u32 bytes_written;
+-      
+ #if BUILD_FT2232_FTD2XX == 1
++static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more)
++{
+       FT_STATUS status;
+       DWORD openex_flags = 0;
+       char *openex_string = NULL;
+-#endif
+-
+-      ft2232_layout_t *cur_layout = ft2232_layouts;
+-      
+-      if ((ft2232_layout == NULL) || (ft2232_layout[0] == 0))
+-      {
+-              ft2232_layout = "usbjtag";
+-              WARNING("No ft2232 layout specified, using default 'usbjtag'");
+-      }
+-      
+-      while (cur_layout->name)
+-      {
+-              if (strcmp(cur_layout->name, ft2232_layout) == 0)
+-              {
+-                      layout = cur_layout;
+-                      break;
+-              }
+-              cur_layout++;
+-      }
++      u8 latency_timer;
+ 
+-      if (!layout)
+-      {
+-              ERROR("No matching layout found for %s", ft2232_layout);
+-              return ERROR_JTAG_INIT_FAILED;
+-      }
+-      
+-#if BUILD_FT2232_FTD2XX == 1
+-      DEBUG("'ft2232' interface using FTD2XX with '%s' layout", 
ft2232_layout);
+-#elif BUILD_FT2232_LIBFTDI == 1
+-      DEBUG("'ft2232' interface using libftdi with '%s' layout", 
ft2232_layout);
+-#endif
++      DEBUG("'ft2232' interface using FTD2XX with '%s' layout",
++          ft2232_layout);
+ 
+-#if BUILD_FT2232_FTD2XX == 1
+ #if IS_WIN32 == 0
+       /* Add non-standard Vid/Pid to the linux driver */
+-      if ((status = FT_SetVIDPID(ft2232_vid, ft2232_pid)) != FT_OK)
++      if ((status = FT_SetVIDPID(ft2232_vid[0], ft2232_pid[0])) != FT_OK)
+       {
+-              WARNING("couldn't add %4.4x:%4.4x", ft2232_vid, ft2232_pid);
++              WARNING("couldn't add %4.4x:%4.4x",
++                  ft2232_vid[0], ft2232_pid[0]);
+       }
+ #endif
+ 
+@@ -1307,6 +1278,12 @@
+       {
+               DWORD num_devices;
+               
++              if (more) {
++                      WARNING("unable to open ftdi device (trying more): %lu",
++                          status);
++                      *try_more = 1;
++                      return ERROR_JTAG_INIT_FAILED;
++              }
+               ERROR("unable to open ftdi device: %lu", status);
+               status = FT_ListDevices(&num_devices, NULL, 
FT_LIST_NUMBER_ONLY);
+               if (status == FT_OK)
+@@ -1365,14 +1342,44 @@
+               ERROR("unable to enable bit i/o mode: %lu", status);
+               return ERROR_JTAG_INIT_FAILED;
+       }
+-#elif BUILD_FT2232_LIBFTDI == 1
++
++      return ERROR_OK;
++}
++
++static int ft2232_purge_ftd2xx(void)
++{
++      FT_STATUS status;
++
++      if ((status = FT_Purge(ftdih, FT_PURGE_RX | FT_PURGE_TX)) != FT_OK)
++      {
++              ERROR("error purging ftd2xx device: %lu", status);
++              return ERROR_JTAG_INIT_FAILED;
++      }
++
++      return ERROR_OK;
++}
++#endif /* BUILD_FT2232_FTD2XX == 1 */
++
++#if BUILD_FT2232_LIBFTDI == 1
++static int ft2232_init_libftdi(u16 vid, u16 pid, int more, int *try_more)
++{
++      u8 latency_timer;
++
++      DEBUG("'ft2232' interface using libftdi with '%s' layout",
++          ft2232_layout);
++
+       if (ftdi_init(&ftdic) < 0)
+               return ERROR_JTAG_INIT_FAILED;
+ 
+       /* context, vendor id, product id */
+-      if (ftdi_usb_open_desc(&ftdic, ft2232_vid, ft2232_pid, 
ft2232_device_desc, ft2232_serial) < 0)
+-      {
+-              ERROR("unable to open ftdi device: %s", ftdic.error_str);
++      if (ftdi_usb_open_desc(&ftdic, vid, pid, ft2232_device_desc,
++          ft2232_serial) < 0) {
++              if (more)
++                      WARNING("unable to open ftdi device (trying more): %s",
++                           ftdic.error_str);
++              else
++                      ERROR("unable to open ftdi device: %s", 
ftdic.error_str);
++              *try_more = 1;
+               return ERROR_JTAG_INIT_FAILED;
+       }
+ 
+@@ -1405,7 +1412,77 @@
+       }
+ 
+       ftdi_set_bitmode(&ftdic, 0x0b, 2); /* ctx, JTAG I/O mask */
++
++      return ERROR_OK;
++}
++
++static int ft2232_purge_libftdi(void)
++{
++      if (ftdi_usb_purge_buffers(&ftdic) < 0)
++      {
++              ERROR("ftdi_purge_buffers: %s", ftdic.error_str);
++              return ERROR_JTAG_INIT_FAILED;
++      }
++
++      return ERROR_OK;
++}
++#endif /* BUILD_FT2232_LIBFTDI == 1 */
++
++int ft2232_init(void)
++{
++      u8 buf[1];
++      int retval;
++      u32 bytes_written;
++      ft2232_layout_t *cur_layout = ft2232_layouts;
++      int i;
++      
++      if ((ft2232_layout == NULL) || (ft2232_layout[0] == 0))
++      {
++              ft2232_layout = "usbjtag";
++              WARNING("No ft2232 layout specified, using default 'usbjtag'");
++      }
++      
++      while (cur_layout->name)
++      {
++              if (strcmp(cur_layout->name, ft2232_layout) == 0)
++              {
++                      layout = cur_layout;
++                      break;
++              }
++              cur_layout++;
++      }
++
++      if (!layout)
++      {
++              ERROR("No matching layout found for %s", ft2232_layout);
++              return ERROR_JTAG_INIT_FAILED;
++      }
++      
++      for (i = 0; 1; i++) {
++              /*
++               * "more indicates that there are more IDs to try, so we should
++               * not print an error for an ID mismatch (but for anything
++               * else, we should).
++               *
++               * try_more indicates that the error code returned indicates an
++               * ID mismatch (and nothing else) and that we should proceeed
++               * with the next ID pair.
++               */
++              int more = ft2232_vid[i+1] || ft2232_pid[i+1];
++              int try_more = 0;
++
++#if BUILD_FT2232_FTD2XX == 1
++              retval = ft2232_init_ftd2xx(ft2232_vid[i], ft2232_pid[i],
++                  more, &try_more);
++#elif BUILD_FT2232_LIBFTDI == 1
++              retval = ft2232_init_libftdi(ft2232_vid[i], ft2232_pid[i],
++                  more, &try_more);
+ #endif        
++              if (retval >= 0)
++                      break;
++              if (!more || !try_more)
++                      return retval;
++      }
+ 
+       ft2232_buffer_size = 0;
+       ft2232_buffer = malloc(FT2232_BUFFER_SIZE);
+@@ -1423,17 +1500,9 @@
+       }
+ 
+ #if BUILD_FT2232_FTD2XX == 1
+-      if ((status = FT_Purge(ftdih, FT_PURGE_RX | FT_PURGE_TX)) != FT_OK)
+-      {
+-              ERROR("error purging ftd2xx device: %lu", status);
+-              return ERROR_JTAG_INIT_FAILED;
+-      }
++      return ft2232_purge_ftd2xx();
+ #elif BUILD_FT2232_LIBFTDI == 1
+-      if (ftdi_usb_purge_buffers(&ftdic) < 0)
+-      {
+-              ERROR("ftdi_purge_buffers: %s", ftdic.error_str);
+-              return ERROR_JTAG_INIT_FAILED;
+-      }
++      return ft2232_purge_libftdi();
+ #endif        
+ 
+       return ERROR_OK;
+@@ -1847,15 +1916,29 @@
+ 
+ int ft2232_handle_vid_pid_command(struct command_context_s *cmd_ctx, char 
*cmd, char **args, int argc)
+ {
+-      if (argc >= 2)
+-      {
+-              ft2232_vid = strtol(args[0], NULL, 0);
+-              ft2232_pid = strtol(args[1], NULL, 0);
++      int i;
++
++      if (argc > MAX_USB_IDS*2) {
++              WARNING("ignoring extra IDs in ft2232_vid_pid "
++                  "(maximum is %d pairs)", MAX_USB_IDS);
++              argc = MAX_USB_IDS*2;
+       }
+-      else
++      if (argc < 2 || (argc & 1))
+       {
+               WARNING("incomplete ft2232_vid_pid configuration directive");
++              if (argc < 2)
++                      return ERROR_OK;
+       }
+-      
++
++      for (i = 0; i+1 < argc; i += 2) {
++              ft2232_vid[i >> 1] = strtol(args[i], NULL, 0);
++              ft2232_pid[i >> 1] = strtol(args[i+1], NULL, 0);
++      }
++      /*
++       * Explicitly terminate, in case there are multiples instances of
++       * ft2232_vid_pid.
++       */
++      ft2232_vid[i >> 1] = ft2232_pid[i >> 1] = 0;
++
+       return ERROR_OK;
+ }




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2007-04-10 06:20:51 +0200 (Tue, 10 Apr 2007)
New Revision: 1720

Modified:
   developers/werner/notes/openocd
Log:
latest versions of OpenOCD and libftdi, and support for a list of USB ID pairs



Modified: developers/werner/notes/openocd
===================================================================
--- developers/werner/notes/openocd     2007-04-10 04:19:31 UTC (rev 1719)
+++ developers/werner/notes/openocd     2007-04-10 04:20:51 UTC (rev 1720)
@@ -1,14 +1,13 @@
-# Quick OpenOCD setup and usage notes (for JTAGkey - will need updating for
-# debug v2)
+# Quick OpenOCD setup and usage notes (for JTAGkey and debug v2)
 
 ###  SETUP  ###################################################################
 
 # Build libftdi (don't need to do this if you already have a recent version)
 
 cd $OMDIR
-wget 
http://www.intra2net.com/de/produkte/opensource/ftdi/TGZ/libftdi-0.8.tar.gz
-tar xfz libftdi-0.8.tar.gz
-cd libftdi-0.8
+wget 
http://www.intra2net.com/de/produkte/opensource/ftdi/TGZ/libftdi-0.9.tar.gz
+tar xfz libftdi-0.9.tar.gz
+cd libftdi-0.9
 automake
 autoconf
 ./configure
@@ -17,12 +16,12 @@
 make install
 ldconfig
 
-# Build openocd (don't need to do this if you already have it)
+# Build openocd
 
 cd $OMDIR
-svn -r 130 co svn://svn.berlios.de/openocd/trunk openocd
+svn -r 137 co svn://svn.berlios.de/openocd/trunk openocd
 cd openocd
-patch -p1 -s <$OMDIR/openmoko/devlopers/werner/openocd-wait-patiently.patch
+patch -p1 -s <$OMDIR/openmoko/developers/werner/openocd-multiple-usb-ids.patch
 ./bootstrap
 # enable parport_dev and ft2232, so that we stay compatible with the wiggler.
 # use libftdi since we don't want no binary-only code.
@@ -48,8 +47,8 @@
 # Get the config file. (JTAGkey version)
 
 wget http://people.openmoko.org/laforge/misc/openocd.cfg
-wget http://people.openmoko.org/werner/openocd-jtagkey.patch
-patch -p1 -s <openocd-jtagkey.patch
+wget http://people.openmoko.org/werner/openocd-ft2232.patch
+patch -p1 -s <openocd-ft2232.patch
 
 # Run openocd
 
@@ -63,10 +62,8 @@
 cd $OMDIR
 wget http://people.openmoko.org/laforge/tmp/bbt-20070206/lowlevel_foo.bin
 
-# Build a version of u-boot that can boot from JTAG
-# WARNING: you need to undo this if you want to build one that boots from NAND 
!
+# Build u-boot
 
-echo 'PLATFORM_RELFLAGS += -DBUILD_FOR_RAM' >> u-boot/board/neo1973/config.tmp
 make -C u-boot ARCH=arm
 
 




--- End Message ---
_______________________________________________
commitlog mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to