Hot!Format USB Thumb drive

Author
LeeZimme
Starting Member
  • Total Posts : 74
  • Reward points : 0
  • Joined: 2014/06/11 12:14:35
  • Location: 0
  • Status: offline
2016/07/14 15:16:27 (permalink)
0

Format USB Thumb drive

I want to format USB thumb drive using the pic24fj256gb110
 
I was cheating before and just erasing all files in the root directory.  Which was good enough at the time but now I need to do a proper format.  New disks aren't formatted correctly and bogus files can stick around on disk.
 
What is usbMediaParameters?  Can I read serial number and name from a disk in the wrong format?  I don't want to rename it or give it a new serial number.
 
    
case FORMAT_DRIVE:
        if (FILEIO_MediaDetect(&gUSBDrive, &deviceAddress) == true)
        {
           FILEIO_Format( &gUSBDrive, &usbMediaParameters, FILEIO_FORMAT_BOOT_SECTOR, 12456 , "test");
        }
        msdState = WAITING_FOR_DETACH;
        break;

 
Below is my cheat
    
case FORMAT_DRIVE:
        if (FILEIO_MediaDetect(&gUSBDrive, &deviceAddress) == true)
        {
            if (FILEIO_DriveMount('A', &gUSBDrive, &deviceAddress) == FILEIO_ERROR_NONE)
            {
                FILEIO_SEARCH_RECORD record;
                if (FILEIO_Find(buffer, 0xFF, &record, true) == FILEIO_RESULT_SUCCESS)
                {
                    FILEIO_Remove(record.shortFileName);
                    while (FILEIO_Find(buffer, 0xFF, &record, false) == FILEIO_RESULT_SUCCESS)
                    {
                        FILEIO_Remove(record.shortFileName);
                    }
                }
                FILEIO_DriveUnmount('A');
            }
        }
        msdState = WAITING_FOR_DETACH;
        break;

 
 
           
#1

1 Reply Related Threads

    Zer0204
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2018/08/09 07:35:25
    • Location: 0
    • Status: offline
    Re: Format USB Thumb drive 2018/08/10 05:49:59 (permalink)
    0
    Did you get a solution about this?
    I am trying to do the same.
     
    #2
    Jump to:
    © 2018 APG vNext Commercial Version 4.5