Ok, I've reversed the wires and now it works with what I think is full speed wireless mouse.
But, doesn't work with low speed mouse or keyboard.
Gives that same message as with wires backwards:
GetDescriptor(TYPE_DEVICE): 0x00000000, Retry limit exceeded, transaction canceled.
The USB-SD-uSD thing is fun. It works with a black 2GB card, but not that white 32GB one.
The 64GB Kangaroo doesn't work, probably because it's NTFS.
1GB Lexar JumpDrive works.
4GB RiData doesn't work, not sure why, seems like it should..
Gives this:
<Full-Speed device connected.>
Vendor ID: Ut163
Product ID: USB2FlashStorage
Version level: 0.00
Media is removable
Device does not claim conformance to any SPC standard
Highest LBA: 8060926
Sector size: 512
Checking media for a FAT file system...
Unable to mount this device.
Here it is. Note: this is a fairly old USB drive, wouldn't worry too much about it...
It's formatted as partition type $06 (FAT16) with a cluster size of 128KB and I currently have the cluster buffer set to a max of 32KB. I did that because FAT32 with 16KB cluster size gets you 64GB+. But since we're testing, I probably should be looking at the extremes, too.
If you want to test it out, you can change the MAX_CLUSTER_SIZE constant to a max of 128KB and the "boms_cluster_buff" buffer size to MAX_CLUSTER_SIZE and it should enumerate.
garryj: Do you have any guidance for using this in an application?
I see I can "type" a file, so know I can get access to a file's contents.
Say I want to open a bmp file and copy contents to RAM.
Is there an easy way to do that?
The TYPE/CAT routine is single-minded, but does show the steps needed to read the directory and access the content of a file. Real fopen() type access is planned, but slow in coming...
How does the read speed compare with usd with spi interface ?
Only needs 2 pins (instead of 4 for uSD). That can be a big advantage...
Did you mean USB vs SPI ?
USB needs 2 COGs I think, but yes, it can run on just 2 pins.
Top USB speeds I've seen from PC's are 8~9 MBit/s (ie the 12 MHz minus overheads), which is slower than P2 can run SPI.
BTW, my head-math sucks -- the cluster size of your RiData drive is 64KB. For what it's worth, this is what MS has to say regarding FAT cluster sizes:
BPB_SecPerClus (BPB offset 13, one byte):
Number of sectors per allocation unit. This value must be a power
of 2 that is greater than 0. The legal values are 1, 2, 4, 8, 16, 32, 64,
and 128. Note however, that a value should never be used that
results in a “bytes per cluster” value (BPB_BytsPerSec *
BPB_SecPerClus) greater than 32K (32 * 1024). There is a
misconception that values greater than this are OK. Values that
cause a cluster size greater than 32K bytes do not work properly; do
not try to define one. Some versions of some systems allow 64K
bytes per cluster value. Many application setup programs will not
work correctly on such a FAT volume.
I'm unable to fully test USB, since PNut doesn't run a terminal by itself after the program has been compiled and loaded. My main problem is that Tera Term resets the board and clears the program after PNut, and thus I'm unable to interact with it. I've tried loading the program with spin2gui as an alternative, but it yields compilation errors.
I'm unable to fully test USB, since PNut doesn't run a terminal by itself after the program has been compiled and loaded. My main problem is that Tera Term resets the board and clears the program after PNut, and thus I'm unable to interact with it. I've tried loading the program with spin2gui as an alternative, but it yields compilation errors.
What version of spin2gui are you using? I'm able to compile that program just fine with versions 3.9.24 and 3.9.26. There is a warning on line 3400 about a cmp being used without flags, but I think that warning is legitimate (and it is just a warning).
I'm unable to fully test USB, since PNut doesn't run a terminal by itself after the program has been compiled and loaded. My main problem is that Tera Term resets the board and clears the program after PNut, and thus I'm unable to interact with it. I've tried loading the program with spin2gui as an alternative, but it yields compilation errors.
What version of spin2gui are you using? I'm able to compile that program just fine with versions 3.9.24 and 3.9.26. There is a warning on line 3400 about a cmp being used without flags, but I think that warning is legitimate (and it is just a warning).
Hi ersmith,
I'm using version 1.3.2, which seems to be much older. I'll upgrade and try the newer version ASAP.
Update: Compilation issue solved with version 3.9.26. Thanks! Now I have to sort out which baudrate is used.
<Full-Speed device connected.>
Vendor ID: SanDisk
Product ID: Ultra
Version level: 1.00
Media is removable
SCSI version is ANSI X3.131:1994 (SCSI-2) or higher
Highest LBA: 60062499
Sector size: 512
Checking media for a FAT file system...
Partition type: 0x0C
Cluster size: 16384
Volume base sector: 32
Reserved sector count: 38
FSInfo base sector (in reserved): 33
FAT region base sector: 70
Sector count of one FAT: 14657
FAT region sector count: 29314
RootDir base sector: 29384
RootDir cluster#: 2
Dir/file/data base sector: 29384
Count of data region clusters: 1876034
Count of free clusters: 1872940
FSInfo next free cluster: 52516
Count of data region sectors: 60033116
Count of volume sectors: 60062468
FAT32 volume mounted.
And here is the same test using a SanDisk Cruzer Slice:
<Full-Speed device connected.>
Vendor ID: SanDisk
Product ID: Cruzer Slice
Version level: 8.02
Media is removable
Device does not claim conformance to any SPC standard
No data...
Bulk-IN endpoint STALL...
SCSI command error: Failed
ASC: 0x3A, ASCQ: 0x00
Unit requires attention: medium not present
Unable to mount this device.
And a last one with an unidentified, generic pen:
<Full-Speed device connected.>
Vendor ID: DW
Product ID: PND1GCBM11013B
Version level: 4.00
Media is removable
Device does not claim conformance to any SPC standard
Highest LBA: 2045438
Sector size: 512
Checking media for a FAT file system...
Partition type: 0x0B
Cluster size: 4096
Volume base sector: 32
Reserved sector count: 36
FSInfo base sector (in reserved): 33
FAT region base sector: 68
Sector count of one FAT: 1994
FAT region sector count: 3988
RootDir base sector: 4056
RootDir cluster#: 2
Dir/file/data base sector: 4056
Count of data region clusters: 255172
Count of free clusters: 252482
FSInfo next free cluster: 46608
Count of data region sectors: 2041383
Count of volume sectors: 2045407
FAT32 volume mounted.
The mass storage driver seems to work fine for the most part, although only detects a connection on the upper port of the serial host add-on board. I don't know if it is to be expected.
As for the Cruzer Slice, the pen is formatted and contains no FAT errors. It mounts well on Windows and Linux, so I was not expecting that. The issue is very consistent.
I'm at a loss as to why the lower port is not working, as that is the one I usually test with:
'------------------------------------------------------------------------------
' P2-ES USB Host (Master) x 2 Accessory Board I/O group base pin:
USB_BASEPIN = 16 ' + offsets for ES-64006 Serial Host board
'------------------------------------------------------------------------------
'#define USB_PORTB
#ifndef USB_PORTB ' PortA is the default.
' USB "portA" connector pin assignments (lower port):
HOST_ACTIVE_LED = USB_BASEPIN + 4
' USB protection enable/disable
USB_PROTECT_ON = USB_BASEPIN + 5
' Smart pin pair used for the USB transceiver:
DM = USB_BASEPIN + 6 ' DM is "The Brain"
DP = USB_BASEPIN + 7 ' DP is passive
' Long repository pin#:
USB_EVENT_REPO = USB_BASEPIN + 8
' LED to blink at host/driver fatal error:
HOST_ERROR_LED = LED56
#else
' USB "portB" connector pin assignments (upper port):
HOST_ACTIVE_LED = USB_BASEPIN + 0
' USB protection enable/disable
USB_PROTECT_ON = USB_BASEPIN + 1
' Smart pin pair used for the USB transceiver:
DM = USB_BASEPIN + 2 ' DM is "The Brain"
DP = USB_BASEPIN + 3 ' DP is passive
' Long repository pin#:
USB_EVENT_REPO = USB_BASEPIN + 9
' LED to blink at host/driver fatal error:
HOST_ERROR_LED = LED57
#endif
There are refreshes (hopefully soon) of the "lite" USB keyboard/mouse demo coming: a pure p2asm version and a Spin2 version, which can support more than one USB port.
Comments
Not really working, but I do get these messages only when I connect a USB device:
Maybe I need pullup resistors?
Seems that I have DP on an even pin...
Tried this, but it doesn't work:
Time to break out some jumpers...
Yeah. DP must be the odd pin. No pullup/down resistors needed on silicon.
But, doesn't work with low speed mouse or keyboard.
Gives that same message as with wires backwards:
GetDescriptor(TYPE_DEVICE): 0x00000000, Retry limit exceeded, transaction canceled.
This sounds like a great challenge for ersmith!
Fastspin gives a warning on this line:
warning on line 3400 that "cmp" is used without flags being set...
The USB-SD-uSD thing is fun. It works with a black 2GB card, but not that white 32GB one.
The 64GB Kangaroo doesn't work, probably because it's NTFS.
1GB Lexar JumpDrive works.
4GB RiData doesn't work, not sure why, seems like it should..
Gives this:
Yep. This routine is called when clearing a stalled endpoint, which is fairly rare. This one's been there a while. Thanks!
Hmm. It's bailing early in the FAT check, so the issue is likely something it doesn't like in the MBR or the volume BPB.
At the "#" start-up prompt, issue a TGLDBG command to enable verbose output and it will output both of these sectors during device enumeration.
If you want to test it out, you can change the MAX_CLUSTER_SIZE constant to a max of 128KB and the "boms_cluster_buff" buffer size to MAX_CLUSTER_SIZE and it should enumerate.
I see I can "type" a file, so know I can get access to a file's contents.
Say I want to open a bmp file and copy contents to RAM.
Is there an easy way to do that?
The TYPE/CAT routine is single-minded, but does show the steps needed to read the directory and access the content of a file. Real fopen() type access is planned, but slow in coming...
uSD kindof does the same thing.
Thumb drives can be bigger in capacity though.
Harder to break, apparently.
Easier to handle...
Only needs 2 pins (instead of 4 for uSD). That can be a big advantage...
Did you mean USB vs SPI ?
USB needs 2 COGs I think, but yes, it can run on just 2 pins.
Top USB speeds I've seen from PC's are 8~9 MBit/s (ie the 12 MHz minus overheads), which is slower than P2 can run SPI.
BTW, my head-math sucks -- the cluster size of your RiData drive is 64KB. For what it's worth, this is what MS has to say regarding FAT cluster sizes:
I'm unable to fully test USB, since PNut doesn't run a terminal by itself after the program has been compiled and loaded. My main problem is that Tera Term resets the board and clears the program after PNut, and thus I'm unable to interact with it. I've tried loading the program with spin2gui as an alternative, but it yields compilation errors.
I'm using the zip file located in this post:
https://forums.parallax.com/discussion/comment/1462546/#Comment_1462546
Can anyone instruct me on how to run it? Any help would be appreciated. Thanks in advance!
Kind regards, Samuel Lourenço
I'm using version 1.3.2, which seems to be much older. I'll upgrade and try the newer version ASAP.
Update: Compilation issue solved with version 3.9.26. Thanks! Now I have to sort out which baudrate is used.
Kind regards, Samuel Lourenço
Here is what I got with a SanDisk Ultra pen:
And here is the same test using a SanDisk Cruzer Slice:
And a last one with an unidentified, generic pen:
The mass storage driver seems to work fine for the most part, although only detects a connection on the upper port of the serial host add-on board. I don't know if it is to be expected.
As for the Cruzer Slice, the pen is formatted and contains no FAT errors. It mounts well on Windows and Linux, so I was not expecting that. The issue is very consistent.
Kind regards, Samuel Lourenço
Tested the mouse and keyboard driver too, as posted here:
https://forums.parallax.com/discussion/comment/1462633/#Comment_1462633
It works great! First I used a wireless mouse to test it, then a wireless keyboard/mouse combo. Here is the output:
However, as in the MSC driver, only the upper port works on the add-on board.
Kind regards, Samuel Lourenço
There are refreshes (hopefully soon) of the "lite" USB keyboard/mouse demo coming: a pure p2asm version and a Spin2 version, which can support more than one USB port.
Hi Samuel,
Just to double check that both power enable pins are getting set; the upper and lower usb sockets each have an ENable pin.
basepin+1 and basepin+5
garryj's post/code above includes those, but maybe some older code didn't assert both?