2010-11-04 11:10:49 USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Gilbert Inho (FRANCE)
Message: 95563
Hello,
1) Hardware and Software configuration used
1.1) I have a custom board based on BF537 processor with an USB host controller Renesas R8A66957. An on-chip hub SMSC USB2513 is connected to one of the 2 ports of the R8A66597 to add 3 more USB ports. The Renesas host controller is clocked at 24 MHz.
1.2) The uclinux distribution used is 2009R1.1_RC4. The kernel is Linux release 2.6.28.10-ADI-2009R1.1. Toolchain: bfin-uclinux-gcc release gcc version 4.1.2 (ADI svn).
1.3) In the .c file of my custom board in arch/blackfin/mach-bf537/boards I add the Renesas host controller like that:
#if defined(CONFIG_USB_R8A66597_HCD) || defined(CONFIG_USB_R8A66597_HCD_MODULE)
static struct resource r8a66597_usb_host_resources[] = {
[0] = {
.name = "r8a66597_hcd",
.start = 0x20300000, //address for my custom board
.end = 0x203000E5,
.flags = IORESOURCE_MEM,
},
[1] = {
.name = "r8a66597_hcd",
.start = IRQ_PF4, //custom board
.end = IRQ_PF4,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device r8a66597_usb_host_device = {
.name = "r8a66597_hcd",
.id = -1,
.dev = {
.dma_mask = NULL,
.coherent_dma_mask = 0xffffffff,
},
.num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
.resource = r8a66597_usb_host_resources,
};
#endif
and I add r8a66597_usb_host_device struct to the list of the board's platform devices.
1.4) Here are the kernel config done in the qconf for:
- Host controller Renesas:
* Support for Host-side USB
* USB verbose debug message
* USB announce new devices
* USB device filesystem
*USB device class-devices
*USB monitor
* R8A66597 HCD support
- USB-serial converter FTDI:
* USB serial Converter Support
* USB FTDI Single Port Serial Driver
- USB key:
* USB support --->
<*> USB Mass Storage support <*>USB Mass Storage verbose debug
SCSI device support --->
--- SCSI device support
<*> SCSI disk support
[*] Probe all LUNs on each SCSI device
* File systems --->
DOS/FAT/NT Filesystems --->
<*> MSDOS fs support
<*> VFAT (Windows-95) fs support
(437) Default codepage for FAT
(iso8859-1) Default iocharset for FAT
Native Language Support --->
--- Base native language support
(iso8859-1) Default NLS Option
<*> Codepage 437 (United States, Canada)
<*> NLS ISO 8859-1 (Latin 1; Western European Languages)
1.5) The parameters of the driver module of the host controller r8a66597-hcd.c set:
- input clock= 24 MHz (custom)
- input vif = 3,3V (default)
- endian: little (default)
- IRQ sense: low level (default)
2) What I can do:
- The host controller Renesas is recognized by the kernel. The Hub and all the USB ports are detected.
kernel logs:
r8a66597_hcd: driver r8a66597_hcd, 10 Apr 2008
r8a66597_hcd r8a66597_hcd: USB Host Controller
r8a66597_hcd r8a66597_hcd: new USB bus registered, assigned bus number 1
r8a66597_hcd r8a66597_hcd: irq 54, io base 0x20300000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: USB Host Controller
usb usb1: Manufacturer: Linux 2.6.28.10-ADI-2009R1.1 r8a66597_hcd
usb usb1: SerialNumber: r8a66597_hcd
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver
usb 1-2: new high speed USB device using r8a66597_hcd and address 2
usb 1-2: configuration #1 chosen from 1 choice
hub 1-2:1.0: USB hub found
hub 1-2:1.0: 4 ports detected
usb 1-2: New USB device found, idVendor=0424, idProduct=2514
usb 1-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
- The USB key is detected on each USB port: a block device /dev/sda1 is well dynamically created and the file system can be mounted successfully (with mount -t vfat /dev/sda1 /mnt)
logs:
usb 1-1: new high speed USB device using r8a66597_hcd and address 4
usb 1-1: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
usb 1-1: New USB device found, idVendor=0204, idProduct=6025
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: USB_2.0
usb 1-1: Manufacturer: CBM
usb 1-1: SerialNumber: 0614470077E00C08
usb 1-1: address 4, EndpointAddress 0x01 use DMA FIFO
usb 1-1: address 4, EndpointAddress 0x81 use DMA FIFO
scsi 0:0:0:0: Direct-Access CBM USB_2.0 5.00 PQ: 0 ANSI: 2
sd 0:0:0:0: [sda] 2009088 512-byte hardware sectors: (1.02 GB/981 MiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] 2009088 512-byte hardware sectors: (1.02 GB/981 MiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda:<7>usb-storage: queuecommand called
sda1
sd 0:0:0:0: [sda] Attached SCSI removable disk
- The FTDI usb-serial converter is detected on each USB port: a device /dev/ttyUSB0 is dynamically created with success
logs:
usb 1-1: new full speed USB device using r8a66597_hcd and address 3
usb 1-1: configuration #1 chosen from 1 choice
ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
usb 1-1: Detected FT232RL
usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
usb 1-1: New USB device found, idVendor=0403, idProduct=6001
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: US232R
usb 1-1: Manufacturer: FTDI
usb 1-1: SerialNumber: FTEMYMFR
3) Problems
- I can't communicate through ttyUSB0 with the device connected to the FTDI usb-serial converter. There are no answer to AT commands (it is a modem) and a sort of local echo instead. Serial port speed and flow control have been checked. I used tip to communicate with the modem.
logs:
root:/> tip -l /dev/ttyUSB0 -s 57600
usb 1-1: address 5, EndpointAddress 0x81 use DMA FIFO
Connected.
usb 1-1: address 5, EndpointAddress 0x02 use DMA FIFO
a at t
- the mounted filesystem seems to be corrupted: some files are seen as directories and some directories are seen has files. More over, writing seems to corrupt the filesystem: when I create 2 files (eg, echo "hello world" > hello.txt, echo "toto" > titi.txt) when reading the second file with cat I see the content of the first file (eg, cat titi.txt returns "toto hello world"). Then,after that I umount the key (umount /mnt) and it returns:
FAT: Filesystem panic (dev sda1)
fat_free_clusters: deleting FAT entry beyond EOF
File system has been set read-only
After that, the USB key is still successfully accessible with a Windows PC.
I tried with 2 different usb keys and it does the same. I also tried some fsck, but it doesn't solve the problem.
Did I miss something in the configuration ?
Is the declaration of the struct platform_device for r8a66597_hcd in the custom board file correct ?
Has someone experienced the same problem ?
Could someone have a solution ?
Do you think the 2 problems are independant or linked to the use of the same USB host controller ?
QuoteReplyEditDelete
2010-11-05 06:50:47 Re: USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Sonic Zhang (CHINA)
Message: 95590
We have never tested Renesas USB host controller to blackfin before. Your best choice is to ask Renesas for support.
QuoteReplyEditDelete
2010-11-08 20:26:40 Re: USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Mike Frysinger (UNITED STATES)
Message: 95663
you might want to double check your async memory timings in the kernel config. the default timings might violate the requirements for your USB part.
if in doubt, try setting them to the slowest (largest delays) possible and see if things start working.
QuoteReplyEditDelete
2010-11-10 06:22:32 Re: USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Gilbert Inho (FRANCE)
Message: 95749
Mike,
Our Renesas USB HC is mapped on Bank3. Originally, AMBCTL control register for Bank3 was set to 0x99B2.
Following your advice, I changed the value to 0xFFC2 (max timings), but it does not change the bad behaviour we have.
Have you any clue about what could happen ?
Best regards,
Gilbert
QuoteReplyEditDelete
2010-11-10 16:11:41 Re: USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Mike Frysinger (UNITED STATES)
Message: 95757
that's about the only Blackfin-specific aspect. the async bank timings and making sure the driver in question uses functions from io.h to access its registers rather than just a bare volatile pointer. beyond that, you'll prob need to try what Sonic suggested. sorry, but we just dont have any Renesas experience or hardware.
QuoteReplyEditDelete
2011-01-24 09:10:04 Re: USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Gilbert Inho (FRANCE)
Message: 97643
1) Concerning the USB key issue, just upgrading to 2010R1-RC5 solved the problem that seemed to be in the file system (because direct block access was successfull). Nevertheless, since it worked correctly, we haven't push in depth the investigation.
2) About usb-serial converter issue:
The problem comes from the Blackfin specific function "outsw" written in assembly code. This function writes 2 bytes despite its argument "len" is set to 0.
This leads the function "r8a66597_write_fifo" in r8a66597.h (function which writes urb's data into HC's fifo) to write twice the data in the particular case of only 1 char sent because, then, "outsw" writes data despite its argument "len" is set to 0.
We haven't modified "outsw", but from now we use it after testing the argument "len" is different from 0.
QuoteReplyEditDelete
2011-01-24 17:46:35 Re: USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Mike Frysinger (UNITED STATES)
Message: 97655
hmm, that sounds a bit odd. but i guess since other ports seem to handle the count==0 case, we should too.
please try the attached patch.
bfin-outs-0-count.patch
QuoteReplyEditDelete
2011-01-25 11:52:04 Re: USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Gilbert Inho (FRANCE)
Message: 97690
Mike,
Thank you for your quick answer and for providing a patch.
But it seems that the tests in assembly in the patch should be on R2 instead of R0 because it is the arg "count" which is at stack.
QuoteReplyEditDelete
2011-01-25 12:01:43 Re: USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Mike Frysinger (UNITED STATES)
Message: 97691
err, yes of course. so i guess the patch + that change, and things now work as expected ?
QuoteReplyEditDelete
2011-01-26 09:55:23 Re: USB failure using USB-serial FTDI or USB key with Host Controller Renesas R8a66597
Gilbert Inho (FRANCE)
Message: 97701
Yes it works well.
Thank you all for your help and support.