|
- FAT32 and its long filename extensions VFAT, were never meant to ran
on a microcontroller with only 4K SRAM.
- The micro is too slow to index/search and deal with directory trees
quickly and effeciently
When I first started interfacing a hard disc to a microcontroller, it
was obvious that using the FAT filing system was a good idea from the
point of view of ease of copy files and data on to the drive from a PC.
I developed a lot of embedded code to read disks, and to even impliment
some cutdown ANSI C style file commands like fopen(), fgetc(), etc, and
to support directory trees. (click here
for more information)
While this worked and the results were good, there is constant battle
of running out of SRAM on the small microcontroller as my boards only
used the internal SRAM that is contained on the AVR ICs.
When I redesigned my MP3 player, I decided I wanted the following features;
- To allow 'normal' directory structures with MP3s placed in logical form,
rather than having to store them all in the root directory like many other
MP3 players.
- To support some sort of playlist/grouping features, whereby albums or
collections of songs could be grouped together.
- To be able to change track quickly, and to be able to skip groups of
tracks with out much effort.
The main problem with continuing to impliment string matching to search
through folders finding subfolders and files was that it used plenty of
memory (RAM), especially considering you have to buffer the VFAT entries
and then match up long file names.
My only method of putting files onto the player would be to put this hard
disk into a PC and copy data on to it, so why not use the PC to build
up an index or a database of playlists that is easily readable from the
MP3 player, whilst still maintaining the ability to format the drive with
FAT32?
The idea is to put the hard disk into the PC, copy on the MP3s into any
folder structure that you choose and then to run a small application which
takes these files, looks at the FAT32 drive, works out where each MP3
starts, and write all this information, and playlist orders into a small
binary database file which is easily understandable on a memory limited
system.
I wrote the tool in Windows tool in C# (using some unmanaged C++ DLL's
to access the disk) to perform this indexing function
Now that I had this small database system on the target disk drive
with the MP3s, the MP3 players firmware could be striped of its directory
browsing, indexing and matching code which used all that precious SRAM.
Using only basic FAT32 disk access (including cluster traversing) I could
now read MP3s quickly which were grouped in playlists.
Click
Here to Download Executable...
Written mostly in C# with some C++ DLL's, the MPFS Windows tool creates
playlists automatically from a FAT32 formatted partition, and creates
the cutdown playlist file.
Supports the new 'database' format, and the 'Sony
Rotary Commander' joystick controller.
Click
Here for source code...
- Auto locate 'playlist.bin' file in root dir to play all playlists from.
- Favourites Manager: Add a track you like to favourites for ease of playing
again.
- General playlisting improvements
- Control commands can come from serial port or through decoding an ADC
channel for devices like Sony Rotary Commander.
|
|
|