Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 22 Sep 2016 02:58 PM by  Adam Ford
How to erase SD card
 8 Replies
Sort:
You are not authorized to post a reply.
Author Messages
Matt McGarvey
New Member
New Member
Posts:6


--
23 Aug 2016 12:52 PM

    We have the DM3730 board running a Linux OS and need ability to erase MicroSD card content.

    But Linux "dd" command too slow (takes approx. 15 minutes).

    Are there any docs on low level commands that can be sent to the drive via ioctl() which can perform faster bulk erase ?

    Thanks.

    Matt

    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    24 Aug 2016 06:47 AM
    dd is the method I know. I'm going to ask around.

    Are you looking to completely zero the SD card or just wipe out the partition table?

    (Here is a link for wiping the partition table)
    https://www.chrisnewland.com/linux-wipe-sd-card-partition-table-277


    adam
    Matt McGarvey
    New Member
    New Member
    Posts:6


    --
    24 Aug 2016 06:53 AM
    We want to completely zero the SD card as fast as possible; dd is too slow.
    I see there are MMC command codes in mmc.h (e.g. MMC_ERASE), but I have not found online a document which describes exactly how to do this.
    Thanks.
    Matt
    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    25 Aug 2016 10:12 AM
    I have asked a colleague, but he isn't aware of how to do this. I've asked a couple other Linux guys as well. I'll let you know if/what they have to report.

    adam
    Matt McGarvey
    New Member
    New Member
    Posts:6


    --
    19 Sep 2016 12:41 PM
    I see there is an 'mmc_erase' function inside the mmc driver code located in:
    ./rpm/BUILD/linux-3.0/drivers/mmc/core/core.c
    But I cannot see how this can be called from user application code as I see no mention of it in the include files used by the app code.
    Do you think it is reasonable to update the driver code to react to a custom ioctl command code and execute this mmc_erase() function within the driver code ?
    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    21 Sep 2016 08:44 AM
    Our developer is out, and I am not sure when he comes back, but I did a little searching and I found some patches that were submitted in 2010.

    They may not cleanly apply, but I think it's in the general direction you want.

    https://groups.google.com/forum/#!topic/linux.kernel/MATo4Wf9kdU

    The patch explictly states it's will: Add ability to do MMC erase and secure erase operations from userspace, using the BLKDISCARD ioctl and a newly created BLKSECDISCARD ioctl.

    I don't believe these were ever fully accepted into the linux community, so I would use them at your own risk.

    adam

    Matt McGarvey
    New Member
    New Member
    Posts:6


    --
    21 Sep 2016 09:10 AM
    OK - Great! I will try that out and post a reply on how it goes.
    In the mmc driver code, I noticed that it checked on a flag 'REQ_DISCARD' but that appeared to be on the code which serviced I/O requests on the device and not ioctl commands, and I couldn't figure out how user space code would be able to cause this flag to be set in a write command.
    Matt McGarvey
    New Member
    New Member
    Posts:6


    --
    22 Sep 2016 02:21 PM
    Thanks so much for the tip on BLKDISCARD !
    I found source code online to build a 'blkdiscard' console app and using it to wipe the card with BLKDISCARD worked very fast (2 sec for 7.6 GB card. Cannot confirm whether all data was really wiped this fast or the command returns before h/w io is actually complete....looking at the driver source code it appears to be synchronous but I was astonished at how fast this went.). With the SD card I am using the BLKSECDISCARD variant resulted in 'not supported' error but I don't think I need that.
    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    22 Sep 2016 02:58 PM
    That's fantastic! I am glad it worked out. Let us know if you have any other questions or issues.

    adam
    You are not authorized to post a reply.