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. r1119 - trunk/oe/packages/s3c2410-utils
      ([EMAIL PROTECTED])
   2. r1120 - trunk/oe/conf/distro/include ([EMAIL PROTECTED])
   3. r1121 - trunk/src/target/u-boot/patches ([EMAIL PROTECTED])
   4. r1122 - trunk/src/target/u-boot/patches
      ([EMAIL PROTECTED])
   5. r1123 - trunk/src/host/dfu-util/src ([EMAIL PROTECTED])
   6. r1124 - trunk/src/target/u-boot/patches
      ([EMAIL PROTECTED])
--- Begin Message ---
Author: laforge
Date: 2007-02-25 17:31:35 +0100 (Sun, 25 Feb 2007)
New Revision: 1119

Modified:
   trunk/oe/packages/s3c2410-utils/sjf2410-linux-native_svn.bb
Log:
close bug #211:  run do_deploy earlier (Rod Whitby)


Modified: trunk/oe/packages/s3c2410-utils/sjf2410-linux-native_svn.bb
===================================================================
--- trunk/oe/packages/s3c2410-utils/sjf2410-linux-native_svn.bb 2007-02-25 
15:55:29 UTC (rev 1118)
+++ trunk/oe/packages/s3c2410-utils/sjf2410-linux-native_svn.bb 2007-02-25 
16:31:35 UTC (rev 1119)
@@ -29,4 +29,4 @@
        :
 }
 
-addtask deploy before do_build after do_compile
+addtask deploy before do_package after do_install




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-02-25 17:37:14 +0100 (Sun, 25 Feb 2007)
New Revision: 1120

Modified:
   trunk/oe/conf/distro/include/preferred-openmoko-versions.inc
Log:
add 'now' version for dfu-util


Modified: trunk/oe/conf/distro/include/preferred-openmoko-versions.inc
===================================================================
--- trunk/oe/conf/distro/include/preferred-openmoko-versions.inc        
2007-02-25 16:31:35 UTC (rev 1119)
+++ trunk/oe/conf/distro/include/preferred-openmoko-versions.inc        
2007-02-25 16:37:14 UTC (rev 1120)
@@ -14,6 +14,7 @@
 SRCDATE_linux-gta01-nobbt = "now"
 SRCDATE_s3c2410-boot-usb-native = "now"
 SRCDATE_sjf2410-linux-native = "now"
+SRCDATE_dfu-util-native = "now"
 
 SRCDATE_libgsmd = "now"
 SRCDATE_openmoko-session = "now"




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2007-02-25 21:08:11 +0100 (Sun, 25 Feb 2007)
New Revision: 1121

Added:
   trunk/src/target/u-boot/patches/mmc-fixes.patch
Log:
include/asm-arm/arch-s3c24x0/regs-sdi.h (S3C2410_SDIDCON_BLKNUM_MASK): typo,
  should be S3C2410_SDIDCNT_BLKNUM_MASK
cpu/arm920t/s3c24x0/mmc.c (mmc_block_read): use S3C2410_SDIDCON_BLKNUM instead
  of bogus S3C2410_SDIDCON_BLKNUM_MASK
cpu/arm920t/s3c24x0/mmc.c (mmc_block_read): check SDIDSTA after each FIFO read
  and clear any pending errors
cpu/arm920t/s3c24x0/mmc.c (mmc_block_read): commented out useless wait for
  S3C2410_SDIDSTA_XFERFINISH, added reset of S3C2410_SDIDSTA_XFERFINISH
cpu/arm920t/s3c24x0/mmc.c (mmc_cmd): removed unused variables "i" and "status"
cpu/arm920t/s3c24x0/mmc.c (mmc_init): removed unused variable "i"
cpu/arm920t/s3c24x0/mmc.c (mmc_init): replaced MMC CID extraction with SD CID
  version
cpu/arm920t/s3c24x0/mmc.c (mmc_init): added casts to suppress warnings when
  using an "unsigned char *" buffer in sprintf
include/configs/neo1973.h (CONFIG_SUPPORT_VFAT): just #define, to avoid
  conflict with include/fat.h
cpu/arm920t/s3c24x0/mmc.c (rca): set this 16 bit value to 1, not 1 << 16



Added: trunk/src/target/u-boot/patches/mmc-fixes.patch
===================================================================
--- trunk/src/target/u-boot/patches/mmc-fixes.patch     2007-02-25 16:37:14 UTC 
(rev 1120)
+++ trunk/src/target/u-boot/patches/mmc-fixes.patch     2007-02-25 20:08:11 UTC 
(rev 1121)
@@ -0,0 +1,231 @@
+include/asm-arm/arch-s3c24x0/regs-sdi.h (S3C2410_SDIDCON_BLKNUM_MASK): typo,
+  should be S3C2410_SDIDCNT_BLKNUM_MASK
+cpu/arm920t/s3c24x0/mmc.c (mmc_block_read): use S3C2410_SDIDCON_BLKNUM instead
+  of bogus S3C2410_SDIDCON_BLKNUM_MASK
+cpu/arm920t/s3c24x0/mmc.c (mmc_block_read): check SDIDSTA after each FIFO read
+  and clear any pending errors
+cpu/arm920t/s3c24x0/mmc.c (mmc_block_read): commented out useless wait for
+  S3C2410_SDIDSTA_XFERFINISH, added reset of S3C2410_SDIDSTA_XFERFINISH
+cpu/arm920t/s3c24x0/mmc.c (mmc_cmd): removed unused variables "i" and "status"
+cpu/arm920t/s3c24x0/mmc.c (mmc_init): removed unused variable "i" 
+cpu/arm920t/s3c24x0/mmc.c (mmc_init): replaced MMC CID extraction with SD CID
+  version
+cpu/arm920t/s3c24x0/mmc.c (mmc_init): added casts to suppress warnings when
+  using an "unsigned char *" buffer in sprintf
+include/configs/neo1973.h (CONFIG_SUPPORT_VFAT): just #define, to avoid
+  conflict with include/fat.h
+cpu/arm920t/s3c24x0/mmc.c (rca): set this 16 bit value to 1, not 1 << 16
+
+Index: u-boot/cpu/arm920t/s3c24x0/mmc.c
+===================================================================
+--- u-boot.orig/cpu/arm920t/s3c24x0/mmc.c
++++ u-boot/cpu/arm920t/s3c24x0/mmc.c
+@@ -60,8 +60,6 @@ static int wide = 0;
+ static u_int32_t *mmc_cmd(ushort cmd, ulong arg, ushort flags)
+ {
+       static u_int32_t resp[5];
+-      ulong status;
+-      int i;
+ 
+       u_int32_t ccon, csta;
+       u_int32_t csta_rdy_bit = S3C2410_SDICMDSTAT_CMDSENT;
+@@ -134,7 +132,7 @@ static int mmc_block_read(uchar *dst, ul
+       //sdi->SDIPRE = 0xff;
+ 
+       /* setup data */
+-      dcon = (len >> 9) & S3C2410_SDIDCON_BLKNUM_MASK;
++      dcon = (len >> 9) & S3C2410_SDIDCON_BLKNUM;
+       dcon |= S3C2410_SDIDCON_BLOCKMODE;
+       dcon |= S3C2410_SDIDCON_RXAFTERCMD|S3C2410_SDIDCON_XFER_RXSTART;
+       if (wide)
+@@ -145,16 +143,9 @@ static int mmc_block_read(uchar *dst, ul
+       resp = mmc_cmd(MMC_CMD_READ_BLOCK, src, CMD_F_RESP);
+ 
+       while (len > 0) {
+-              u_int32_t sdidsta = sdi->SDIDSTA;
+-              fifo = FIFO_FILL(sdi);
+-              if (sdidsta & (S3C2410_SDIDSTA_FIFOFAIL|
+-                              S3C2410_SDIDSTA_CRCFAIL|
+-                              S3C2410_SDIDSTA_RXCRCFAIL|
+-                              S3C2410_SDIDSTA_DATATIMEOUT)) {
+-                      printf("mmc_block_read: err SDIDSTA=0x%08x\n", sdidsta);
+-                      return -EIO;
+-              }
++              u_int32_t sdidsta, trouble;
+ 
++              fifo = FIFO_FILL(sdi);
+               while (fifo--) {
+                       //debug("dst_u32 = 0x%08x\n", dst_u32);
+                       *(dst_u32++) = sdi->SDIDAT;
+@@ -165,16 +156,32 @@ static int mmc_block_read(uchar *dst, ul
+                               break;
+                       }
+               }
++
++              sdidsta = sdi->SDIDSTA;
++              trouble = sdidsta &
++                      (S3C2410_SDIDSTA_FIFOFAIL |
++                      S3C2410_SDIDSTA_CRCFAIL   |
++                      S3C2410_SDIDSTA_RXCRCFAIL |
++                      S3C2410_SDIDSTA_DATATIMEOUT);
++              if (trouble) {
++                      printf("mmc_block_read: err SDIDSTA=0x%08x\n", sdidsta);
++                      sdi->SDIDSTA |= trouble;
++                      return -EIO;
++              }
+       }
+ 
++#if 0
+       debug("waiting for SDIDSTA  (currently 0x%08x\n", sdi->SDIDSTA);
+       while (!(sdi->SDIDSTA & (1 << 4))) {}
+       debug("done waiting for SDIDSTA (currently 0x%08x\n", sdi->SDIDSTA);
+ 
+       sdi->SDIDCON = 0;
++#endif
+ 
+-      if (!(sdi->SDIDSTA & S3C2410_SDIDSTA_XFERFINISH))
++      if (!(sdi->SDIDSTA & S3C2410_SDIDSTA_XFERFINISH)) {
+               debug("mmc_block_read; transfer not finished!\n");
++              sdi->SDIDSTA |= S3C2410_SDIDSTA_XFERFINISH;
++      }
+ 
+       return 0;
+ }
+@@ -318,7 +325,9 @@ ulong mmc_bread(int dev_num, ulong blknr
+       return blkcnt;
+ }
+ 
+-static u_int16_t rca = MMC_DEFAULT_RCA;
++/* MMC_DEFAULT_RCA should probably be just 1, but this may break other code
++   that expects it to be shifted. */
++static u_int16_t rca = MMC_DEFAULT_RCA >> 16;
+ 
+ static u_int32_t mmc_size(const struct mmc_csd *csd)
+ {
+@@ -331,6 +340,42 @@ static u_int32_t mmc_size(const struct m
+       return blocknr * block_len;
+ }
+ 
++struct sd_cid {
++      char            pnm_0;  /* product name */
++      char            oid_1;  /* OEM/application ID */
++      char            oid_0;
++      uint8_t         mid;    /* manufacturer ID */
++      char            pnm_4;
++      char            pnm_3;
++      char            pnm_2;
++      char            pnm_1;
++      uint8_t         psn_2;  /* product serial number */
++      uint8_t         psn_1;
++      uint8_t         psn_0;  /* MSB */
++      uint8_t         prv;    /* product revision */
++      uint8_t         crc;    /* CRC7 checksum, b0 is unused and set to 1 */
++      uint8_t         mdt_1;  /* manufacturing date, LSB, RRRRyyyy yyyymmmm */
++      uint8_t         mdt_0;  /* MSB */
++      uint8_t         psn_3;  /* LSB */
++};
++
++static void print_cid(const struct sd_cid *cid)
++{
++      printf("Manufacturer:       0x%02x, OEM \"%c%c\"\n",
++          cid->mid, cid->oid_0, cid->oid_1);
++      printf("Product name:       \"%c%c%c%c%c\", revision %d.%d\n",
++          cid->pnm_0, cid->pnm_1, cid->pnm_2, cid->pnm_3, cid->pnm_4,
++          cid->prv >> 4, cid->prv & 15);
++      printf("Serial number:      %u\n",
++          cid->psn_0 << 24 | cid->psn_1 << 16 | cid->psn_2 << 8 |
++          cid->psn_3);
++      printf("Manufacturing date: %d/%d\n",
++          cid->mdt_1 & 15,
++          2000+((cid->mdt_0 & 15) << 4)+((cid->mdt_1 & 0xf0) >> 4));
++      printf("CRC:                0x%02x, b0 = %d\n",
++          cid->crc >> 1, cid->crc & 1);
++}
++
+ int mmc_init(int verbose)
+ {
+       int retries, rc = -ENODEV;
+@@ -361,7 +406,6 @@ int mmc_init(int verbose)
+ 
+       printf("trying to detect SD Card...\n");
+       while (retries--) {
+-              int i;
+               udelay(100000);
+               resp = mmc_cmd(55, 0x00000000, CMD_F_RESP);
+               resp = mmc_cmd(41, 0x00300000, CMD_F_RESP);
+@@ -386,6 +430,7 @@ int mmc_init(int verbose)
+       /* try to get card id */
+       resp = mmc_cmd(MMC_CMD_ALL_SEND_CID, 0, CMD_F_RESP|CMD_F_RESP_LONG);
+       if (resp) {
++#if 0
+               /* TODO configure mmc driver depending on card attributes */
+               mmc_cid_t *cid = (mmc_cid_t *)resp;
+               if (verbose) {
+@@ -400,6 +445,29 @@ int mmc_init(int verbose)
+                       printf("Month = %d\n",cid->month);
+                       printf("Year = %d\n",1997 + cid->year);
+               }
++              sprintf(mmc_dev.vendor,"Man %02x%02x%02x Snr %02x%02x%02x",
++                              cid->id[0], cid->id[1], cid->id[2],
++                              cid->sn[0], cid->sn[1], cid->sn[2]);
++              sprintf(mmc_dev.product,"%s",cid->name);
++              sprintf(mmc_dev.revision,"%x %x",cid->hwrev, cid->fwrev);
++#else
++              struct sd_cid *cid = (struct sd_cid *) resp;
++
++              if (verbose)
++                      print_cid((struct sd_cid *) resp);
++
++              sprintf((char *) mmc_dev.vendor,
++                  "Man %02 OEM %c%c \"%c%c%c%c%c\"",
++                  cid->mid, cid->oid_0, cid->oid_1,
++                  cid->pnm_0, cid->pnm_1, cid->pnm_2, cid->pnm_3,
++                  cid->pnm_4);
++              sprintf((char *) mmc_dev.product, "%d",
++                  cid->psn_0 << 24 | cid->psn_1 << 16 | cid->psn_2 << 8 |
++                  cid->psn_3);
++              sprintf((char *) mmc_dev.revision, "%d.%d",
++                  cid->prv >> 4, cid->prv & 15);
++#endif
++
+               /* fill in device description */
+               mmc_dev.if_type = IF_TYPE_MMC;
+               mmc_dev.part_type = PART_TYPE_DOS;
+@@ -409,11 +477,6 @@ int mmc_init(int verbose)
+               /* FIXME fill in the correct size (is set to 32MByte) */
+               mmc_dev.blksz = 512;
+               mmc_dev.lba = 0x10000;
+-              sprintf(mmc_dev.vendor,"Man %02x%02x%02x Snr %02x%02x%02x",
+-                              cid->id[0], cid->id[1], cid->id[2],
+-                              cid->sn[0], cid->sn[1], cid->sn[2]);
+-              sprintf(mmc_dev.product,"%s",cid->name);
+-              sprintf(mmc_dev.revision,"%x %x",cid->hwrev, cid->fwrev);
+               mmc_dev.removable = 0;
+               mmc_dev.block_read = mmc_bread;
+ 
+Index: u-boot/include/asm-arm/arch-s3c24x0/regs-sdi.h
+===================================================================
+--- u-boot.orig/include/asm-arm/arch-s3c24x0/regs-sdi.h
++++ u-boot/include/asm-arm/arch-s3c24x0/regs-sdi.h
+@@ -62,7 +62,7 @@
+ #define S3C2410_SDIDCON_XFER_RXSTART  (2<<12)
+ #define S3C2410_SDIDCON_XFER_TXSTART  (3<<12)
+ 
+-#define S3C2410_SDIDCON_BLKNUM_MASK   (0xFFF)
++#define S3C2410_SDIDCNT_BLKNUM_MASK   (0xFFF)
+ #define S3C2410_SDIDCNT_BLKNUM_SHIFT  (12)
+ 
+ #define S3C2410_SDIDSTA_RDYWAITREQ    (1<<10)
+Index: u-boot/include/configs/neo1973.h
+===================================================================
+--- u-boot.orig/include/configs/neo1973.h
++++ u-boot/include/configs/neo1973.h
+@@ -224,7 +224,7 @@
+ #define CONFIG_EXT2           1
+ 
+ #define CONFIG_FAT            1
+-#define CONFIG_SUPPORT_VFAT   1
++#define CONFIG_SUPPORT_VFAT
+ 
+ #if 1
+ /* JFFS2 driver */




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-02-25 21:34:15 +0100 (Sun, 25 Feb 2007)
New Revision: 1122

Modified:
   trunk/src/target/u-boot/patches/uboot-dfu.patch
Log:
* get rid of bogus -EINVAL somewhere in source code
* implement the DFU state machine correctly (MANIFEST_SYNC -> IDLE transition)
* add 'proprietary' way to switch back from DFU to Runtime: DFU_DETACH in IDLE 
state + reset.


Modified: trunk/src/target/u-boot/patches/uboot-dfu.patch
===================================================================
--- trunk/src/target/u-boot/patches/uboot-dfu.patch     2007-02-25 20:08:11 UTC 
(rev 1121)
+++ trunk/src/target/u-boot/patches/uboot-dfu.patch     2007-02-25 20:34:15 UTC 
(rev 1122)
@@ -1,7 +1,7 @@
 Index: u-boot/drivers/usbdcore_ep0.c
 ===================================================================
 --- u-boot.orig/drivers/usbdcore_ep0.c 2007-02-25 15:37:52.000000000 +0100
-+++ u-boot/drivers/usbdcore_ep0.c      2007-02-25 15:37:53.000000000 +0100
++++ u-boot/drivers/usbdcore_ep0.c      2007-02-25 19:41:13.000000000 +0100
 @@ -42,10 +42,15 @@
   */
  
@@ -85,11 +85,21 @@
        /* handle USB Standard Request (c.f. USB Spec table 9-2) */
        if ((request->bmRequestType & USB_REQ_TYPE_MASK) != 0) {
                if (device->device_state <= STATE_CONFIGURED)
+@@ -570,7 +611,8 @@
+                       device->interface = le16_to_cpu (request->wIndex);
+                       device->alternate = le16_to_cpu (request->wValue);
+                       /*dbg_ep0(2, "set interface: %d alternate: %d", 
device->interface, device->alternate); */
+-                      serial_printf ("DEVICE_SET_INTERFACE.. event?\n");
++                      usbd_device_event_irq(device, DEVICE_SET_INTERFACE,
++                                              (request->wIndex << 16 | 
request->wValue));
+                       return 0;
+ 
+               case USB_REQ_GET_STATUS:
 Index: u-boot/drivers/usbdfu.c
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ u-boot/drivers/usbdfu.c    2007-02-25 16:40:12.000000000 +0100
-@@ -0,0 +1,863 @@
++++ u-boot/drivers/usbdfu.c    2007-02-25 21:30:18.000000000 +0100
+@@ -0,0 +1,911 @@
 +/*
 + * (C) 2007 by OpenMoko, Inc.
 + * Author: Harald Welte <[EMAIL PROTECTED]>
@@ -377,7 +387,7 @@
 +                              /* re-write dynenv marker in OOB */
 +                              run_command("dynenv set u-boot_env", 0);
 +                      }
-+                      ds->nand = NULL;-EINVAL;
++                      ds->nand = NULL;
 +                      free(ds->buf);
 +                      ds->ptr = ds->buf = ds->_buf;
 +                      break;
@@ -598,7 +608,6 @@
 +#endif
 +              break;
 +      case DFU_STATE_dfuMANIFEST_SYNC:
-+              dev->dfu_state = DFU_STATE_dfuMANIFEST;
 +              break;
 +      default:
 +              //return;
@@ -795,6 +804,15 @@
 +              case USB_REQ_DFU_GETSTATE:
 +                      handle_getstate(urb, len);
 +                      break;
++              case USB_REQ_DFU_DETACH:
++                      /* Proprietary extension: 'detach' from idle mode and
++                       * get back to runtime mode in case of USB Reset.  As
++                       * much as I dislike this, we just can't use every USB
++                       * bus reset to switch back to runtime mode, since at
++                       * least the Linux USB stack likes to send a number of 
resets
++                       * in a row :( */
++                      dev->dfu_state = DFU_STATE_dfuMANIFEST_WAIT_RST;
++                      break;
 +              default:
 +                      dev->dfu_state = DFU_STATE_dfuERROR;
 +                      ret = RET_STALL;
@@ -855,6 +873,8 @@
 +      case DFU_STATE_dfuMANIFEST_SYNC:
 +              switch (req) {
 +              case USB_REQ_DFU_GETSTATUS:
++                      /* We're MainfestationTolerant */
++                      dev->dfu_state = DFU_STATE_dfuIDLE;
 +                      handle_getstatus(urb, len);
 +                      break;
 +              case USB_REQ_DFU_GETSTATE:
@@ -867,6 +887,7 @@
 +              }
 +              break;
 +      case DFU_STATE_dfuMANIFEST:
++              /* we should never go here */
 +              dev->dfu_state = DFU_STATE_dfuERROR;
 +              ret = RET_STALL;
 +              break;
@@ -952,6 +973,43 @@
 +
 +      return 0;
 +}
++
++/* event handler for usb device state events */
++void dfu_event(struct usb_device_instance *device,
++             usb_device_event_t event, int data)
++{
++      switch (event) {
++      case DEVICE_SET_INTERFACE:
++              debug("SET_INTERFACE(%u,%u) old_state = %u ",
++                      device->interface, device->alternate,
++                      device->dfu_state);
++              switch (device->dfu_state) {
++              case DFU_STATE_appIDLE:
++              case DFU_STATE_appDETACH:
++              case DFU_STATE_dfuIDLE:
++              case DFU_STATE_dfuMANIFEST_WAIT_RST:
++                      /* do nothing, we're fine */
++                      break;
++              case DFU_STATE_dfuDNLOAD_SYNC:
++              case DFU_STATE_dfuDNBUSY:
++              case DFU_STATE_dfuDNLOAD_IDLE:
++              case DFU_STATE_dfuMANIFEST:
++                      device->dfu_state = DFU_STATE_dfuERROR;
++                      device->dfu_status = DFU_STATUS_errNOTDONE;
++                      break;
++              case DFU_STATE_dfuMANIFEST_SYNC:
++              case DFU_STATE_dfuUPLOAD_IDLE:
++              case DFU_STATE_dfuERROR:
++                      device->dfu_state = DFU_STATE_dfuERROR;
++                      device->dfu_status = DFU_STATUS_errUNKNOWN;
++                      break;
++              }
++              debug("new_state = %u\n", device->dfu_state);
++              break;
++      default:
++              break;
++      }
++}
 +#endif /* CONFIG_USBD_DFU */
 Index: u-boot/drivers/Makefile
 ===================================================================
@@ -969,7 +1027,7 @@
 Index: u-boot/drivers/usbdcore.c
 ===================================================================
 --- u-boot.orig/drivers/usbdcore.c     2007-02-25 15:36:49.000000000 +0100
-+++ u-boot/drivers/usbdcore.c  2007-02-25 15:37:53.000000000 +0100
++++ u-boot/drivers/usbdcore.c  2007-02-25 21:29:47.000000000 +0100
 @@ -31,6 +31,7 @@
  
  #include <malloc.h>
@@ -1014,17 +1072,19 @@
        if ((alternate < 0) || (alternate >= interface_instance->alternates)) {
                return NULL;
        }
-@@ -623,6 +639,18 @@
+@@ -623,6 +639,20 @@
        case DEVICE_RESET:
                device->device_state = STATE_DEFAULT;
                device->address = 0;
 +#ifdef CONFIG_USBD_DFU
 +              switch (device->dfu_state) {
++              case DFU_STATE_appIDLE:
++                      break;
 +              case DFU_STATE_appDETACH:
 +                      printf("DFU: Switching to DFU Mode\n");
 +                      device->dfu_state = DFU_STATE_dfuIDLE;
 +                      break;
-+              case DFU_STATE_dfuMANIFEST:
++              case DFU_STATE_dfuMANIFEST_WAIT_RST:
 +                      printf("DFU: Switching back to Runtime mode\n");
 +                      device->dfu_state = DFU_STATE_appIDLE;
 +                      break;
@@ -1033,10 +1093,18 @@
                break;
  
        case DEVICE_ADDRESS_ASSIGNED:
+@@ -681,4 +711,7 @@
+               /* usbdbg("calling device->event"); */
+               device->event(device, event, data);
+       }
++#ifdef CONFIG_USBD_DFU
++      dfu_event(device, event, data);
++#endif
+ }
 Index: u-boot/drivers/usbtty.c
 ===================================================================
 --- u-boot.orig/drivers/usbtty.c       2007-02-25 15:37:52.000000000 +0100
-+++ u-boot/drivers/usbtty.c    2007-02-25 15:37:53.000000000 +0100
++++ u-boot/drivers/usbtty.c    2007-02-25 19:36:45.000000000 +0100
 @@ -31,6 +31,8 @@
  #include "usbtty.h"
  #include "usb_cdc_acm.h"
@@ -1118,8 +1186,8 @@
 Index: u-boot/include/usb_dfu.h
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ u-boot/include/usb_dfu.h   2007-02-25 15:37:53.000000000 +0100
-@@ -0,0 +1,91 @@
++++ u-boot/include/usb_dfu.h   2007-02-25 20:24:52.000000000 +0100
+@@ -0,0 +1,94 @@
 +#ifndef _DFU_H
 +#define _DFU_H
 +
@@ -1210,6 +1278,9 @@
 +
 +int dfu_ep0_handler(struct urb *urb);
 +
++void dfu_event(struct usb_device_instance *device,
++             usb_device_event_t event, int data);
++
 +#endif /* _DFU_H */
 Index: u-boot/include/usb_dfu_descriptors.h
 ===================================================================




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-02-25 21:35:03 +0100 (Sun, 25 Feb 2007)
New Revision: 1123

Modified:
   trunk/src/host/dfu-util/src/main.c
   trunk/src/host/dfu-util/src/sam7dfu.c
Log:
* add explicit 'Reset after transfer' switch (--reset -R)
* correctly implement MANIFEST/MANIFEST_SYNC/IDLE stat transition after transfer


Modified: trunk/src/host/dfu-util/src/main.c
===================================================================
--- trunk/src/host/dfu-util/src/main.c  2007-02-25 20:34:15 UTC (rev 1122)
+++ trunk/src/host/dfu-util/src/main.c  2007-02-25 20:35:03 UTC (rev 1123)
@@ -264,6 +264,7 @@
                "  -t --transfer-size\t\tSpecify the number of bytes per USB 
Transfer\n"
                "  -U --upload file\t\tRead firmware from device into <file>\n"
                "  -D --download file\t\tWrite firmware from <file> into 
device\n"
+               "  -R --reset\t\t\tIssue USB Reset signalling once we're 
finished\n"
                );
 }
 
@@ -282,6 +283,7 @@
        { "transfer-size", 1, 0, 't' },
        { "upload", 1, 0, 'U' },
        { "download", 1, 0, 'D' },
+       { "reset", 1, 0, 'R' },
 };
 
 enum mode {
@@ -301,6 +303,7 @@
        struct dfu_status status;
        struct usb_dfu_func_descriptor func_dfu;
        char *filename = NULL;
+       int final_reset = 0;
        
        printf("dfu-util - (C) 2007 by OpenMoko Inc.\n"
               "This program is Free Software and has ABSOLUTELY NO 
WARRANTY\n\n");
@@ -314,7 +317,7 @@
 
        while (1) {
                int c, option_index = 0;
-               c = getopt_long(argc, argv, "hVvld:c:i:a:t:U:D:", opts, 
&option_index);
+               c = getopt_long(argc, argv, "hVvld:c:i:a:t:U:D:R", opts, 
&option_index);
                if (c == -1)
                        break;
 
@@ -369,6 +372,9 @@
                        mode = MODE_DOWNLOAD;
                        filename = optarg;
                        break;
+               case 'R':
+                       final_reset = 1;
+                       break;
                default:
                        help();
                        exit(2);
@@ -442,7 +448,8 @@
                printf("state = %s, status = %d\n", 
dfu_state_to_string(status.bState), status.bStatus);
 
                switch (status.bState) {
-               case STATE_APP_IDLE:
+               case DFU_STATE_appIDLE:
+               case DFU_STATE_appDETACH:
                        printf("Device really in Runtime Mode, send DFU detach 
request...\n");
                        if (dfu_detach(_rt_dif.dev_handle, _rt_dif.interface, 
1000) < 0) {
                                fprintf(stderr, "error detaching: %s\n", 
usb_strerror());
@@ -455,7 +462,7 @@
                        }
                        sleep(2);
                        break;
-               case STATE_DFU_ERROR:
+               case DFU_STATE_dfuERROR:
                        printf("dfuERROR, clearing status\n");
                        if (dfu_clear_status(_rt_dif.dev_handle, 
_rt_dif.interface) < 0) {
                                fprintf(stderr, "error clear_status: %s\n", 
usb_strerror());
@@ -463,9 +470,9 @@
                                break;
                        }
                        break;
-               case STATE_DFU_IDLE:
-                       printf("Device already in dfuIDLE ?!?, continuing\n");
-                       goto already_idle;
+               default:
+                       printf(stderr, "IMPOSSIBLE: Runtime device already in 
DFU state ?!?\n");
+                       exit(1);
                        break;
                }
 
@@ -497,7 +504,6 @@
                 * procedure */
        }
 
-already_idle:
        num_ifs = count_dfu_interfaces(dif->dev);
        if (num_ifs < 0) {
                fprintf(stderr, "No DFU Interface after RESET?!?\n");
@@ -522,7 +528,6 @@
        }
 #endif
        printf("Claiming USB DFU Interface...\n");
-       printf("%p (%d)\n", dif->dev_handle, *(int *)dif->dev_handle);
        if (usb_claim_interface(dif->dev_handle, dif->interface) < 0) {
                fprintf(stderr, "Cannot claim interface: %s\n", usb_strerror());
                exit(1);
@@ -619,6 +624,17 @@
                exit(1);
        }
 
+       if (final_reset) {
+               if (dfu_detach(dif->dev_handle, dif->interface, 1000) < 0) {
+                       fprintf("can't detach: %s\n", usb_strerror());
+               }
+               printf("Resetting USB to swithc back to runtime mode\n");
+               if (usb_reset(dif->dev_handle) < 0) {
+                       fprintf(stderr, "error resetting after download: %s\n", 
+                       usb_strerror());
+               }
+       }
+
        exit(0);
 }
 

Modified: trunk/src/host/dfu-util/src/sam7dfu.c
===================================================================
--- trunk/src/host/dfu-util/src/sam7dfu.c       2007-02-25 20:34:15 UTC (rev 
1122)
+++ trunk/src/host/dfu-util/src/sam7dfu.c       2007-02-25 20:35:03 UTC (rev 
1123)
@@ -117,19 +117,33 @@
        
        printf("] finished!\n");
 
+get_status:
        /* Transition to MANIFEST_SYNC state */
        ret = dfu_get_status(usb_handle, interface, &dst);
        if (ret < 0) {
-               fprintf(stderr, "unable to transition to MANIFEST state\n");
+               fprintf(stderr, "unable to read DFU status\n");
                goto out_close;
        }
-               
+       printf("state(%u) = %s, status(%u) = %s\n", dst.bState, 
+               dfu_state_to_string(dst.bState), dst.bStatus,
+               dfu_status_to_string(dst.bStatus));
+
+       /* FIXME: deal correctly with ManifestationTolerant=0 / WillDetach bits 
*/
+       switch (dst.bState) {
+       case DFU_STATE_dfuMANIFEST_SYNC:
+       case DFU_STATE_dfuMANIFEST:
+               goto get_status;
+               break;
+       case DFU_STATE_dfuIDLE:
+               break;
+       }
+#if 0
        printf("Resetting USB...\n");
-       sleep(1);
        if (usb_reset(usb_handle) < 0) {
                fprintf(stderr, "error resetting after download: %s\n", 
                        usb_strerror());
        }
+#endif
        printf("Done!\n");
 out_close:
        close(fd);




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-02-25 21:45:53 +0100 (Sun, 25 Feb 2007)
New Revision: 1124

Modified:
   trunk/src/target/u-boot/patches/uboot-dfu.patch
Log:
* one less #ifdef section for usbdcore.c
* if stdout is usbtty, switch it to vga until we get back from DFU mode


Modified: trunk/src/target/u-boot/patches/uboot-dfu.patch
===================================================================
--- trunk/src/target/u-boot/patches/uboot-dfu.patch     2007-02-25 20:35:03 UTC 
(rev 1123)
+++ trunk/src/target/u-boot/patches/uboot-dfu.patch     2007-02-25 20:45:53 UTC 
(rev 1124)
@@ -98,8 +98,8 @@
 Index: u-boot/drivers/usbdfu.c
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ u-boot/drivers/usbdfu.c    2007-02-25 21:30:18.000000000 +0100
-@@ -0,0 +1,911 @@
++++ u-boot/drivers/usbdfu.c    2007-02-25 21:44:46.000000000 +0100
+@@ -0,0 +1,940 @@
 +/*
 + * (C) 2007 by OpenMoko, Inc.
 + * Author: Harald Welte <[EMAIL PROTECTED]>
@@ -974,11 +974,40 @@
 +      return 0;
 +}
 +
++static int stdout_switched;
++
 +/* event handler for usb device state events */
 +void dfu_event(struct usb_device_instance *device,
 +             usb_device_event_t event, int data)
 +{
++      char *out;
++
 +      switch (event) {
++      case DEVICE_RESET:
++              switch (device->dfu_state) {
++              case DFU_STATE_appDETACH:
++                      device->dfu_state = DFU_STATE_dfuIDLE;
++                      out = getenv("stdout");
++                      if (out && !strcmp(out, "usbtty")) {
++                              setenv("stdout", "vga");
++                              setenv("stderr", "vga");
++                              stdout_switched = 1;
++                      }
++                      printf("DFU: Switching to DFU Mode\n");
++                      break;
++              case DFU_STATE_dfuMANIFEST_WAIT_RST:
++                      device->dfu_state = DFU_STATE_appIDLE;
++                      printf("DFU: Switching back to Runtime mode\n");
++                      if (stdout_switched) {
++                              setenv("stdout", "usbtty");
++                              setenv("stderr", "usbtty");
++                              stdout_switched = 0;
++                      }
++                      break;
++              default:
++                      break;
++              }
++              break;
 +      case DEVICE_SET_INTERFACE:
 +              debug("SET_INTERFACE(%u,%u) old_state = %u ",
 +                      device->interface, device->alternate,
@@ -1027,7 +1056,7 @@
 Index: u-boot/drivers/usbdcore.c
 ===================================================================
 --- u-boot.orig/drivers/usbdcore.c     2007-02-25 15:36:49.000000000 +0100
-+++ u-boot/drivers/usbdcore.c  2007-02-25 21:29:47.000000000 +0100
++++ u-boot/drivers/usbdcore.c  2007-02-25 21:38:24.000000000 +0100
 @@ -31,6 +31,7 @@
  
  #include <malloc.h>
@@ -1072,28 +1101,7 @@
        if ((alternate < 0) || (alternate >= interface_instance->alternates)) {
                return NULL;
        }
-@@ -623,6 +639,20 @@
-       case DEVICE_RESET:
-               device->device_state = STATE_DEFAULT;
-               device->address = 0;
-+#ifdef CONFIG_USBD_DFU
-+              switch (device->dfu_state) {
-+              case DFU_STATE_appIDLE:
-+                      break;
-+              case DFU_STATE_appDETACH:
-+                      printf("DFU: Switching to DFU Mode\n");
-+                      device->dfu_state = DFU_STATE_dfuIDLE;
-+                      break;
-+              case DFU_STATE_dfuMANIFEST_WAIT_RST:
-+                      printf("DFU: Switching back to Runtime mode\n");
-+                      device->dfu_state = DFU_STATE_appIDLE;
-+                      break;
-+              }
-+#endif
-               break;
- 
-       case DEVICE_ADDRESS_ASSIGNED:
-@@ -681,4 +711,7 @@
+@@ -681,4 +697,7 @@
                /* usbdbg("calling device->event"); */
                device->event(device, event, data);
        }




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

Reply via email to