Problem with FAT component

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time
Contact:

Problem with FAT component

Post by Eric »

Hello,

I want to create a datalogger on MMC card.
The idea is that every time the logger is restarted or reset, a new logfile is created in the root directory.
The attached program is a simplified version of the final program just to demonstrate my problem.
It creates 5 logliles ( LOG1.TXT, LOG2.TXT .... LOG5.TXT ) and it writes in every logfile some text ( AZERTYUIOPQSDFGHJKLM ).
After reading the MMC on pc, I noticed that the 5 logfiles are indeed created.
But only in file 1, 3 and 5 the data is written. In file 2 and 4, no data is written however the file lenghts of all files are equal.
Investigating the resulting MMC in Winhex shows that the MMC is formated with a clustersize of 0x2000, while the data is only written every 0x4000.
The problem is reproducable on another pc.
Only every second file contains data.
The MMC is formatted in XP SP3 as FAT16.
Any idea what is goiing on here?

Best regards,
snap0414.jpg
(178.58 KiB) Downloaded 1246 times
snap0415.jpg
(180.14 KiB) Downloaded 1244 times
Attachments
Test MMC.fcf
(8.5 KiB) Downloaded 282 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with FAT component

Post by Benj »

Hello,

When you formatted the card did you specify the sector size as 512 Bytes. If you do not do this then the embedded memory allocation will not work correctly. I am currently in the process of testing several different cards with the FAT component and hope to have a more conclusive list available soon. This is bacause some of the newer cards have a default sector size of 1024 and above.

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time
Contact:

Re: Problem with FAT component

Post by Eric »

Hi Ben,

Thanks for your reply.
But unfortunatly XP Pro SP3 doesn't offer me the choise to format the MMC in another format as the default one.
snap0422.jpg
snap0422.jpg (22.14 KiB) Viewed 4771 times
It is important to know that in my full program the filesize of the even files with no data in it are effectively growing as the logging continues. There is only no visible data written in the even files. This means that the file allocation tables of the even files are effectively adapted when the file growes.

Best regards,

Eric

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time
Contact:

Re: Problem with FAT component

Post by Eric »

Hello Ben,

Any progress on this issue?

Regards,

Eric

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with FAT component

Post by Benj »

Ok I have come across this website that lists a lot of the common MMC and SD cards available.

http://www.embedded-os.de/index.html?pcfat_port.htm

Here it shows that some cards do not have a standard sector size of 512 bytes. If your cards are in the list and do not have a sector size of 512 then they will likely not work with the FAT component though there may be a lengthy workaround by manually editing the code. I also saw a paragraph stating that some SD cards do not support the SPI protocol that is used to communicate with the card!!! If this is the case then the component will not be able to talk to the card at all.

I have also found this information about SDHC cards. This website states that they start at 4GB and require a faster connection then the normal SD cards, therefore I dont think the component will support this new standard.

http://www.sdcard.org/developers/tech/sdhc/

Looking on this online memory card shop I have found that there are still a lot of standard SD cards available. I have had good results with a "Integral 512MB SD Memory Card" and a "Transcend 1GB SD Memory Card" if you can find them anywhere. Beware though the "Transcend 2GB SD Memory Card" will not work as it has a sector size of 1024 bytes rather then the standard 512.

http://www.memorybits.co.uk/categories/sd/756

lionelb
Posts: 1
Joined: Wed Jul 21, 2010 11:53 am
Contact:

Re: Problem with FAT component

Post by lionelb »

Hi, I am playing with Micro SDHC and read the extensive wiki at http://en.wikipedia.org/wiki/Secure_Digital

note in the paragraph on "File system" that ;
"USB-based SD card readerLike other flash card technologies, most SD cards ship preformatted with a file system on top of an MBR partition scheme. SD cards are typically formatted as FAT16, SDHC cards as FAT32, SDXC cards as exFAT. The ubiquity of FAT16 and FAT32 allows those cards to be accessed on virtually any host device with an SD reader. Also, standard FAT maintenance utilities (e.g., SCANDISK) can be used to repair or retrieve corrupted data, and some utilities can recover deleted files, providing that they have not been overwritten. However, because the card appears as a removable hard drive to the host system, the card can be reformatted to any file system supported by the operating system. "


SDSC are 1MB to 4 GB are formatted as FAT16 (referred to as SD)
SDHC are 4 GB to 32 GB are formatted as FAT32 ( I am interested in the Micro SDHC which fits here)
SDXC are >32 GB to 2 TeraB

At the very end of this wikipedia page there is a paragraph on Interfacing ... in particular "Interfacing to SD cards, great technical details" .... http://elm-chan.org/docs/mmc/mmc_e.html ..... http://elm-chan.org/fsw/ff/00index_e.html

Hope this clears your logjam.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with FAT component

Post by Benj »

Hello,

There is an updated FAT component available from here.
http://www.matrixmultimedia.com/mmforum ... FAT#p19450

If anyone experiences that the init routine causes a hang with the updated component then I have another fix for this which will be included in the May release. I've only ever come across this problem when using micro SD cards.

Post Reply