Windows CE 5.0 mult-xip bin模式实现
时间:10-02
整理:3721RD
点击:
Windows CE 5.0 mult-xip bin模式实现 (已完全开放) 管理提醒: (? ? (? 描述:图一
图片:
描述:图二
图片:
Windows CE 5.0 mult-xip bin模式实现
XIP是什么,微软说:
Execute-in-place (XIP) regions are areas where an application can execute code directly from ROM rather than loading it from RAM. Windows CE allows you to construct multiple XIP regions in a single system. There are several reasons for using multiple XIP regions instead of a single region:
? You can break applications into functional subsets and install them separately from the core of the operating system (OS).
? You do not need to replace the whole run-time image to add new features.
? You do not need to replace the whole run-time image to fix a bug.
? The user can update the run-time image.
? Updates to the run-time images are permanent and not vulnerable to cold resets.
The growing popularity of flash memory as a replacement for masked ROM is one of the technologies that enables multiple XIP regions. In the Help topics that discuss multiple XIP regions, ROM refers to the flash memory where the system image resides.
Multiple XIP regions divide the ROM image into discrete, upgradeable units. As you decide how to divide the XIP image, consider the owner of the modules and files in the region and the functionality of the modules and files in that region.
Note XIP cannot span across physically discontiguous regions. Although virtually contiguous, some devices can hang when executed in place on code across physical regions. Also, uncompressed FILE and MODULE across regions can be direct mapped or accessed directly without copying, but the kernel only handles the case where the file is physically contiguous.
不懂英语的兄弟,吃亏了吧,赶紧对照看吧。
其实,XIP BIN也不是很新鲜的技术,在很多OS里都有用到。比如LINUX下,很多高手早就掌握了。在Windows CE下也有不少人在使用,大多都依赖于Nor Flash,因为前期都是才用Nor Flash来做BOOT的嘛。直到最近,大家开始慢慢摒弃Nor Flash,开始精简硬件,降低成本,越来越多的方案都才用Nand Flash来做为BOOT。由此的转变,使得XIP要使用在Nand Flash上有了一定的不可能。
从某种角度来说是不可能,但是咱们程序员讲的就是化腐朽为神奇,把不可能变成可能。所以越来越多的同志来投身XIP的研究中。其中高手当然是云集拉。比如: zhengshijie,harktrip,simula,wenzai,oxox等等高手,在论坛里积极发表个人建议,对我们这些后来的兄弟积极解答,真的帮助很大。
现在大概讲讲我的实现办法。
先给出我的实现效果图:(注:我的内存大小是64M)
图一
图二
图三
看了流口水了吧,那赶紧来跟我一起做。
第一、 搭建工程。该选的组件一个也别落下。
第二、 添加HIVE支持,这个部分可以参考:
http://www.armsystem.com.cn/article/ARM9-article/example/20061232117590.html
(wenzai友情提供链接)
第三、 在setting里 设置环境变量中,加上IMGMULTIBIN = 1,这个是对XIP BIN的支持,一定要加上。
第四、 对config.bib文件进行修改:
大体设置如下:
MEMORY
pdwXIPLoc 00000000 803FF000 FIXUPVAR
XIPKERNEL 80200000 001FF000 RAMIMAGE
CHAIN 803FF000 00001000 RESERVED
NK 80400000 01E00000 NANDIMAGE
RAM 80400000 07C00000 RAM
FLASH 92000000 00100000 RESERVED
CONFIG
AUTOSIZE=ON
COMPRESSION=ON
DLLADDR_AUTOSIZE=ON
KERNELFIXUPS=ON
PROFILE=OFF
RAM_AUTOSIZE=OFF
ROMFLAGS=0
;ROMSIZE=01E00000
;ROMSTART=800B8000
;ROMWIDTH=32
ROM_AUTOSIZE=OFF
XIPSCHAIN=803FF000
(感谢simula 提供参数配置)
第五、 对XIPKERNEL进行规划,将最小化系统内核打包到其中。
系统必须加载组件为:
MODULES
; Name Path Memory Type
; -------------- --------------------------------------------- -----------
nk.exe D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\kern.exe XIPKERNEL SH
coredll.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\coredll.dll XIPKERNEL SH
filesys.exe D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\filesys.exe XIPKERNEL SH
fatfsd.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\fatfsd.dll XIPKERNEL SH
diskcache.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\diskcache.dll XIPKERNEL SH
fatutil.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\fatutil.dll XIPKERNEL SH
binfs.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\binfs.dll XIPKERNEL SH
fsdmgr.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\fsdmgr.dll XIPKERNEL SH
mspart.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\mspart.dll XIPKERNEL SH
ceddk.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\ceddk.dll XIPKERNEL SH
smflash.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\smflash.dll XIPKERNEL SH
FILES
boot.hv D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\boot.hv XIPKERNEL SH
default.hv D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\default.hv XIPKERNEL SH
user.hv D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\user.hv XIPKERNEL SH
(感谢zhengshijie提供XIPKERNEL资料)
第六、 设置完这些后,剩下的工作就是在platform.reg中添加一个BINFS的分区了。我的设置为:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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"
; 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
记住,此注册信息必须包含在
; HIVE BOOT SECTION
; END HIVE BOOT SECTION
中,这样才能讲BINFS的信息打包到boot.hv中,不然,那你的XIP实现就比较郁闷了。(本人因此郁闷了3天,比较菜)
大概设置完毕,大家可以开始XIP之旅了。
以下是大虾对此补充,
zhengshijie:
我也总结了一下,对比一下看看.
第三、 在setting里 设置环境变量中,加上IMGMULTIBIN = 1,这个是对XIP BIN的支持,一定要加上。
这一步可以不要了,你是受帮助文档的影响,那是因为它是针对CEPC的配置来说的,因为CEPC的配置里config.bib有判断这个量.
对于我们的config.bib根本不作这个判断,所以就不需要了.生不生成XIP.BIN是看你的MEMORY是否有一个以上的IMAGE,CHAIN的声明.
关于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.
zhengshijie:
还有一点实践表明内核子集最小文件包含还可以再去掉3个,实践得知之前强调的必须调用InitRomChain()实际上是可以去掉的,不用在OEMIinit()里调用这个函数了.
下面这些文件是必需的:
"nk.exe",
"coredll.dll",
"filesys.exe",
"fatfsd.dll",
"diskcache.dll",
"fatutil.dll",
"binfs.dll",
"fsdmgr.dll",
"mspart.dll",
"smflash.dll",
"boot.hv",
图片:
描述:图二
图片:
Windows CE 5.0 mult-xip bin模式实现
XIP是什么,微软说:
Execute-in-place (XIP) regions are areas where an application can execute code directly from ROM rather than loading it from RAM. Windows CE allows you to construct multiple XIP regions in a single system. There are several reasons for using multiple XIP regions instead of a single region:
? You can break applications into functional subsets and install them separately from the core of the operating system (OS).
? You do not need to replace the whole run-time image to add new features.
? You do not need to replace the whole run-time image to fix a bug.
? The user can update the run-time image.
? Updates to the run-time images are permanent and not vulnerable to cold resets.
The growing popularity of flash memory as a replacement for masked ROM is one of the technologies that enables multiple XIP regions. In the Help topics that discuss multiple XIP regions, ROM refers to the flash memory where the system image resides.
Multiple XIP regions divide the ROM image into discrete, upgradeable units. As you decide how to divide the XIP image, consider the owner of the modules and files in the region and the functionality of the modules and files in that region.
Note XIP cannot span across physically discontiguous regions. Although virtually contiguous, some devices can hang when executed in place on code across physical regions. Also, uncompressed FILE and MODULE across regions can be direct mapped or accessed directly without copying, but the kernel only handles the case where the file is physically contiguous.
不懂英语的兄弟,吃亏了吧,赶紧对照看吧。
其实,XIP BIN也不是很新鲜的技术,在很多OS里都有用到。比如LINUX下,很多高手早就掌握了。在Windows CE下也有不少人在使用,大多都依赖于Nor Flash,因为前期都是才用Nor Flash来做BOOT的嘛。直到最近,大家开始慢慢摒弃Nor Flash,开始精简硬件,降低成本,越来越多的方案都才用Nand Flash来做为BOOT。由此的转变,使得XIP要使用在Nand Flash上有了一定的不可能。
从某种角度来说是不可能,但是咱们程序员讲的就是化腐朽为神奇,把不可能变成可能。所以越来越多的同志来投身XIP的研究中。其中高手当然是云集拉。比如: zhengshijie,harktrip,simula,wenzai,oxox等等高手,在论坛里积极发表个人建议,对我们这些后来的兄弟积极解答,真的帮助很大。
现在大概讲讲我的实现办法。
先给出我的实现效果图:(注:我的内存大小是64M)
图一
图二
图三
看了流口水了吧,那赶紧来跟我一起做。
第一、 搭建工程。该选的组件一个也别落下。
第二、 添加HIVE支持,这个部分可以参考:
http://www.armsystem.com.cn/article/ARM9-article/example/20061232117590.html
(wenzai友情提供链接)
第三、 在setting里 设置环境变量中,加上IMGMULTIBIN = 1,这个是对XIP BIN的支持,一定要加上。
第四、 对config.bib文件进行修改:
大体设置如下:
MEMORY
pdwXIPLoc 00000000 803FF000 FIXUPVAR
XIPKERNEL 80200000 001FF000 RAMIMAGE
CHAIN 803FF000 00001000 RESERVED
NK 80400000 01E00000 NANDIMAGE
RAM 80400000 07C00000 RAM
FLASH 92000000 00100000 RESERVED
CONFIG
AUTOSIZE=ON
COMPRESSION=ON
DLLADDR_AUTOSIZE=ON
KERNELFIXUPS=ON
PROFILE=OFF
RAM_AUTOSIZE=OFF
ROMFLAGS=0
;ROMSIZE=01E00000
;ROMSTART=800B8000
;ROMWIDTH=32
ROM_AUTOSIZE=OFF
XIPSCHAIN=803FF000
(感谢simula 提供参数配置)
第五、 对XIPKERNEL进行规划,将最小化系统内核打包到其中。
系统必须加载组件为:
MODULES
; Name Path Memory Type
; -------------- --------------------------------------------- -----------
nk.exe D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\kern.exe XIPKERNEL SH
coredll.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\coredll.dll XIPKERNEL SH
filesys.exe D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\filesys.exe XIPKERNEL SH
fatfsd.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\fatfsd.dll XIPKERNEL SH
diskcache.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\diskcache.dll XIPKERNEL SH
fatutil.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\fatutil.dll XIPKERNEL SH
binfs.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\binfs.dll XIPKERNEL SH
fsdmgr.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\fsdmgr.dll XIPKERNEL SH
mspart.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\mspart.dll XIPKERNEL SH
ceddk.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\ceddk.dll XIPKERNEL SH
smflash.dll D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\smflash.dll XIPKERNEL SH
FILES
boot.hv D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\boot.hv XIPKERNEL SH
default.hv D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\default.hv XIPKERNEL SH
user.hv D:\WINCE500\PBWorkspaces\SMDK2440\RelDir\SMDK2440_ARMV4I_Release\user.hv XIPKERNEL SH
(感谢zhengshijie提供XIPKERNEL资料)
第六、 设置完这些后,剩下的工作就是在platform.reg中添加一个BINFS的分区了。我的设置为:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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"
; 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
记住,此注册信息必须包含在
; HIVE BOOT SECTION
; END HIVE BOOT SECTION
中,这样才能讲BINFS的信息打包到boot.hv中,不然,那你的XIP实现就比较郁闷了。(本人因此郁闷了3天,比较菜)
大概设置完毕,大家可以开始XIP之旅了。
以下是大虾对此补充,
zhengshijie:
我也总结了一下,对比一下看看.
第三、 在setting里 设置环境变量中,加上IMGMULTIBIN = 1,这个是对XIP BIN的支持,一定要加上。
这一步可以不要了,你是受帮助文档的影响,那是因为它是针对CEPC的配置来说的,因为CEPC的配置里config.bib有判断这个量.
对于我们的config.bib根本不作这个判断,所以就不需要了.生不生成XIP.BIN是看你的MEMORY是否有一个以上的IMAGE,CHAIN的声明.
关于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.
zhengshijie:
还有一点实践表明内核子集最小文件包含还可以再去掉3个,实践得知之前强调的必须调用InitRomChain()实际上是可以去掉的,不用在OEMIinit()里调用这个函数了.
下面这些文件是必需的:
"nk.exe",
"coredll.dll",
"filesys.exe",
"fatfsd.dll",
"diskcache.dll",
"fatutil.dll",
"binfs.dll",
"fsdmgr.dll",
"mspart.dll",
"smflash.dll",
"boot.hv",