Windows CE 5.0 mult-xip bin模式實現

來源:互聯網
上載者:User
描述:圖一
圖片:

描述:圖二
圖片:
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",
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.