The question came up again about how to quickly test an application or driver using Platform Builder and KITL. This article will show how this test cycle can be done quickly without building a new OS and downloading it.
Of course Platform Builder is a tool for developing an operating system, so if you use its default behavior it will build an operating system. So that means that a small change to source code means building the operating system and deploying it to your device. But we will look at how we can do things a little differently and speed up the process. 
The basic steps are:
1.       Add KITL support
2.       Add Target Control Support (Shell.exe)
3.       Leave your app out of the OS, but leave in the registry settings
4.       Build your OS
5.       Start the OS and connect KITL
6.       When your run the app, it will load over your KITL connection
7.       Update your app
8.       Build your app
9.       Repeat starting at step 6
For this article I am not going to show you everything, but I will describe what I did to write an application and test it using KITL without rebuilding the OS. I am writing this while sitting in an airport, so I am using the emulator but these techniques work just as well with a real device, maybe better.
I started by creating a new project, not that this is important but I didn’t have one to work with. I wanted to keep it simple so I chose the Emulator BSP and the Thin Client template. I left out anything that I didn’t need for this article, like the .NET CompactFramework. I double checked that KITL was enabled and that Target Control Support was included. Target Control Support is important to this because it adds support for the \Release folder which links back to the _FLATRELEASEDIR on the development PC. I change the shell from the Thin Client shell to the standard shell, honestly I am not familiar with the Thin Client shell and felt more comfortable with the standard shell for a quick test.
Next I added a subproject. I am adding it now, before building the OS, so that it more closely simulates a real world project. The project is a WCE Application and I selected a simple Hello World template. This template doesn’t provide a menu with an option to Exit, so using code from Windows CE: Setting an Application to Display Full Screen in C/C++ I added an exit button. Being able to exit the application being tested will be very important for speeding up the test cycle.
We are almost ready to build and test, but first, and this is important for speeding up the test cycle, remove the subproject application from the OS image.   If you are testing a driver, the same thing applies. There are a couple of ways to remove the application from the image:
1.       In the OSDesign Properties, select Configuration Properties\Subproject Image Settings. Double click on the subproject that you are working on, and then select Exclude from Image.
 
 


It took me a long time to find this property. In prior versions of Platform Builder it was much easier to exclude a file from the OS. For that reason, my first test I used option 2.
2.       Comment out the file in the bib file.
It is finally time to build the OS and run the first test. For this, run Sysgen and attach to the device.
Once the OS is running, you can start your application by using Start\Run. Looking at the debug output you will see that the application was loaded by RelFSD, which is the \Release folder.
That means that the application was downloaded from your _FLATRELEASEDIR and was not in the OS image. If it isn’t in the OS image, which means that we can change it without changing the OS image, or for that matter restarting the device and downloading the image. The application looks like this when I run it:
The next step is to modify the application. In this case, I want to app to say “The App is running” instead of “Hello World!” So I changed the string table to modify the string that is displayed.  I also fixed the location of the button so that it doesn't sit on top of the text.
Now we need to build the application, not the whole OS. I am a command line kind of engineer, so I would open a build window, change directories to the subproject folder and run build. If you like to use Visual Studio, then start by unchecking Build\Targeted Build Settings\Make Run-Time Image After Build, which is important because we don’t need to make the run-time image and the process takes considerable time.   Now you can right click on your subproject in the Solution Explorer and select Build (for this to work well, set the environment variable WINCEREL to 1).
Finally, run the application again, now it looks like:
To use this same technique to test a stream interface driver, leave the driver and its registry settings out of the OS. Then call ActivateDevice() and DeactivateDevice() from your application as shown in Windows CE: Loading a Driver with ActivateDeviceEx.
 
Copyright © 2010 – Bruce Eitman
All Rights Reserved