This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

usb hostlite fat32 impplementation

i am currently using lpc2468 usbhostlite code and getting the required results.
can anyone please help me make the necessary changes in the code to use it with fat32 formatted pendrives also

Parents
  • Thanks Sir for your kind support

    yes,File name is in capital letter .but sir i solved that problem using following change in main_write function

    void  Main_Write (void)
    {
        SWORD32  fdw;
        SWORD32  fdr;
        UWORD32  tot_bytes_written;
        UWORD32  bytes_written;
        UWORD8            tmp_buf[64]="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO";
        UserBuffer = &tmp_buf[0];
    
    
    
    
            fdw = FILE_Open(FILENAME_W, RDWR);
            if (fdw > 0) {
                tot_bytes_written = 0;
    
                do {
    
                   // bytes_written = FILE_Write(fdw, UserBuffer, 1024);//earlier
                    bytes_written = FILE_Write(fdw, UserBuffer , 64);//now
                    tot_bytes_written += bytes_written;
                    } while (tot_bytes_written < 1024);
                FILE_Close(fdw);
    
    
            }
    
    }
    
    

    Now i am able to create the file.but a new problem is that when i create file of size upto 0 - 5kb everything is ok.but when I create file of size greater than 8 KB and try to open it on PC.It gives an error


    could n,t open L:\MSWRITE.TXT
    Make sure a drive in the disk is specified or not

    What,s the reason behind it?

    Thanks Rohit

Reply
  • Thanks Sir for your kind support

    yes,File name is in capital letter .but sir i solved that problem using following change in main_write function

    void  Main_Write (void)
    {
        SWORD32  fdw;
        SWORD32  fdr;
        UWORD32  tot_bytes_written;
        UWORD32  bytes_written;
        UWORD8            tmp_buf[64]="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO";
        UserBuffer = &tmp_buf[0];
    
    
    
    
            fdw = FILE_Open(FILENAME_W, RDWR);
            if (fdw > 0) {
                tot_bytes_written = 0;
    
                do {
    
                   // bytes_written = FILE_Write(fdw, UserBuffer, 1024);//earlier
                    bytes_written = FILE_Write(fdw, UserBuffer , 64);//now
                    tot_bytes_written += bytes_written;
                    } while (tot_bytes_written < 1024);
                FILE_Close(fdw);
    
    
            }
    
    }
    
    

    Now i am able to create the file.but a new problem is that when i create file of size upto 0 - 5kb everything is ok.but when I create file of size greater than 8 KB and try to open it on PC.It gives an error


    could n,t open L:\MSWRITE.TXT
    Make sure a drive in the disk is specified or not

    What,s the reason behind it?

    Thanks Rohit

Children
  • Is the buffer passed to FILE_Write() / FILE_Read() placed on the USB RAM (HOST_BASE_ADDR)?

    This buffer is directly put into the Transfer Descriptor for DMA by the host controller.
    It means the buffer should be placed on the USB RAM.
    LPC23xx/24xx families have this restriction on DMA by USB controller.

    In the USB host lite example, it manages buffer assignment as follows.

    usbhost_lpc2468.c
    
    volatile  HCED        *EDCtrl;        /* Control endpoint descriptor structure                  */
    volatile  HCED        *EDBulkIn;      /* BulkIn endpoint descriptor  structure                  */
    volatile  HCED        *EDBulkOut;     /* BulkOut endpoint descriptor structure                  */
    volatile  HCTD        *TDHead;        /* Head transfer descriptor structure                     */
    volatile  HCTD        *TDTail;        /* Tail transfer descriptor structure                     */
    volatile  HCCA        *Hcca;          /* Host Controller Communications Area structure          */
              USB_INT16U  *TDBufNonVol;   /* Identical to TDBuffer just to reduce compiler warnings */
    volatile  USB_INT08U  *TDBuffer;      /* Current Buffer Pointer of transfer descriptor          */
    volatile  USB_INT08U  *FATBuffer;     /* Buffer used by FAT file system                         */
    volatile  USB_INT08U  *UserBuffer;    /* Buffer used by application                             */
    
    void  Host_Init (void)
    {
        ...
        Hcca       = (volatile  HCCA       *)(HOST_BASE_ADDR+0x000);
        TDHead     = (volatile  HCTD       *)(HOST_BASE_ADDR+0x100);
        TDTail     = (volatile  HCTD       *)(HOST_BASE_ADDR+0x110);
        EDCtrl     = (volatile  HCED       *)(HOST_BASE_ADDR+0x120);
        EDBulkIn   = (volatile  HCED       *)(HOST_BASE_ADDR+0x130);
        EDBulkOut  = (volatile  HCED       *)(HOST_BASE_ADDR+0x140);
        TDBuffer   = (volatile  USB_INT08U *)(HOST_BASE_ADDR+0x150);
        FATBuffer  = (volatile  USB_INT08U *)(HOST_BASE_ADDR+0x1D0);
        UserBuffer = (volatile  USB_INT08U *)(HOST_BASE_ADDR+0x1000);
    

    If the buffer would be placed on the USB RAM, you don't need abuve repeated FILE_Write(). Single FILE_Write() call with whole buffer will do.

    Tsuneo

  • Thanks Sir

    No, Sir buffer was not placed on USB RAM.

  • Thank You so much Sir you solved my problem

    you are genuinely a master.