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()裡調用它也沒有問題.讓人感覺是多此一舉.