LPC1769 USB and FAT32

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1769 USB and FAT32

2,293 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kimi on Sat Jan 07 04:35:22 MST 2012
Hello to everybody,

I have just bought a LPCXpresso board with LPC1769 and would like to make a USB datalogger with it.

My idea is to use the USB Host capability and connect a USB Flash Drive to the board. As this Flash Drive will be formatted with FAT32, I will also need a software layer over the USB Host that lets me access a few primitives like open,close,write a file.

I looked at USBHostLite project but it has only support for FAT16. Did anybody extend it to FAT32?

I think my project will not excess the 128k limit of the free LPCXpresso IDE, but in case it does, or I make a bigger project, is there other way I can compile and upload the application to the board?  Like using GCC and a 3rd party software that uses the LPC-Link.

Thanks very much,
0 Kudos
18 Replies

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nikita on Wed Oct 23 23:57:48 MST 2013
Thank you ..!!
I got it... :)
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Wed Oct 23 11:08:18 MST 2013
ChaN's FatFs implementation on NXP USB host lite for LPC17xx

http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html#chanfat_lpc_cm3

Tsuneo
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nikita on Mon Oct 21 22:19:57 MST 2013
Hi,
  I am also working on lpc1769 a hostlite example, as this supports only FAT16 I can not use it for pendrive .

Anyone have code for FAT32 ?
or what modifications do we need ?

 
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elef on Tue Jul 17 06:54:46 MST 2012

Quote: modestt
Thanks All sorted. Replaced FAT files with new version and it worked !
One thing though data write speed doesnt improve with WORD_ACCESS enabled.
I have project files If some one needs. I cant upload becuase of limit exceed.


I didn't check that option, but i did try changing the buffer size from 1k to 4k and it pretty much doubled the speed! Changing it to 8k made it faster too, don't know by how much, didn't measure it.
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by modestt on Tue Jul 17 06:27:27 MST 2012
Thanks All sorted. Replaced FAT files with new version and it worked !
One thing though data write speed doesnt improve with WORD_ACCESS enabled.
I have project files If some one needs. I cant upload becuase of limit exceed.
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elef on Tue Jul 17 02:59:48 MST 2012

Quote: modestt
so far so good, it is working however I have problems creating new files.
Any ideas  ? does FatFS requires certain escape char or something before file name ?
Thanks


Not that i know of. It even handles long file names if you enable that feature. By default i think you can only have the standard 8+3 filenames, i think?

Anyways, what error code are you getting returned from the f_open function? And maybe show us your f_open line and filename?
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by modestt on Tue Jul 17 01:32:43 MST 2012
so far so good, it is working however I have problems creating new files.
Any ideas  ? does FatFS requires certain escape char or something before file name ?
Thanks
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elef on Mon Jul 16 16:02:28 MST 2012

Quote: modestt
Thanks for your detailed response.
Before I saw it I managed to play about with mp3 demo code only and come up with a stripped down version with all codec stuff removed. it works and data throughput not far from what you reported.
I wanted to attach files but I am not allowed it looks like I cant do it without removing pervious attachments :(:(



That's what i started doing, but for some reason i couldn't get it to copy more than 6 to 7kB per file, then crash/lock up.
I spent ages trying to get it going, nothing i did worked. So eventually i moved all the fat32 stuff to the hostlite demo, only took 10 minutes and it worked great with larger files.
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by modestt on Mon Jul 16 09:06:32 MST 2012
Thanks for your detailed response.
Before I saw it I managed to play about with mp3 demo code only and come up with a stripped down version with all codec stuff removed. it works and data throughput not far from what you reported.
I wanted to attach files but I am not allowed it looks like I cant do it without removing pervious attachments :(:(
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elef on Mon Jul 16 04:58:19 MST 2012
And to test it, i used simple test like this:

void  Main_Copy (void)
{
    uint32_t  nRead, nWritten;
    uint8_t res;
    uint8_t buffer[FAT_BUFFER_SIZE]; //or change this if you have some static memory allocated somewhere else instead of stack.

    res = f_open(&File1, "SRC.TXT", FA_READ);
    if(res == FR_OK) {
        PRINT_Log("SRC.TXT open OK.\n\r");
        res = f_open(&File2, "DEST.TXT", FA_WRITE | FA_READ | FA_OPEN_ALWAYS);
        if(res == FR_OK) {
            PRINT_Log("DEST.TXT open OK.\n\r");
            PRINT_Log("Copying from ...\n");
            do {
                res = f_read(&File1, buffer, FAT_BUFFER_SIZE, &nRead);
                res = f_write(&File2, buffer ,nRead, &nWritten);
            } while (nRead);
            f_close(&File2);
        } else {
            PRINT_Log("Could not open file Dest\n");
            return;
        }
        f_close(&File1);
        PRINT_Log("Copy completed\n");
    } else {
        PRINT_Log("Could not open file Src\n");
        return;
    }
}
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elef on Sun Jul 15 16:25:44 MST 2012

Quote: modestt
Hi,
I had same issue finding USBHOSTlite too slow. Would it be possible for you to upload your code or link the demo code you originally used ?
Thanks


I don't have it here with me, but this is what i did:

Four downloads you need before you start:
1. USBHostLite demo (RDB1768cmsis2.zip\NXP_LPC17xx_UsbHostLiteCMSIS2)
2. MP3 demo from http://www.lpcware.com/content/nxpfile/an11178-mp3-player-solution-nxp-lpc1700-series-v10
3. The download from the link Tsuneo posted: http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html#chanfat_lpc_cm3
4. FatFs 0.09 ff9.zip

a) Open the project in (file 1) then delete the 2 files in the FAT folder. Replace them with all the 5 files in ff9.zip (file 4)
b) Copy storage.c and storage.h from (file 2) into the project FAT folder
c) Copy fattime.c from (file 3) into project in FAT folder
d) compile and fix up each minor error as you get to it, i can't remember what they were, but i think they were just minor things, such as RTC (or disable RTC in fattime.c by changing #define from 1 to 0) etc...
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by modestt on Sun Jul 15 09:16:12 MST 2012
Hi,
I had same issue finding USBHOSTlite too slow. Would it be possible for you to upload your code or link the demo code you originally used ?
Thanks
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elef on Sat Jul 14 09:44:22 MST 2012
Thanks. I did see that moments ago, but I ended up using another demo, the mp3 demo on the lpcware websitei found was sufficient.
I also got FatFs working in the lpcxpresso HostLite demo, by removing the Fat16 files, adding the FatFS files. Few minor tweaks, and was all running in very little time. (the diskio.c i used the storage.c file from the mp3 demo on lpcware website, and overall works great)

For those who are interested:
Using FatFS, copying a 1MB file in about 5 to 7 seconds, took about 20 seconds with default Hostlite FAT.

Reading an entire 1MB file takes under 2 seconds, took about 6 seconds in default hostlite fat.
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Sat Jul 14 04:45:00 MST 2012

Quote:
hopefully someone has done it?



Here is a FatFs implementation over USBHostLite.

ChaN's FAT-Module with LPC17xx SPI/SSP and USB-MSD
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html#chanfat_lpc_cm3

Tsuneo
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elef on Sat Jul 14 00:08:58 MST 2012

Quote: kimi
I think I have answered myself when looking at Application Note: 10916 - AN10916 FAT library EFSL and FatFs port on NXP LPC1700

Now I have to link this example with the USB Host like example.

Thanks,


Kimi, did you get this going? i am also looking for the same thing, i haven't found anything yet, hopefully someone has done it?
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Sun Jan 08 08:03:38 MST 2012

Quote: Rob65
Why not just use an SD card instead of a USB stick?


Good question. Except the practical aspects, which solution would have the best write transfer rate ?

Angelo
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sat Jan 07 17:02:05 MST 2012
Why not just use an SD card instead of a USB stick?
You can always plug the SD card in a card reader to read it at the PC and this code is already available.

Regards,
[INDENT]Rob
[/INDENT]
0 Kudos

1,589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kimi on Sat Jan 07 04:56:04 MST 2012
I think I have answered myself when looking at Application Note: 10916 - AN10916 FAT library EFSL and FatFs port on NXP LPC1700

Now I have to link this example with the USB Host like example.

Thanks,
0 Kudos