none
Why Fails to call FormatStore or FormatPartition? RRS feed

  • Question

  •            I success to call FormatVolume to Format NandFlash to FAT32.

               when i try to format store or format Partition, it always Fails, And i debug by call GetLastError()

              The error code is 31,

               31 A device attached to the system is not functioning.     ERROR_GEN_FAILURE 
           

               According to MSDN   ,it indicates as follows:

    /*
    The following steps show the process for partitioning a storage volume:

    Open the storage volume using OpenStore.
    Dismount all file systems on the store, using DismountStore.
    Format the store, using FormatStore.
    Create the desired number of partitions on the store, using CreatePartition.
    If the AutoFormat registry value is not set, format the partition using FormatPartition.
    For more information on the Storage Manager registry settings, see Storage Manager Registry Settings.
    */    

     

              hStore = OpenStore(szStoreName);
                
                #if 1// Formate store
                  DismountStore(hStore); 

                  if(FormatStore(hStore)==TRUE)
                  { 
                RETAILMSG(1,(TEXT("FormatStore OK\r\n")));
                Sleep(10); 
                }
                  else
                {  
                wsprintf(szChar,TEXT("FormatStore is Failed. Error code is
                %d.\r\n"), GetLastError());
                RETAILMSG(1,(TEXT("FormatStore Fail %d,\r\n"), GetLastError() ));
                }
                #endif
                  
                #if 1//Formate Partition
                  HANDLE hPartition = OpenPartition(hStore,szPartName);

                  DismountPartition(hPartition); 

                  if(FormatPartition(hPartition)==TRUE)
                  { RETAILMSG(1,(TEXT("FormatPartition OK\r\n")));
                Sleep(10); 
                }
                  else
                {  
                wsprintf(szChar,TEXT("FormatPartition is Failed. Error code is
                %d.\r\n"), GetLastError());
                RETAILMSG(1,(TEXT("FormatPartition Fail %d\r\n"), GetLastError() ));
                }
                #endif


    Everything is possible.
    Monday, November 14, 2011 8:01 AM

All replies

  • Is the HANDLE returned by OpenPartition valid? Has been the partition already created? What happens if you use CreatePartition instead? There's a lot of scenarios in which the storage and the partition manager returns ERROR_GEN_FAILURE: have you got the opportunity to run a debug build and see what happens inside %_WINCEROOT%\PRIVATE\WINCEOS\COREOS\STORAGE?


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com
    Monday, November 14, 2011 9:24 AM
  • Hello Luca Calligaris

    HANDLE  returned by  OpenPartition is  "0xc37a28ee" ,that is ,it is valid.

    the partition exists when windows runs , while debug: szStoreName is   0x000162a0 "DISK1"     szPartName is   0x00016098 "PART00"

    I can use FormatVolume to Format NandFlash to FAT32 , in the other words , I succeed in using ""FormatVolume "to format Flash.

    The whole process I do as follows:

    Step1: Format NandFlash to FAT32 by FormatVolume

    Step2: Copy Files to folders in NandFlash by CopyFile

    Step3: Update the Wince 5.0 OS Eboot and image.

    However,  Step1 failed in 1%chance, success in 99% chance.

     ( step1.1 OpenPartition  

       Step1.2 DismountPartition

       Step 1.3 DeviceIoControl(DISK_IOCTL_GETINFO)

       Step1.4:  FormatVolume

                   fo.dwClusSize = 8*1024; //8KB

                     fo.dwFatVersion = 32;

                   fo.dwNumFats = 1;

                     fo.dwRootEntries = 512;

                      fo.dwFlags = 0;   

    )

    The 1% case is that the "PART00" is lost .  then i can not to do the follow  copy job.

    I do not know why, then I guess,

    The new Wince 5.0 OS Eboot and image is different from the old OS by the Partition, May be it is the root reason,

    Then I try to find the way to format the store or format the Partition by calling FormatStore or FormatPartition just in order to format the MBR.

    It fails each time when debug step by step.

     


    Everything is possible.
    Tuesday, November 15, 2011 6:20 AM