You probably know that I've been working on the CEFileWiz application, which (hopefully) makes it easier for you to add files and applications to your Windows CE operating system image.

The CEFileWiz application was originally written to jumpstart Windows CE hands on labs at conferences but turned out to be a useful tool for developing "real" embedded operating system images.

I recently updated CEFileWiz to import a set of folders and files in one click, when testing this today I wanted to include files (images), native, and managed applications - CEFileWiz did its thing, the CEC file was generated and imported into Platform Builder, the operating system built ok, and all of the files and applications were where I expected them to be... apart from the eMbedded Visual C++ 4.0 SP4 Win32 C++ "Hello World" application, this application wasn't mapped to its destination folder, and when I ran the application from the "\Windows" folder I got an error "This is not a valid Windows CE application".

Huh ? - I've developed a TON of applications for Windows CE and run them on target devices, perhaps I've made a mistake in the CEC/BIB file generation in CEFileWiz... a quick check and everything looks perfect - so it's time to put on the debugger hat and figure out what's going on under the hood.

I built a debug image of the operating system, and also copied my eVCApp.exe to MyEvcApp.exe in the _FLATRELEASEDIR (build output folder) - now it's time to try two things...

  1. Try running the MyEvcApp.exe from the Target | Run menu in Platform Builder (to see if the application runs outside of the O/S image) and
  2. Look at the debug messages from Platform Builder when launching the application from the o/s image.

Step 1 - run the application from the build release folder - note that this is *exactly* the same binary that I've already included in the operating system image, no changes apart from renaming the binary - Interestingly the application ran without any problems - Interesting, huh...

Step 2 - run the application from the O/S image and take a look at the debug messages from Platform Builder  - here's the error message...

3990320 PID:43d221fa TID:43d2af9a 0x83cff0a8: Paging in from uncompressed R/O page from XIP module -- should've never happened

Should've never happened... hmm... perhaps it didn't happen, let's try again... exactly the same results... on both attempts Platform Builder hit the appropriate breakpoint in the Windows CE Shared source - hmm... even more interesting, right ?

So, what's going on ? - and... perhaps an even more interesting question, why haven't I seen this error before... It turns out that all of my eVC applications have been downloaded onto a target and not included directly into the embedded image.

Q: When you are writing applications for your Windows CE "Embedded" device, what tools do you use ? Platform Builder, eMbedded Visual C++, or Visual Studio 2003/2005 ?

It turns out that the eVC 4.0 linker put imports of an executable in a read-only section, the applicaiton loader while doing imports needs to write to the page, but since it’s in ROM, we can’t write to it, and therefore loading the application fails - a quick workaround to this issue is to drop the eVC 4.0 application into the FILES section rather than the MODULES section (has anyone seen this before?).

Adding an application using the Platform Builder "New Project" wizard works perfectly.  There's obviously a difference between the compiler/linker flags used by Platform Builder to build an application and eMbedded Visual C++ 4.0, once I've figured out the difference I will post a comment.

- Mike