Hello Matthew and other usb_storage experts, I have an issue which I posted about on the OpenOCD mailing list, but I think this may be a better forum. I'm working with the NXP LPC1343 ARM Cortex-M3 microcontroller. This is a small one, it doesn't run Linux at all. It does however have a full speed USB 2.0 peripheral built-in. It has 32kb built-in flash for program storage. The flash can be programmed via SWD or via ISP bootloader. I don't have an SWD solution so I'm trying my luck with the bootloader. There are two flavors of the ISP bootloader, via UART and via USB. I like USB. The device enumerates as USB MSC if it is started in ISP mode and the USB cable is connected: --8<-- dmesg [93203.773040] usb 3-2: new full speed USB device using uhci_hcd and address 13 [93203.933590] usb 3-2: New USB device found, idVendor=04cc, idProduct=0003 [93203.933603] usb 3-2: New USB device strings: Mfr=4, Product=32, SerialNumber=72 [93203.933613] usb 3-2: Product: NXP LPC13XX IFLASH [93203.933620] usb 3-2: Manufacturer: NXP Semicond [93203.933627] usb 3-2: SerialNumber: ISP000000000 [93203.943708] scsi5 : usb-storage 3-2:1.0 [93226.183053] usb 3-2: reset full speed USB device using uhci_hcd and address 13 [93226.327196] scsi 5:0:0:0: Direct-Access NXP LPC134X IFLASH 1.0 PQ: 0 ANSI: 0 CCS [93226.342143] sd 5:0:0:0: [sdb] 68 512-byte logical blocks: (34.8 kB/34.0 KiB) [93226.345131] sd 5:0:0:0: [sdb] Write Protect is off [93226.345143] sd 5:0:0:0: [sdb] Mode Sense: 03 00 00 00 [93226.345151] sd 5:0:0:0: [sdb] Assuming drive cache: write through [93226.367057] sd 5:0:0:0: [sdb] Assuming drive cache: write through [93226.367074] sdb: [93226.391126] sd 5:0:0:0: [sdb] Assuming drive cache: write through [93226.391139] sd 5:0:0:0: [sdb] Attached SCSI removable disk -->8-- --8<-- lsusb -vs 13 Bus 003 Device 013: ID 04cc:0003 Philips Semiconductors Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x04cc Philips Semiconductors idProduct 0x0003 bcdDevice 5.01 iManufacturer 4 NXP Semicond iProduct 32 NXP LPC13XX IFLASH iSerial 72 ISP000000000 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 32 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xc0 Self Powered MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 8 Mass Storage bInterfaceSubClass 6 SCSI bInterfaceProtocol 80 Bulk (Zip) iInterface 98 Memory Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Device Status: 0x0001 Self Powered -->8-- --8<-- The User Manual from NXP for this microcontroller The LPC134x supports ISP from the USB port through enumeration as a Mass Storage Class (MSC) Device when connected to a USB host interface (Windows operating system only). -->8-- --8<-- me blindly trying a few sg commands # sg_inq -v /dev/sdb inquiry cdb: 12 00 00 00 24 00 standard INQUIRY: inquiry cdb: 12 00 00 00 25 00 inquiry: requested 37 bytes but got 36 bytes PQual=0 Device_type=0 RMB=1 version=0x00 [no conformance claimed] [AERC=0] [TrmTsk=0] NormACA=0 HiSUP=0 Resp_data_format=1 SCCS=1 ACC=0 TPGS=0 3PC=0 Protect=0 BQue=0 EncServ=0 MultiP=0 [MChngr=0] [ACKREQQ=0] Addr16=0 [RelAdr=0] WBus16=0 Sync=0 Linked=0 [TranDis=0] CmdQue=0 length=37 (0x25) Peripheral device type: disk Vendor identification: NXP Product identification: LPC134X IFLASH Product revision level: 1.0 inquiry cdb: 12 01 00 00 fc 00 inquiry: requested 252 bytes but got 36 bytes # sg_ident /dev/sdb Report identifying information command, device not ready # sg_get_config -v /dev/sdb inquiry cdb: 12 00 00 00 24 00 NXP LPC134X IFLASH 1.0 Peripheral device type: disk Get Configuration cdb: 46 00 00 00 00 00 00 20 00 00 <hangs here for ~60 seconds, followed by usb 3-2: reset in dmesg> get configuration: transport: Host_status=0x05 [DID_ABORT] Driver_status=0x00 [DRIVER_OK, SUGGEST_OK] Get Configuration command failed # -->8-- I don't quite understand why it needs to be limited to Windows only, but it seems that Linux does *something* different enough that it doesn't quite work for me. sdb mounts fine as vfat. In the mounted directory there's a single 32kb firmware.bin file, which contains the current flash memory contents. I can copy this file to make a backup of the program memory. The reprogramming procedure is to delete the file and then copy another file into the directory, with any name. That file's contents is then flashed over the previous firmware, and the program runs after the next reset. I rm, cp, umount and reset the chip, but it doesn't run my program. :\ Resetting again, into the USB ISP mode I can copy the firmware.bin file, and it reads back *almost* the same as what I copied there, except that it now has 1024 bytes of 0 prepended to it. Any ideas about why the device might get the impression that Linux wants to write two empty sectors before the real data? I appreciate any ideas and hints for further debugging that you may be able to offer. //Peter -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html