MULTI BIN的wince 5.0,smdk2440下的实现
原本早就要发出来了,但是看到king_sundi网友已经发过一个帖子了,所以犹豫了没有发,相对而言,我这个总结更具有实用性,基本上照着这个步骤来就能成功,我给我几个朋友试过了,他们一开始对这个基本不懂都能搞定。
XIP实现总结.
step1:修改config.bib文件.内核子集XIPKERNEL的SIZE根据你自己编译出来的XIPKERNEL.BIN实际大小调整,
XIPKERNEL BASE=8C200000,XIPKERNEL SIZE = 0013F000 内存类型是RAMIMAGE
CHAIN BASE = XIPKERNEL BASE + XIPKERNEL SIZE; CHAIN SIZE = 00001000 内存类型是RESERVED
NK BASE = CHAIN BASE + CHAIN SIZE;NK SIZE根据你平台定制的实际NK.BIN的大小调整, 内存类型是 NANDIMAGE
RAM BASE = NK BASE + NK SIZE; RAM SIZE = 90000000 - RAM BASE, 内存类型是 RAM.
pdwXIPLoc 是一个指定地址的全局变量,用于InitRomChain(),它的地址必须等于CHAIN BASE.
XIPSCHAIN=8C33F000 也必须等于CHAIN BASE.
关于BIB文件中的MEMORY部分的定义可以从帮助文档中找到答案,搜索MEMORY Section
Name Address Size Type
内存区域名字 起始地址 区域空间 内存类型
内存类型的取值分别有FIXUPVAR,NANDIMAGE,RAM,RAMIMAGE,RESERVED.
大家可以特别注意看一下NANDIMAGE的解释
Specifies that RAM should overlap these regions when building an run-time image that uses BINFS.
The overlapping regions are stored in NAND but are fixed up to virtually appear as though they do not overlap.
When the kernel accesses these regions, BINFS responds by intercepting the request. BINFS accesses NAND and returns the proper data to the kernel.
This enables a device with NAND to execute in place out of NAND, freeing up RAM for use by the system.
Romimage generates one binary (.bin) file for each NANDIMAGE entry.
NANDIMAGE sections must be page aligned.
MEMORY
XIPKERNEL 8C200000 0013F000 RAMIMAGE
CHAIN 8C33F000 00001000 RESERVED
NK 8C340000 00D00000 NANDIMAGE
RAM 8D040000 02FC0000 RAM
; RAM 8C340000 03CC0000 RAM
pdwXIPLoc 00000000 8C33F000 FIXUPVAR
; FLASH 92000000 00100000 RESERVED
; Common RAM areas
AUD_DMA 8c002000 00000800 RESERVED
SDIO_DMA 8c010000 00010000 RESERVED
ARGS 8C020800 00000800 RESERVED
DBGSER_DMA 8c022000 00002000 RESERVED
SER_DMA 8c024000 00002000 RESERVED
IR_DMA 8c026000 00002000 RESERVED
; EDBG 8c030000 00020000 RESERVED
; CAMERA 8c050000 000A0000 RESERVED
DISPLAY 8c100000 00100000 RESERVED
;
; ROMFLAGS is a bitmask of options for the kernel
; ROMFLAGS 0x0001 Disallow Paging
; ROMFLAGS 0x0002 Not all KMode
; ROMFLAGS 0x0010 Trust Module only
;
CONFIG
AUTOSIZE=ON
; ROM_AUTOSIZE=ON
DLLADDR_AUTOSIZE=ON
COMPRESSION=ON
KERNELFIXUPS=ON
XIPSCHAIN=8C33F000
PROFILE=OFF
ROMFLAGS=00
ROMSTART=8C200000
ROMWIDTH=32
ROMSIZE=00D00000
【注】PB能生成XIP.BIN,这项一定要定义XIPSCHAIN=8C33F000,不然生成不了XIP.BIN的。
step2:
注册表的修改,platform.reg
; HIVE BOOT SECTION
; @CESYSGEN IF CE_MODULES_SDNPCID
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Support BINFS Section
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Add BinFS to partition table
[HKEY_LOCAL_MACHINE/System/StorageManager/PartitionTable]
"21"="BINFS"
[HKEY_LOCAL_MACHINE/System/StorageManager/BINFS]
"Folder"="BINFS"
"FriendlyName"="Bin FileSystem"
"Dll"="binfs.dll"
"Paging"=dword:1
; MountFlags:
; 0x10 specifies that this file system is to be mounted as an external
; ROM filesystem shadowing the /windows directory
; 0x1 specifies that the mountpoint /BINFS is to be hidden
;
"MountFlags"=dword:10
"BootPhase"=dword:0
[HKEY_LOCAL_MACHINE/System/StorageManager/AutoLoad/MSFlash]
"DriverPath"="Drivers//BuiltIn//MSFlash"
; LoadFlags 0x01 == load synchronously
"LoadFlags"=dword:1
"Order"=dword:0
; "MountFlags"=dword:10
"BootPhase"=dword:0
"Flags"=dword:1000
[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/MSFlash]
"Prefix"="DSK"
"Order"=dword:0
"Dll"="smflash.dll"
"Profile"="MSFlash"
; "MountFlags"=dword:10
"FriendlyName"="MSFLASH Driver"
"BootPhase"=dword:0
"Flags"=dword:1000
; Bind BINFS to the block driver
[HKEY_LOCAL_MACHINE/System/StorageManager/Profiles/MSFlash]
"DefaultFileSystem"="BINFS"
"PartitionDriver"="mspart.dll"
"AutoMount"=dword:1
"AutoPart"=dword:1
"Folder"="NandFlash"
"Name"="Microsoft Flash Disk"
"BootPhase"=dword:0
"Flags"=dword:1000
"MountAsHidden"=dword:1
"MountAsRom"=dword:1
; "MountFlags"=dword:00000004
; "MountHidden"=dword:00000000
[HKEY_LOCAL_MACHINE/System/StorageManager/Profiles/MSFlash/FATFS]
"FriendlyName"="FAT FileSystem"
"Dll"="fatfsd.dll"
"Flags"=dword:00280014
"Paging"=dword:1
"CacheSize"=dword:0
"EnableCacheWarm"=dword:0
"EnableCache"=dword:1
"MountAsBootable"=dword:1
"MountAsRom"=dword:1
; "MountAsRoot"=dword:1
; @CESYSGEN ENDIF CE_MODULES_SDNPCID
; END HIVE BOOT SECTION
step3:
系统选用的文件系统必须是RAM and ROM Filesystem,不能用ROM Only.
step4:
要知道内核子集XIPKERNEL.BIN必须包含的modules和Files是那些,根据我的实践得出,下面这些文件是必需的:
"nk.exe",
"coredll.dll",
"filesys.exe",
"fatfsd.dll",
"diskcache.dll",
"fatutil.dll",
"binfs.dll",
"fsdmgr.dll",
"mspart.dll",
"smflash.dll",
"boot.hv",
其它的可选.
step5:
使用preromimage.bat和processbib.exe程序,把它们拷贝到你的PLATFORM/SMDK2440/FILES/目录下.
到此改动就算结束了,下面就是开始Build and Sysgen.
生成了XIP.BIN之后烧写到NAND FLASH上,需要你的BOOT支持分区,在烧写的时候自动创建BINFS分区和FAT分区,如果不幸的你用的不是EBOOT的话又不能创建BINFS和FAT分区的话就麻烦大了.
系统起来之后可以看到有个BINFS目录和一个NandFlash目录.
step6:
最后一步,修改一下ce.bib的
XIPKERNEL 8C200000 0013F000 RAMIMAGE
CHAIN 8C33F000 00001000 RESERVED
NK 8C340000 00D00000 NANDIMAGE
; RAM 8D040000 02FC0000 RAM
RAM 8C340000 03CC0000 RAM
使RAM的起始地址等于NK的起始地址,这里就是放大了RAM的空间,用命令行方式romimage ce.bib,生成XIPKERNEL.BIN的文件烧到NAND FLASH中去就可以了,有人有问题了发现XIPKERNEL.BIN太小烧不进去,在OEMVerifyMemory()判断里把它判断成了IMAGE_TYPE_RAMIMAGE,所以不写到FLASH了.把这段代码注释掉就好了.
/* comment for fix if the image too small and locate in range,then the image type will change to ram image and cause the image can not write to flash.
// Is it a ram image?
else if ((dwStartAddr >= ROM_RAMIMAGE_START) &&
((dwStartAddr + dwLength - 1) < (ROM_RAMIMAGE_START + ROM_RAMIMAGE_SIZE)))
{
// RETAILMSG(1, (TEXT("Downloading RAM image/r/n")));
g_ImageType = IMAGE_TYPE_RAMIMAGE;
return TRUE;
}
*/
好了,完成,你的程序内存将会是61774K左右.
有疑问吗?我没有提到InitRomChain()函数,实践证明,你不写这个函数,不在OEMInit()里调用它也没有问题.让人感觉是多此一举.