Wednesday, December 19, 2007

Enable ROM-only File System under Windows CE 6.0 (R2)

The Windows Embedded CE 6.0 (R2) operating system mounts a File System at startup. By default, this File System is located in RAM and the content is the ROM (content of the nk.bin), this is the RAM and ROM File System. This FS is represented by a backslash (“\”). Additional File Systems can be mounted on the system (external storage) and will be accessible through subfolders of the root (\Hard Drive,…). The inconvenience with this configuration is that your persistent files must be located inside this subfolder, but you may want to be able to store those persistent files directly at the root of the main File System. In that case you have to enable the ROM-only File System.

To be able to mount the storage device as a root folder we have some prerequisites to check.

Mount the storage device in boot Phase 1
The system is booting in different step, and drivers are usually loaded during the last boot step. To mount this storage area as root folder, you must load your storage device driver in the early steps of the boot. So Device Manager must be loaded first and then your block driver.

Start the Device Manager
The device manager must be start at this Phase in order to be able to load the storage driver.
[HKEY_LOCAL_MACHINE\init\BootVars]
"Start DevMgr"=dword:1


Set the block driver to be loaded at this Phase of the boot.
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\]
"Profile"="FlashDisk"

"Flags"=dword:1000


You can notice in the registry setting above that we are associating this Storage driver to a Storage Manager profile using the Profile key. This profile will be used later to define the settings for this storage device (File System type, auto format, …). Flags key is used to specify to the device manager when the driver must be loaded.

Set the storage profile
Once the storage driver definition is done we have to specify to the Storage Manager how to use this storage space :
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FlashDisk]
"AutoMount"=dword:1
"AutoPart"=dword:1
"AutoFormat"=dword:1
"PartitionDriver"="mspart.dll"
"MountAsBootable"=dword:1
"Name"="NANDFLASH"
"Folder"="NandFlash"
"DefaultFileSystem"="FATFS"

For this storage (FlashDisk) we are enabling the FATFS file system, the content will be automatically formatted (AutoFormat) and partition will be created if the storage is blank (AutoPart). But one of the most important parameters is the MountAsBootable parameter, that will allow the system to access this storage during the boot.

To complete the configuration of the device we need to set the File System properties to finally make this Storage Device as Root.
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FlashDisk\FATFS]
"MountAsRoot"=dword:1
"MountAsBootable"=dword:1
"MountPermanent"=dword:1


Enable the ROM-only File System
At this step we are ready to select the ROM-only File System from the catalog to turn on this feature. After selecting this component you have to do a Clean Sysgen to fully enable the feature in your Windows CE binary image.
Note : You must include the file system replication filter in your OS design for ActiveSync to work correctly when you are mounting a file system as the root directory.

Erase the Storage content
Before booting the device for the first time, the content of the storage device must be completely erased (most of the bootloaders provide a menu to clean up your storage device).
After booting all the files that you will store under \ will be accessible on the next boot.

Final note
To clean up the registry file and to insert those settings only when the ROM-Only File System option is selected in your OSDesign, you can use IF statement with the SYSGEN_FSROMONLY variable.

- Nicolas

8 comments:

Anonymous said...

Hi,

It's a very interesting thing for WinCE 6.0n but what about CE 5.0, I'm quite new to this but I guess the problem is the same in WinCE 5.0 isn't it?

vicky said...

Thank yo Nicolas....

I was struggling with this ROM only File system with out putting all these settings....

My OS was building but was not booting on the target device(i.MX31 ADS)...

Thank you very much

Anonymous said...

Hi Nicolas

I worked enabling Rom-Only File System, but i got stopped in the step: "including the file system replication filter". maybe you should give us more explanation about this.

Thank you very much

Nicolas BESSON said...

The file system replication filter is a component of the Windows CE catalog. Just check it in the list and you have it in your runtime image.
Enjoy !
Nicolas

Anonymous said...

Maybe a dumb question but where could i enable "ROM-only File System" in the catalog?

Nicolas BESSON said...

Select the component from the catalog, perofrm a clean sysgen, and upload the runtime image on the target.

Anonymous said...

Dear Nicolas

I don't have File System Replication Filter.

Can you please give me the catalog item corresponding to it?

Merci

Nicolas BESSON [MVP] said...

To enable the file system replication filter, then add SYSGEN_FSREPLXFILT variable to your OSdesign configuration.