USB Mass Storage Device not enough bandwidth

Author
tvnpe
New Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2008/05/09 12:29:48
  • Location: 0
  • Status: offline
2008/09/18 12:17:17 (permalink)
2 (1)

USB Mass Storage Device not enough bandwidth

Hi Guys,
 
I am using PIC32 module with Explore 16, USB adaptor card, and SD/MMC adaptor card and try to implement USB mass storage device per AN1169.  I am successfully got it to work with 1GB SD card, but it does not works with 2GB SD card.  So I contact microchip techsuport and this is what there response:
 
Hello Tuan,
I aplogize for the delay. With the help of our applications engineer, we were able to track down the problem and along the way find a bug and made some improvements. However, the bad news is that we will not be able to support 2GB cards at this time. The reason is that 2GB has a sector size of 1K where card less than 2GB have a sector size of 512. Because of this, we would not be able to support the sector size of 1k right now. This is not to say that we WILL not be able to support this card size in the future. We do not have the bandwidth to make the modifications and test the code right now for that feature update.

We also found some bugs that were preventing the 1GB cards to work properly. Part of the problem was that the CSD (SD card structure) was not being read properly. On some 1GB cards reading the CSD work properly and on some others did not. This problem is now corrected.

We also found an error in the MSD source file. The routine that sends the card data, from the CSD, was calculating the size incorrectly. This issue has also been resolved.

I am attaching the modified msd.c and mediasd.c files that reflect the above mentioned corrections. You can use them with the 1GB or less capacity card.

Again, sorry for the inconvinience.

 
Have any of you guys try to implement same thing that I am trying to do and run into the same problem?  also what your guys take on microchip techsupport answer?
 
Tuan


#1

8 Replies Related Threads

    Neiwiertz
    Super Member
    • Total Posts : 2087
    • Reward points : 0
    • Joined: 2004/09/01 02:58:52
    • Status: offline
    RE: USB Mass Storage Device not enough bandwidth 2008/09/18 14:37:40 (permalink)
    0
    Tuan

    Check this out, support 2GB 1K block will be no problem i guess,
    but next the upper layer this means msd.c should being updated too.
    http://forum.microchip.com/fb.aspx?m=362659
    http://forum.microchip.com/fb.aspx?m=359633
    http://forum.microchip.com/fb.aspx?m=366845

    Can you upload a PIC32 example here

    Regards
    post edited by Neiwiertz - 2008/09/18 14:40:06

    Flying With --|Explorer 16|HardWare|SoftWare|-- Fav(s) Gallery Lists
    #2
    tvnpe
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2008/05/09 12:29:48
    • Location: 0
    • Status: offline
    RE: USB Mass Storage Device not enough bandwidth 2008/09/22 09:07:46 (permalink)
    0
    Hi,
     
    You mean you successfully implemented the USB Mass Storage Device with 2GB SD-Card?
     
    Tuan
    #3
    Neiwiertz
    Super Member
    • Total Posts : 2087
    • Reward points : 0
    • Joined: 2004/09/01 02:58:52
    • Status: offline
    RE: USB Mass Storage Device not enough bandwidth 2008/09/22 11:18:07 (permalink)
    0
    Hello Tuan

    No i did not yet, but i am curious to give it a try, sadly i don't have PIC32 usb PIM here
    therefore i could give it only a try at the 18F4550.

    Flying With --|Explorer 16|HardWare|SoftWare|-- Fav(s) Gallery Lists
    #4
    Neiwiertz
    Super Member
    • Total Posts : 2087
    • Reward points : 0
    • Joined: 2004/09/01 02:58:52
    • Status: offline
    RE: USB Mass Storage Device not enough bandwidth 2008/10/04 11:14:34 (permalink)
    0
    Tuan i just have give it a shot without result, the problem here by using 2GB that the readsector function this means sending readblock command but it doesn't return 1024 Bytes at sector address 0 it only return 512 bytes of data, So this will be difficulty then i thought at the first look.

    I think the read capacity handler doesn't return the 2GB size correctly

    Regards
    post edited by Neiwiertz - 2008/10/04 12:34:11

    Flying With --|Explorer 16|HardWare|SoftWare|-- Fav(s) Gallery Lists
    #5
    Neiwiertz
    Super Member
    • Total Posts : 2087
    • Reward points : 0
    • Joined: 2004/09/01 02:58:52
    • Status: offline
    RE: USB Mass Storage Device not enough bandwidth 2008/10/04 12:13:30 (permalink)
    0
    I think the read capacity handler doesn't return the 2GB size correctly
    The read capicity of an1003 is fine it returns 2009599 for a 2GB card which has 4019200 of 512bytes sectors (2009599+1) x 2 -> 4019200, Still i found it strange why msd is not calling sector read for a second time when using a 2GB card during debug. I have to figure out what is causing this and secondly i need to figure out why the block len doesn't return 1024bytes.

    i just try to manual hard define 4019200-1 as capacity but that won't help i guess[&:][&:] AN1003 msd.c is not designed to support cards greater than 1GB. due the 1024 byte sized blocks

    Still strange why i don't receive 1024bytes for readblock cmd, because AN1003 readcapacity funtion points to a half a size therfore i can conclude my 2GB must support 1024bytes block. at init i should send 0x400 as blocklen and i should watch out that sector address is in range of 1024 at the sector read function or something
    post edited by Neiwiertz - 2008/10/04 12:29:58

    Flying With --|Explorer 16|HardWare|SoftWare|-- Fav(s) Gallery Lists
    #6
    fredtroy
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2006/10/23 15:08:51
    • Location: 0
    • Status: offline
    RE: USB Mass Storage Device not enough bandwidth 2008/12/15 13:53:13 (permalink)
    0
    What is maximum bandwidth USB mass storage PIC32?  This will not be an SD card.
     
    Thank-you,
     
    Fred
    #7
    Kiwi Mike AZ
    Super Member
    • Total Posts : 2044
    • Reward points : 0
    • Status: offline
    RE: USB Mass Storage Device not enough bandwidth 2008/12/15 14:19:36 (permalink)
    0
    It depends on what else is pluggeed into the PC USB - if there is nothing else, then the full USB bandwith is avaliable, if there are other devices then the bandwith is shared, and BULK has the lowest priority.
     
    Theoretically up to just over 1MByte/sec is possible with BULK if nothing else is on the bus.
     
    Mike
    #8
    mirimcp
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2003/11/07 12:40:02
    • Location: Italy
    • Status: offline
    RE: USB Mass Storage Device not enough bandwidth 2009/02/23 05:05:15 (permalink)
    0
    Hello,
    I had the same problem using the PIC32 kit. I have found the solution.
    CSD data must be used to calculate the capacity of the SD card and not the Sector Size. The sector size is always 512 bytes reading or writing blocks on SD cards. The function _HandleReadCapacity contain errors for a correct capacity calculation. I have corrected the code and I paste it here. This code come from the sample for the PIC32 starter kit. It worked well with a 2GB Kingstron and should work with larger capacity. There are some comments where I made changes.

    PRIVATE BOOL _HandleReadCapacity(void)
    {
    BYTE buffer[16];
    DWORD size, mult;
    WORD block_len; //Mike. Added to perform the calculation.

    memset(_msdBuffer, 0, 8);

    if(!CSDRead(buffer))
    {
    _msdCBWCopy.CBWCB[0] = 0xFE;
    USBDEVTransferData(MSD_USB_TX, _msdBuffer, _msdCBWCopy.dCBWDataTransferLength);
    return FALSE;
    }
    //Mike 23/02/09 Sectors are always read or write with 512 byte
    //buffer[5] must be used to calculate the capacity, not the SecSize

    //_msdSecSize.Val = 1 << (buffer[5] & 0x0F);
    _msdSecSize.Val = MEDIA_SECTOR_SIZE;
    //block_len will be used later to calculate the max sectors
    block_len= 1 << (buffer[5] & 0x0F);
    size = (DWORD)(buffer[6] & 0x03);
    size <<= 8;
    size |= (DWORD)buffer[7];
    size <<= 2;
    size |= (DWORD)((buffer[8] & 0xC0) >> 6);
    size++;

    mult = (DWORD)(buffer[9] & 0x03);
    mult <<= 1;
    mult |= (DWORD)((buffer[10] & 0x80) >> 7);
    mult += 2;

    _msdTotalSec.Val = size << mult;
    //total sectors are now multiplied by block_len/512
    _msdTotalSec.Val*=(block_len/MEDIA_SECTOR_SIZE);
    _msdTotalSec.Val--;
    _msdBuffer[0] = _msdTotalSec.v[3];
    _msdBuffer[1] = _msdTotalSec.v[2];
    _msdBuffer[2] = _msdTotalSec.v[1];
    _msdBuffer[3] = _msdTotalSec.v[0];

    _msdBuffer[4] = _msdSecSize.v[3];
    _msdBuffer[5] = _msdSecSize.v[2];
    _msdBuffer[6] = _msdSecSize.v[1];
    _msdBuffer[7] = _msdSecSize.v[0];

    return USBDEVTransferData(MSD_USB_TX, _msdBuffer, 8);
    }

    I have noticed a small difference writing blocks with 2G card respect to a 512M, here the results:

    512MB Kingstron:
    Write: 214kB/s
    Read: 533 kB/s

    2GB Kingstron:
    Write: 172kB/s
    Read: 533 kB/s

    Hope that this help.
    Mike.
    #9
    Jump to:
    © 2017 APG vNext Commercial Version 4.5