Skip to main content
ingwmeier
Senior
June 27, 2016
Question

uSDcard sector or block handling

  • June 27, 2016
  • 2 replies
  • 632 views
Posted on June 27, 2016 at 16:48

we try to use a uSDcard efficiently to log process Data. This works great. Now we would like to erase certain sectors in order to have a kind of a ''ring buffer'' for these process Data.

We can't find any documentation for such low level chip handling, (similar to flash handling onchip flash in STM32 chips). Has anyone any experience in this? Or is the controller on a uSDcard ''hiding'' everything? Erase a file using Fatfs does not really erase anything but just mark something as erased.
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    June 27, 2016
    Posted on June 27, 2016 at 17:51

    Correct, FatFs just manages files system structures, which are agnostic to the underlying media, and what it might do.

    If you want to manage the erase blocks on the media, then you are going to have to become familiar with the command set of the MMC/SD cards themselves. The flash controller on the card (small micro) manages the blocks, deblocking, erase, and wear management. The erase block on the media is probably 128KB, see geometry specification returned by card, this is generally unmanageably large for a micro-controller, and the 512 byte block level is similar to that of classical hard drives.

    Unless you have some particular file system, and block storage media skills, it's going to be a bit of a chore to navigate through the FAT file system structures, mapping blocks to erase underlying flash array, especially where unaligned, or non-contiguous runs are involved.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    ingwmeier
    ingwmeierAuthor
    Senior
    June 29, 2016
    Posted on June 29, 2016 at 08:47

    Thank you clive, we thougt so. We will work with time stamps in the data.