WINCE6.0+SLC NAND FLASH创建多个分区

备注:

三星S3C2451原厂的BSPSMDK2450_WinCE60_FMD_REL_1.10_090516》此BSP默认情况下把FLASH分为两个分区,一个为PART_BINFS分区,用于保存nk,另一个为PART_DOS32(FAT32)分区,其中BINFS分区隐藏,在系统启动之后,可以看到的只有FAT32分区,下面把实现的方式总结出来。

 

1.      三星原厂两个分区的实现方式

1.1  WriteOSImageToBootMedia函数

 // create extended partition in whatever is left

   //

   hPartEx = BP_OpenPartition( NEXT_FREE_LOC,

                               USE_REMAINING_SPACE,

                               PART_DOS32,

                               TRUE,

                               PART_OPEN_ALWAYS);

 

   if (hPartEx == INVALID_HANDLE_VALUE )

   {

       OALMSG(OAL_WARN, (TEXT("*** WARN: StoreImageToBootMedia: Failed to open/create Extended partition ***\r\n")));

}

上面的代码为除了nbootTOCebootnk之外的空间创建一个FAT32的分区。

 

1.2  Platform.reg注册表信息

 

IF BSP_NONANDFS !

; HIVE BOOT SECTION

 

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SMFLASH]

   "DefaultFileSystem"="BINFS"

   "PartitionDriver"="mspart.dll"

   "MountHidden"=dword:1

   "MountAsROM"=dword:1

   "Folder"="ResidentFlash"

   "Name"="Microsoft Flash Disk"

 

; Keep FATFS from trying to shadow \Windows

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SMFLASH\FATFS]

   "MountHidden"=dword:0

   "MountAsROM"=dword:0

 

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\SMFLASH]

   "Prefix"="DSK"

   "Dll"="smflash.dll"

   "Index"=dword:1

   "Order"=dword:0

   "Profile"="SMFLASH"

   "IClass"="{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"

 

[HKEY_LOCAL_MACHINE\System\StorageManager\FATFS]

   "Flags"=dword:00000014        ;FATFS_TFAT_ALWAYS|FATFS_FORCE_TFAT

    

[HKEY_LOCAL_MACHINE\System\StorageManager\AutoLoad\SMFLASH]

   "DriverPath"="Drivers\\BuiltIn\\SMFLASH"

   "LoadFlags"=dword:1

   "BootPhase"=dword:0

 

; END HIVE BOOT SECTION

ENDIF ; BSP_NONANDFS

 

系统起来后可以看到ResidentFlash盘符,文件系统是FATFS

1.3   

2.      三个分区的实现

 

2.1  WriteOSImageToBootMedia函数

 

// create user partition size

hPartEx1 = BP_OpenPartition(NEXT_FREE_LOC ,

SECTOR_TO_BLOCK_SIZE(FILE_TO_SECTOR_SIZE(SYS_PARTITION_SIZE))*PAGES_PER_BLOCK, // align to block

 PART_DOS32,

 TRUE,

 PART_OPEN_ALWAYS);

 

if (hPartEx1 == INVALID_HANDLE_VALUE )

{

 OALMSG(1, (TEXT("*** WARN: StoreImageToBootMedia: Failed to open/create Extended partition 1111 ***\r\n")));

}

 

hPartEx2 = BP_OpenPartition( NEXT_FREE_LOC,

USE_REMAINING_SPACE,

PART_DOS32X13,

TRUE,

PART_OPEN_ALWAYS);

 

if (hPartEx2 == INVALID_HANDLE_VALUE )

{

 OALMSG(1, (TEXT("*** WARN: StoreImageToBootMedia: Failed to open/create Extended partition 2222***\r\n")));

}

这里需要注意,创建的两个分区所采用的是不同的文件系统,分别是PART_DOS32PART_DOS32X13

 

2.2  Platform.reg

;---- NAND Flash Driver ---------------------------------------------------------

IF BSP_NONANDFS !

; HIVE BOOT SECTION

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\NAND]

        "Prefix"="DSK"

        "Dll"="smflash.dll"

        "Order"=dword:0

        "Index"=dword:3

        "Profile"="NAND"

        "Ioctl"=dword:4

        "IClass"="{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"

        "Flags"=dword:1000

 

;[HKEY_LOCAL_MACHINE\System\StorageManager\AutoLoad\NAND]

        ;"DriverPath"="Drivers\\BuiltIn\\NAND"

        ;"LoadFlags"=dword:1                       ; load synchronously

        ;"BootPhase"=dword:0

        ;"MountAsBootable"=dword:1                 ; for Hive-based registry

        ;"Flags"=dword:1000

 

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\NAND]

        "DefaultFileSystem"="BINFS"

        "PartitionDriver"="mspart.dll"

        "Name"="Microsoft Flash Disk"

        "AutoPart"=dword:1

        "AutoFormat"=dword:1

        "AutoMount"=dword:1

        "BootPhase"=dword:0

        "Flags"=dword:1000

        ;"Folder"="HIVE1"

 

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\NAND\BINFS]

        "MountHidden"=dword:1

        "MountAsROM"=dword:1

 

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\NAND\FATFS]

        ;"FormatExfat"=dword:1

        "FormatFAT"=dword:1

        "Flags"=dword:14                               ; deprecated in CE6.0 (0x4 : FATFS_DISABLE_AUTOSCAN, 0x10 : FATFS_ENABLE_BACKUP_FAT)

        "DisableAutoScan"=dword:1

        "CheckForFormat"=dword:1

        "EnableWriteBack"=dword:1

        "AutoFormat"=dword:1

        "MountAsRoot"=dword:1                 ; for ROM-only file system

        "MountAsBootable"=dword:1                  ; for Hive-based registry

 

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\NAND\FATFS]

        "Flags"=dword:00000024

        

[HKEY_LOCAL_MACHINE\System\StorageManager\AutoLoad\NAND\Filters\CacheFilt]

        "Dll"="cachefilt.dll"

        "LockIOBuffers"=dword:1

 

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\NAND\FATFS\Filters\CacheFilt]

        "Dll"="cachefilt.dll"

        "LockIOBuffers"=dword:1

 

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\NAND\PART01]

            "Name"="Microsoft Flash Disk"

            "Folder"="NAND"

 

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\NAND\PART02]

            "Name"="Microsoft Flash Disk"

            "Folder"="Flash"

;END HIVE BOOT SECTION

ENDIF ; BSP_NONANDFS

 

你可能感兴趣的:(WINCE6.0+SLC NAND FLASH创建多个分区)