bulat-icon  Articles  

[+]  Articles


Integrating IPSM with WindowsCE .NET 4.x - “A How To”

by Maharajan Veerabahu


The Intel Persistent Storage Manager is the Windows CE file system driver for Intel flashes. Intel provides the driver through local Intel representatives. The driver is in the form of library files and the source code is not easily available. The PSM implementation is possible with these libraries provided by Intel. PLAT_API.c is the only file that is recommended for modification from the Intel Side and ofcourse that’s the only source file given by Intel. But to implement PSM we may have to modify some registry keys and a few OEM files.


The integration of IPSM and making it work has been a painful task (atleast for me) as i was not able to get all the information I used, from one place. The task was to read through a lot of things and sieve the relevent information from the all that was gathered. So the main intention of this article is to make the IPSM integrating easy for others who try it.
This article tells how to integrate PSM for a SA-1110 based board with Intel StrataFlash on it.


The article has been divided into two halves

1. The steps that has to be followed to integrate IPSM from scratch. ,
2. A discussion on the key factors

The steps to be followed to integrate IPSM :


A. Setting up the PSM directory


1. Get the IPSM from Intel. It unzips into a folder called PSM.,

2. Copy the PSM folder to the $(_TARGETPLATROOT)\drivers directory [ $(_TARGETPLATROOT) directory is C:\WINCE400\PLATFORM\econtest1 in my setup]


B. Changing the HAL code

1. Make the following changes in the $(_TARGETPLATROOT)\kernel\hal\OEMIOCTL.c

Add this line,if not present
#include <pkfuncs.h> ,

Add these at the top of initialization


Add this to the OEMIoControl( ) function switch statement.
retval = PSMHAL_IOCtl(nInBufSize, lpInBuf, lpOutBuf);

2. Make the following changes in the $(_TARGETPLATROOT)\kernel\hal\sources


3. Look into $(_TARGETPLATROOT)\Inc\SA11X0BD.INC (or) \Platform\myPlatform\Kernel\Hal\ARM\MAP1100.H and check whether the memory is mapped adn to what address it is mapped.

C Making the PSM FileSystem Settings

1. Change the PSM_OEMInfo structure in the PLAT_API.c to suit your platform.

The contents and an example is given below.
/* PhysicalReadStartAddress */ (VOID_PTR)0x08000000,
/* PhysicalWriteStartAddress */ (VOID_PTR)0x08000000,
/* PhysicalBurstReadStartAddress */ (VOID_PTR)0x08000000,
/* VirtualReadStartAddress */ (VOID_PTR)0xa1000000,
/* VirtualWriteStartAddress */ (VOID_PTR)0xa1000000,
/* VirtualBurstReadStartAddress */ (VOID_PTR)0xa1000000,
/* MaximumArrayLength */ 0x01000000,
/* MaximumRegistrySize */ 0x00000000,
/* ManagedAreaStart */ 0x00000000,
/* ManagedAreaLength */ 0x01000000,
/* ReadBusWidth */ 16,
/* WriteBusWidth */ 16,
/* BurstReadBusWidth */ 16

The Readstartaddress, WriteStartAddress and BurstReadStartAddress ( Both physical and virtual) are the start addresses of the flash array.
MaximumArrayLength is the maximum length of the flash array.
MaximumRegistrySize is the size of the registry backup going to be used
ManagedAreaStart is the start of the PSM area.
ManagedAreaLength will be the length of the PSM file storage and registry storage put together.
The Bus width is the width of the bus connected to the flash.

D. Building the Driver

1. Start the Plaform Builder Environment
2. In the platform created make sure you have the HIVE BASED REGISTRY chosen.
3. Open the build release directory ( from the build menu )
4. Change directory to $(_TARGETPLATROOT)\drivers\PSM\SA11X0\WCE.NET
5. Run the buildpsm.bat from there.

You will get a psmfsd.dll in the $(_TARGETPLATROOT)\drivers\PSM\SA11X0\WCE.NET\bin directory.

E. Making the registry settings. (The tricky part ...)

The registry key changes for WinCE 4.0 and 4.2 have minor differences.

For WinCE 4.0 and WinCE 4.2


"FolderName" = "MYIPSM" ; Folder name of your choice

3. [HKEY_LOCAL_MACHINE\System\StorageManager\AutoLoad\psmfsd]
“Loadflags“=dword:1 ; REQUIRED ONLY FOR WINCE 4.2 ( only difference )

"Start DevMgr"=dword:1

5. Include,
to the driver keys that gets loaded in the boot hive section

F. Final buid

After the modifications you will need to give a clean rebuild. We need to verify whether psmfsd.dll and flshdrv.dll are there in the image. Else you may have to copy them from some subdirectory of $(_TARGETPLATROOT)\drivers\PSM to the release directory and make image to make it part of the image.

With this NK.bin you should be able to get the PSM file storage and the registry backup working fine.

Discussion on the key Factors

What exactly IPSM does or how the filesystem works is all Intel' s Intellectual property.

From the information availble and the changes made we can trace an outline of the IPSM.

Actually Intel's psm driver contains a file manager comes in the form of two libraries namely the psmfsd.lib and psmhal.lib. The psmfsd.lib gets linked along with plat_api.c and gives the psmfsd.dll and psmhal.lib gets linked with the plat_api.c and gets as part of the Hardware Adaptation layer / Board Support Package code.

Once the correct settings are made in the plat_api.c and in the HAL files the PSM file storage will start working. The registry backup is a tricky part.

In the RAM based registry the registry is in the RAM. And it vanishes as soon as the power is switched off. To provide persistent storage to the RAM based registry we need to allocate registry backup space in the Plat_Oem structure.Also we (OEMS ) have to implement the WriteRegistryToOEM and ReadRegistryFromOEM functions. These functions will have to do a low-level write of the registry to the flash and read them back the same way. The WriteRegistryToOEM is called whenever RegFlushKey is called and the storing of the registry is done on the flash. While booting a call to the ReadRegistryFromOEM is made and if it is successful the registry from the flash is loaded.

Thats the backup procedure in the RAM based registry.

In the hive based registry there are two files by name boot.hv and system.hv (name can be changed using the registry settings). When using the hive based registry we have two boot phases. The first boot phase makes use of the boot.hv to bring up the most important components. During the second phase the system.hv is taken from the filesystem and that is used to complete the boot process. To reach the filesystem and get the system.hv you require the PSM driver loaded. The psm driver is loaded based on the regsitry only. So the keys that load PSM have to be in the boot hive section (boot.hv). There are a few other keys that need to be loaded before the system.hv hive is loaded. These are also part of boot.hv.

Whatever that has to go into boot.hv needs to be mentioned between


either in common.reg, platform.reg or project.reg

Care should be taken to decide which keys become part of boot.hv and which become part of system.hv


This setting in the registry flag tells the Device Manager to load the driver in the first boot phase with the boot registry, and not to load it a second time in the second boot phase with the system registry. It prevents the driver from being started twice.

"Start DevMgr"=dword:1

This key tells the booting OS to start the device manager in-order to reach the system.hv ( system hive registry file). The device manager has to be started at this stage because, to take the system.hv file from the filesystem, the necessary drivers need to be loaded and only device manager can do this.


This says that the filesystem may contain a registry.

The boot process:
The booting consists of two phases. Initially the system boots with the boot.hv. In this phase after the Nk.exe, coredll.dll, filesys.exe, fsdmgr.dll, etc. the psm driver psmfsd.dll and the regenum.dll are loaded. Once this is done, the filesystem becomes accessible and the system.hv is taken from the flash.

What happens during the first boot ?
This interesting situation is handled differently. First the flash is examined for proper format. A fresh flash Is not PSM formatted and so PLAT_FormatRecovery is called, a decision on the format and format options is made and formatting is done. This formatting may take some time ( the reason why the boot process might appear to have halted when PSM is enabled for the first time ). There is no system.hv in the filesystem now and so the default system.hv is taken from the NK.bin image and stored in the flash.

PSM as the root File System :
To make IPSM as the root filesystem, the ROM-Only filesystem has to be enabled in the place of RAM/ROM filesystem. And also the mountflags should be


which means the mounted filesystem may contain root and also the system hive. Rest of the settings are similar.
In this case we have windows directory in Rom and the rest are in the IPSM. But unfortunately the program files folder seems to vanish.. Well there is a way to handle this situation and that would be discussed in a following writeup.


More detailed discussion on IPSM is slated to come in future. For more information on Windows CE device drivers, BSP development write to sales@e-consystems.com with subject "Driver/BSP development". e-con Systems has expertise in Product development in windows ce, we also have WEC2013 reference design based on Dm3730 Processor.