Hello,
I've created a application of USB FLASH Drive acessing the 1MB internal FLASH of K64 using the Freescale's bareboard USB Stack 5.0 software + FRDM-K64F to be used by anyone as reference.
It seems to be stable, I already wrote some files on that and checked the integrity of the volume.
It can be very useful for datalogger application where the equipment can store data on the MCU FLASH using a internal filesystem, and read it through PC as it was a regular USB stick. It also very much cheaper than using a external SD Card, as it only needs the MCU + a external crystal and a USB connector.The only limitation so far is that it cannot exceed the number of the erase/write cycles of the device (of course!).
Please see the file attached with the USB Stack and the example on the folder "{Installation Path}\Freescale_BM_USB_Stack_v5.0\Src\example\device\msd\bm\iar\dev_msd_disk_frdmk64f". The project was wrote using IAR.
Also I have attached the srec file if you don't want to build the project by yourself.
Any issues, doubts or suggestions, please let me know.
Denis
Hi Denis
Please see the following: µTasker Kinetis FRDM-K64F support
This allows the same but the internal application can already access the card. In addition, the SD card can be used in parallel, plus an optional external SPI Flash - meaning that the USB host sees 3 hard drives when the FRDM-K64F is attached.
There are downloads there for comparison if of interest. The project is available as CW, KDS, IAR, Keil, Crossworks, Atollic, CooCox, GCC standalone and Green Hills setups, plus can be simulated in real-time using VisualStudio. It also works on any K, KL or KE device with enough internal memory to be of use.
Out of interest I checked the project that you posted and have the following remarks:
- Usually FAT in internal Flash uses a block management layer with wear-leveling. - this makes Flash operations faster because you don't need to erase a complete Flash sector each time you write data to a FAT sector
- The wear-leveling also ensures that the Flash sectors that are being erased/written most are not going to fail first (spreads the wear) - although this is of course only an issue when a very large amount of writes are performed
- When you erase a 4k Flash sector it would be better to use a define for this size otherwise the code is not correctly portable for processor with different Flash sector sizes
- The technique of erasing a Flash sector on each FAT sector write is a risk for systems requiring high reliability due to the fact that if there is a reset/power down during the process (which takes about 15ms each time) it is possible to lose important data that can result in corrupted files or a corrupted file system. Block management is therefore important in such systems since its operation automatically allows failure at any time without risk of corrupting the file system itself or data that has already been saved.
The project in the link has a define SIMPLE_FLASH which also allows exactly the same method. Without this define it switches in a block management layer (although I have to admit that there is a little extra work required to perform background mode house-keeping that is still being worked on).
Regards
Mark
Kinetis: µTasker Kinetis support
K64F: µTasker Kinetis FRDM-K64F support / µTasker Kinetis TWR-K64F120M support
For the complete "out-of-the-box" Kinetis experience and faster time to market
Hi Mark!
Thank you very much for your feedback! I will surely check the examples of uTasker!
Yes, you are right. There is no wear-leveling scheme on this version of the project. The idea here was to make something easy to understand and baremetal (no OS) for further use. I will work on this implementation for the future releases.
Thank you again!
Regards,
Denis
Hi Denis,
I tried using the project, but every time I disconnect the board from the PC and re-connected it, it keeps trying to do a
FORMAT. If I format it and place a small file, I can never see it, because it asks for formatting.
Any idea on this?
Thanks,
Neil
Hey dshimizu,
Interesting project. I've looked at doing an application like this repeatedly over the years but wasn't sure how as I would also have a USB CDC device running in parallel (and never had enough time to do the research). There are a few examples providing USB MSD but none that I've tried actually work as I would expect; when you plug in the Freedom board with the example projects (ie dev_composite_cdc_msc_bm/freertos) you just end up with an error message.
I should point out that the SDK MSD examples (seem to have the same issue as what neilporven is reporting; when you plug the Kinetis into a PC you will be told that the drive needs to be formatted before you can copy in any files. The data is lost when you plug in again (and have to format).
Just a few comments back to mjbcswitzerland, a few years ago, I took the basic FatFS code and ported it to the K20DN512 (under MQX) and got it running quite nicely with a lot of work. It's fairly easy to implement "as is" but to get it working practically in a Kinetis (and the internal Flash of any MCU) you're going to have to:
I'd love to see this project move forwards (and understand the issues) because it would eliminate the need for the custom software I use for accessing the file system contents through a CDC device with custom software. Bonus, as I said, would be able to communicate with the Kinetis concurrently using a CDC device.
myke