![]() |
Forum Index : Microcontroller and PC projects : PicoMite: Does the filesystem care about cluster size?
Author | Message | ||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
I have some "Old new stock" SD cards in the 128MB flavour(yes, megabyte!), which are going to be perfect for my security system upgrade based on the PicoMite, but I am just curious about if the SD card handler in the PM firmware cares at all about allocation(cluster) size. All the database and log-files are saved on the SD card, but the default for such small cards is FAT16 with 16KB clusters, meaning that if your database file is only 100 bytes or so, it is allocated 16KB of disk space. You can reformat the SD cards to FAT32, and use 512-byte clusters instead of the 16KB for FAT16, and this means that these little files only now use 512 bytes of disk space, a saving of 15.5KB or so per file, or a 96% space saving per file with these small files on a small SD card. Over several hundred files, this adds up to a LOT of space being assigned to nothing at all with FAT16 and 16KB clusters. With modern cards this is not an issue as they are so huge in capacity, you never need to worry, but I want to use these older cards, as they are absolutely perfect for simple activity logging and storing a database of text messages etc - while being just about useless for anything else these days. ![]() So, my question is really about if the PM firmware supports only the DEFAULT cluster sizes, or can it use anything that the card has been formatted to? Reading is not really my concern, it is writing to the card if you use a non-default cluster size that the FW does not support - that could be catastrophic in the worst-case scenario, so if someone could give me a yes or no, that would be great. Smoke makes things work. When the smoke gets out, it stops! |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
The answer will be deep inside FatFS - why not try it and see? |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
OK, based on your reply, I will format a card using FAT32/512, copy a few files to it, and use the COPY command and see what happens. If that works OK, I will then put the card back in the PC and see if I can read the copies. I just did not want to try this, if it was definitely a no-no and might cause serious corruption etc, but I suppose if it works on a card formatted like that, I can assume that everything is OK, especially with respect to writing. Hopefully not false logic! ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5091 |
Hi, Even with 16kb per file, you can store (128000000/16000 =) 8000 files on that card. Since the file system will take it's part of the 128Mbyte, practical will be some 6000-7000 files, but I guess that is far more than you will use. Volhout PicomiteVGA PETSCII ROBOTS |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Excellent point. I might just leave the cards as FAT16/16 and move on. Perhaps I am simply chasing my tail to some extent. Daily activity logs average 2-3KB in size(plain text), with the odd large file if there has been a day(or night) of heavy activity for some reason, or system testing where they are trying everything to make sure it is working etc. It's the old DOS man in me, still thinking about clusters, heads and sectors and trying to arrange things for the best efficiency!!! ![]() Really a non-issue with today's modern storage capacities, but when I come across those older smaller capacity things, my brain goes right back in there again! Old habits die hard...... EDIT: Seems to work fine. I did the test anyway, and used MMBASIC's COPY command to copy a 450KB or so file to another filename. Worked with FAT32/512 just fine, copied filename is exactly the same size as the original, and I can read the copy just fine on my main PC, so it would seem to support non-default cluster sizes should you wish to format any card like that. But based on the above, I will just leave them as FAT16/16, cos even that is gonna cater for thousands of log files, so.... Edited 2022-08-31 20:18 by Grogster Smoke makes things work. When the smoke gets out, it stops! |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
Normally things like log files would OPEN APPEND, so the filesystem wouldn't allocate an additional block until the existing one was full. Unless you are writing individual files every time? Likewise, a database might use OPEN RANDOM to read, even if it was originally written with OPEN APPEND. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |