Monday, January 14, 2008

Automatically add files to an SDK

When building an SDK using Platform Builder 6.0 (and previous), you may need to include your own files. Those files are the list of IOcontrols of drivers you implemented, or header files required to link to a new library that you want to provide in your SDK. In that case you have to include those files to your SDKs.
The first one is a manual inclusion of those files using the configuration wizard of the SDK. That’s mean that every time you generates the SDK you have to take care of those files.
The second solution is to automated this mechanism by copying those files to a specific folder that will be used automatically by the wizard during the generation of the SDK.

Identification of the sdk folder :
The SDK tool uses the content of the cesysgen folder (located in your OSDesign folder), and the sdk folder located in the same folder as the cesysgen and OAK folder.
$(_PROJECTROOT)\sdk or $(_PROJECTSDKROOT)
The SDK tool adds the content of the sdk\Inc and sdk\Lib folder to the SDK msi file. So you must store the files you need to provide with the SDK in those sub folders. Doing it manually is never the solution, so by asking the Windows embedded CE build environment to do it, it is more reliable. This could be done during the build of those libraries or drivers.

Add an automated task :
Using the sources files you can add dependencies and enable automated task for the build engine. You could also use the postlink macro, but this is not the purpose of this article.
In the sources file add the following lines :
#------------------------------------------------------------------------------
# SDK files
#------------------------------------------------------------------------------
# Enable copy to the SDK directory
WINCETARGETFILES=$(WINCETARGETFILES) CopyFilesToSDK
SDK_FILES=gpio_iocontrol.h driverheadertoshare.h

Any target files that you specify using WINCETARGETFILES are added to the list of dependencies that must be satisfied to generate a successful build. Also by listing the files you need for your SDK in the SDK_ FILES variable, you will generate a list actions that will be solved later in the makefile.inc.
In association to the sources file you must provide a makefile.inc (located in the same folder), this file is proceeded after your sources files during the build. In this file you must satisfy the dependency list, so it must contain information about the CopyFilesToSDK.

Makefile.inc content will be something like this :
CopyFilesToSDK:
#REM copy the files listed in SDK_FILES to $(_PROJECTSDKROOT)
....
The copy will be done in batch script language and executed by the build engine.
After the build of the driver or the library, you may find all your required files in the $(_PROJECTSDKROOT) folder.
In this article I described only one list of files to be proceeded, but it make sense to have two lists, one for the header files and the sdk\Inc folder and another one for the sdk\Lib folder for the libraries.

-Nicolas

Thursday, January 3, 2008

Happy New Year

I wish you an Happy New Year 2008.

For this new year, I'm glad to announce that I have been awarded as Windows Embedded MVP for the second time. So thanks to the Mike Fosmire and the MVP team for this award.

- Nicolas

Friday, December 28, 2007

Enable Remote Display Application - CERDisp

The "Remote Display Application" or CERDisp is a Windows CE functionality that gives you the possibility to see remotely the content of the Frame Buffer of your device, and to interact with it through the mouse and keyboard. This tool is composed of two part, a client and a server.

The server :
CERHost is the host part of this tool, and must be launched on your computer before the client. This tools will wait for client connections.
The application can be found in the following folder :
C:\WINCE600\PUBLIC\COMMON\OAK\BIN\I386



The Client :
CERDisp is the Windows CE client and must be integrated inside your Windows CE binary image, by selecting the "Remote Display Application" component in your OSDesign. The client will connect to a dedicated server, for which the settings are stored in the registry. Add the following registry settings to your Project.reg file to setup CERDisp.
[HKEY_LOCAL_MACHINE\SOFTWARE\CERDISP]
"Hostname"="nameoftheserver"

The Hostname is the name or the IP address of the server. Use ppp_peer the as Hostname if you want ot use CERDisp throught an ActiveSync connection.

Tip to use this tool :
As you have to launch CERDisp on your device, you need an access to your device through a command prompt. That's why in that case I suggest you to enable a Telnet server to have a network access to your device and be able to launch the client.
[HKEY_LOCAL_MACHINE\COMM\TELNETD]
"IsEnabled "=dword:1
"UseAuthentication"=dword:0
The above settings are enabling the telnet server and removing the authentication. So you may have network security risk to use those settings AS IS on your device.

Launch CERDisp :
Before launching CERDisp, you have to launch CERHost on your computer. To launch CERDisp you have to use the following command line :
Cerdisp –c
The -c parameter is used to specify that the application have to connect.


Note : Do not store any registry settings about the host if you do not have a specific dedicated host. You may be able to select your device in a list under CERHost (File -> Connect).

- Nicolas

Thursday, December 20, 2007

Error while opening pbxml file

If you have the following error while opening a Windows Embedded CE 6.0 OSdesign, that means that in the path to this OSDesign there is a space character.

Platform Builder reported an error while trying to load the OS design file:
System.ArgumentException: Invalid characters in path.
The OS design could not be loaded.

The solution is to remove this or those space characters from the path to your OSDesign files, by simply removing the space or replacing the space by an underscore (_). Usually OSDesign files are located inside the OSDesign subfolder of the WINCE600 folder. By default the WINCE600 is located at the root on the C hard drive.

Do not move your OSDesign to your desktop, as this one is located in C:\Documents and Settings\user name\Desktop, and this path contains a space !!


- Nicolas

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

Thursday, December 13, 2007

VS2005 and square selection

To make a square selection under Visual Studio 2005, use the Alt key and your mouse.


- Nicolas

How does Windows Embedded CE 6.0 starts ?

Kurt Kennett, Senior Development Lead wrote a very interesting article on the early steps of the start of the Windows CE Kernel.

Article : How does Windows Embedded CE 6.0 starts

- Nicolas