Reply by Tim Mitchell December 13, 20112011-12-13
----Original Message----
From: l...
[mailto:l...] On Behalf Of xavierwork
Sent: 13 December 2011 15:44 To: l...
Subject: [lpc2000] Re: FATFS USB MSD needed for LPC1768

> Thank you Tim!
> Thank you Martin!
>
> LOL - I guess I completely miss-understood how that
> should work. Incorrectly I was thinking the USB would
> access the FATFS and I would have to provide some
> interface for the two to talk. Thank you both for
> setting me on the right path. Thank you also for
> providing the link. I will review the link in detail.
> No wonder I was getting no where fast, I was completely
> off base - LOL!!!

I know what you mean because I thought exactly that when I started trying to get mass storage to work. Once I worked out the PC took over control, it was much easier to understand.

--
Tim Mitchell

An Engineer's Guide to the LPC2100 Series

Reply by xavierwork December 13, 20112011-12-13
Thank you Tim!
Thank you Martin!

LOL - I guess I completely miss-understood how that should work. Incorrectly I was thinking the USB would access the FATFS and I would have to provide some interface for the two to talk. Thank you both for setting me on the right path. Thank you also for providing the link. I will review the link in detail. No wonder I was getting no where fast, I was completely off base - LOL!!!

Thanks,
Xman

--- In l..., "Tim Mitchell" wrote:
>
> In Mass Storage mode, the PC controls all accesses to the flash - it uses it just like a raw disk. FatFS plays no part in this.
> All you have to do is give the USB MS code the correct flash sector when it asks for it, or write the sector to the correct place when it gives you one.
>
> You must not access the flash yourself using FatFS while the device is in mass storage mode, Windows does write caching and all sorts of evil things which can destroy the filesystem if you start changing bits of it at the same time.
>
> I found these sample routines from nxp useful when getting MSD code working
>
> http://ics.nxp.com/support/software/code.bundle.lpc17xx.keil/
>
> --
> Tim Mitchell
>

Reply by Tim Mitchell December 13, 20112011-12-13
In Mass Storage mode, the PC controls all accesses to the flash - it uses it just like a raw disk. FatFS plays no part in this.
All you have to do is give the USB MS code the correct flash sector when it asks for it, or write the sector to the correct place when it gives you one.

You must not access the flash yourself using FatFS while the device is in mass storage mode, Windows does write caching and all sorts of evil things which can destroy the filesystem if you start changing bits of it at the same time.

I found these sample routines from nxp useful when getting MSD code working

http://ics.nxp.com/support/software/code.bundle.lpc17xx.keil/

--
Tim Mitchell

Reply by capiman26061973 December 13, 20112011-12-13
Hello Xman,

FatFs works via DiskIo-Layer on (sector based) memory.
MSD (at least as far as i know / heard, never used it myself)
want also a (sector based) memory.

So in my opinion it is not (easily) possible to use MSD on top of
FatFs. But it could be possible to let MSD access the "layer"
below DiskIO (e.g. let it read / write a sector via SPI).

Problems are parallel accesses and consistency between
both access methods. When both are connected, the OS on PC
reads some sectors / caches some sectors and also the uC reads /
writes some sectors. But then it could happen that you get a
mixture of both (one is reading, the other is writing)...

Best regards,

Martin

--- In l..., "xavierwork" wrote:
> Hello Lukas, my SD has an SPI interface. The DiskIO layer for the LPC17xx SPI I found in an app note from NXP (AN10916). This has been working well in my hardware thus far as I have been able to do the 3 things I needed... read dir, read file, write file. I am now stuck with trying to figureing out how to add MSD to the FATfs.
>
> Sorry I do not have a solution for you. Good luck.
>
> Thanks,
> Xman
> --- In l..., "lukas.jeindl" wrote:
> >
> > Hi Xman,
> >
> > unfortunately I can't supply you with mass storage code.
> >
> > You say you ported Chan's FATFS to LPC1768.
> > Trying to port it to LPC1788 from the LPC23xx (MMC) version, I ran into a problem when replacing the routines "Store_Block" and "Load_Block" (previously in asmfunc.s) with memcpys.
> > They seem to be not fast enough to empty the MCI buffer in time, so I had to increase buffer depth by 1.
> > Current version of ChanFS seems to be for SPI and uses a while loop for block transfer.
> >
> > Did you create your own assembly procedures for these routines or addressed the issue in any other way?
> > If yes, could you please post the solution here?
> >
> > Thanks in advance!
> >
> > Regards,
> > Lukas
> >
> >
> > --- In l..., "xavierwork" wrote:
> > >
> > > I have Chan's excellent FATFS posted to my project up and working nicely. I also have the USB portion working as a virtual com.
> > >
> > > I need to implement chan FS and the USB as a MSD. I am nearng the end of a long project, I am far behind, and very tired. I am certain someone has done this before. Can someone please share example code to help.
> > >
> > > Thanks,
> > > Xman
> > >
>

Reply by "M. Manca" December 13, 20112011-12-13
Il 13/12/2011 14:34, xavierwork ha scritto:
>
>
> Thank you M. Manca
>
> Needless to say I have already searched the web, before I asked the
> LPC community.
> I could not find anything on the NXP site specific to my needs. Not
> sure what you mean by install limited releases for IAR. This is for my
> home project, not work - I use CrossWorks, which is very affordable,
> but not very widely used. At work I now use IAR. Can you provide a
> little more specific information, the project can be from anything, if
> the code is there I should be able to work through it, but I do need a
> starting point.
>
Go to the Keil web site and download the demo or lite release, you will
have a 30 (or 60 I didn't remember) day full uVision 4 IDE and
compiler/linker/debugger (after 60 days a 32 KByte limited object size
release) with a big set of examples in source code.
Same thing for IAR. Both Keil and IAR have an example to access an SD
card on a LPC1788/LPC1768 supported board as a USB mass storage device
(so the board is connected to the PC via USB).
From NXP site you can download lpc17xx set of examples packed in a zip
file. There are examples related to USB mass storage. In www.lpcware.com
you can find also a new USB lib tailored to NXP microcontrollers.
Examples from NXP can be found also on Code Red web site.
> Thanks,
> Xman
>
> --- In l... , "M.
> Manca" wrote:
> >
> > Il 13/12/2011 02:56, xavierwork ha scritto:
> > >
> > >
> > > I have Chan's excellent FATFS posted to my project up and working
> > > nicely. I also have the USB portion working as a virtual com.
> > >
> > > I need to implement chan FS and the USB as a MSD. I am nearng the end
> > > of a long project, I am far behind, and very tired. I am certain
> > > someone has done this before. Can someone please share example code to
> > > help.
> > >
> > You can find example applications on NXP web site and on the examples of
> > Keil uVision and IAR Workbench for ARM installations. You have to
> > install their limited releases to obtain a lot of helpful examples. Some
> > other examples also on Code Red web site.
> >
> > If FS and USB/MSD libraries aren't working yet I think you aren't near
> > the end of your project; not for the libraries but for their calls that
> > have to be implemented and tested.
> > >
> > >
> > > Thanks,
> > > Xman
> > >
> > >
> >
> >
> >
> >
> >



Reply by capiman26061973 December 13, 20112011-12-13
Hello Lukas,

have a look for this example codes:

http://gandalf.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html

Best regards,

Martin

--- In l..., "lukas.jeindl" wrote:
>
> Hi Xman,
>
> unfortunately I can't supply you with mass storage code.
>
> You say you ported Chan's FATFS to LPC1768.
> Trying to port it to LPC1788 from the LPC23xx (MMC) version, I ran into a problem when replacing the routines "Store_Block" and "Load_Block" (previously in asmfunc.s) with memcpys.
> They seem to be not fast enough to empty the MCI buffer in time, so I had to increase buffer depth by 1.
> Current version of ChanFS seems to be for SPI and uses a while loop for block transfer.
>
> Did you create your own assembly procedures for these routines or addressed the issue in any other way?
> If yes, could you please post the solution here?
>
> Thanks in advance!
>
> Regards,
> Lukas
> --- In l..., "xavierwork" wrote:
> >
> > I have Chan's excellent FATFS posted to my project up and working nicely. I also have the USB portion working as a virtual com.
> >
> > I need to implement chan FS and the USB as a MSD. I am nearng the end of a long project, I am far behind, and very tired. I am certain someone has done this before. Can someone please share example code to help.
> >
> > Thanks,
> > Xman
>

Reply by xavierwork December 13, 20112011-12-13
Hello Lukas, my SD has an SPI interface. The DiskIO layer for the LPC17xx SPI I found in an app note from NXP (AN10916). This has been working well in my hardware thus far as I have been able to do the 3 things I needed... read dir, read file, write file. I am now stuck with trying to figureing out how to add MSD to the FATfs.

Sorry I do not have a solution for you. Good luck.

Thanks,
Xman
--- In l..., "lukas.jeindl" wrote:
>
> Hi Xman,
>
> unfortunately I can't supply you with mass storage code.
>
> You say you ported Chan's FATFS to LPC1768.
> Trying to port it to LPC1788 from the LPC23xx (MMC) version, I ran into a problem when replacing the routines "Store_Block" and "Load_Block" (previously in asmfunc.s) with memcpys.
> They seem to be not fast enough to empty the MCI buffer in time, so I had to increase buffer depth by 1.
> Current version of ChanFS seems to be for SPI and uses a while loop for block transfer.
>
> Did you create your own assembly procedures for these routines or addressed the issue in any other way?
> If yes, could you please post the solution here?
>
> Thanks in advance!
>
> Regards,
> Lukas
> --- In l..., "xavierwork" wrote:
> >
> > I have Chan's excellent FATFS posted to my project up and working nicely. I also have the USB portion working as a virtual com.
> >
> > I need to implement chan FS and the USB as a MSD. I am nearng the end of a long project, I am far behind, and very tired. I am certain someone has done this before. Can someone please share example code to help.
> >
> > Thanks,
> > Xman
>

Reply by xavierwork December 13, 20112011-12-13
Thank you M. Manca

Needless to say I have already searched the web, before I asked the LPC community.
I could not find anything on the NXP site specific to my needs. Not sure what you mean by install limited releases for IAR. This is for my home project, not work - I use CrossWorks, which is very affordable, but not very widely used. At work I now use IAR. Can you provide a little more specific information, the project can be from anything, if the code is there I should be able to work through it, but I do need a starting point.

Thanks,
Xman

--- In l..., "M. Manca" wrote:
>
> Il 13/12/2011 02:56, xavierwork ha scritto:
> >
> >
> > I have Chan's excellent FATFS posted to my project up and working
> > nicely. I also have the USB portion working as a virtual com.
> >
> > I need to implement chan FS and the USB as a MSD. I am nearng the end
> > of a long project, I am far behind, and very tired. I am certain
> > someone has done this before. Can someone please share example code to
> > help.
> >
> You can find example applications on NXP web site and on the examples of
> Keil uVision and IAR Workbench for ARM installations. You have to
> install their limited releases to obtain a lot of helpful examples. Some
> other examples also on Code Red web site.
>
> If FS and USB/MSD libraries aren't working yet I think you aren't near
> the end of your project; not for the libraries but for their calls that
> have to be implemented and tested.
> >
> >
> > Thanks,
> > Xman
> >
> >
>

Reply by "lukas.jeindl" December 13, 20112011-12-13
Hi Xman,

unfortunately I can't supply you with mass storage code.

You say you ported Chan's FATFS to LPC1768.
Trying to port it to LPC1788 from the LPC23xx (MMC) version, I ran into a problem when replacing the routines "Store_Block" and "Load_Block" (previously in asmfunc.s) with memcpys.
They seem to be not fast enough to empty the MCI buffer in time, so I had to increase buffer depth by 1.
Current version of ChanFS seems to be for SPI and uses a while loop for block transfer.

Did you create your own assembly procedures for these routines or addressed the issue in any other way?
If yes, could you please post the solution here?

Thanks in advance!

Regards,
Lukas
--- In l..., "xavierwork" wrote:
>
> I have Chan's excellent FATFS posted to my project up and working nicely. I also have the USB portion working as a virtual com.
>
> I need to implement chan FS and the USB as a MSD. I am nearng the end of a long project, I am far behind, and very tired. I am certain someone has done this before. Can someone please share example code to help.
>
> Thanks,
> Xman
>

Reply by "M. Manca" December 13, 20112011-12-13
Il 13/12/2011 02:56, xavierwork ha scritto:
>
>
> I have Chan's excellent FATFS posted to my project up and working
> nicely. I also have the USB portion working as a virtual com.
>
> I need to implement chan FS and the USB as a MSD. I am nearng the end
> of a long project, I am far behind, and very tired. I am certain
> someone has done this before. Can someone please share example code to
> help.
>
You can find example applications on NXP web site and on the examples of
Keil uVision and IAR Workbench for ARM installations. You have to
install their limited releases to obtain a lot of helpful examples. Some
other examples also on Code Red web site.

If FS and USB/MSD libraries aren't working yet I think you aren't near
the end of your project; not for the libraries but for their calls that
have to be implemented and tested.
> Thanks,
> Xman