方法一:
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")));
}
上面的代码为除了nboot、TOC、eboot和nk之外的空间创建一个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
"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_DOS32和PART_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
另外使用ADS分区的,也有使用应用程序的,不过我没实现,始终没成功。望知道的人分享探讨下。
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")));
}
上面的代码为除了nboot、TOC、eboot和nk之外的空间创建一个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
"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_DOS32和PART_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