Diskprep.exe is a useful tool for making a bootable USB Disk with an OS but recently it seems to have disappeared from Microsoft’s downloads. I can’t say if it’s another one of those subtle hints on the future of Windows CE, an oversight due to the lack of resources dedicated to Windows CE, or just a simple mistake that will get corrected shortly. Regardless of the cause, there are people who still find the tool useful, so I’m providing a download mirror of the tool here.
A new customer came to me late last week with an interesting problem. They have hundreds of Motorola/Symbol MC70 barcode scanners in the field and occasionally the flash memory on the devices gets corrupted.
The current “solution” these guys are using involves removing the flash chips from the board, reprogramming it in a separate device, re-balling the BGA pins, and re-soldering it to the board. That explains why they desperately want an application that can do it.
They know the range where the corruption occurs and wanted an application that would allow a user to read, update and rewrite the corrupted bytes in flash. They had talked with five separate developers before they found me, and all 5 had agreed that it was impossible, so naturally I took that as a challenge.
First, there are lots of things to know about how flash access works. Most importantly, it’s not like RAM. You can’t just map to it, then go about your merry way doing 32-bit reads and writes. You can read it that way, sure, but writing is a whole new game. Flash is broken up into “blocks” (which aren’t even always the same size – in the case of the MC70, the first 4 blocks are 64k long, and the rest are 256k long.) and writes must be done following this general procedure:
- Read the *entire* block that contains the byte you want to change into RAM
- Change to flash to Lock mode (a flash register write)
- Unlock the block of flash (another register write)
- Change the flash to erase mode (register write)
- Erase the *entire* block of flash (which writes all FF’s to it)
- Change the flash to write mode (register write)
- Update the RAM buffer with your changes
- Write in the *entire* block block to flash
- Tell the flash to commit (register write)
- Wait for the flash to finish (register read)
- Put the flash back into read mode (register write)
Oh, and if you get any of this wrong, you’ve made yourself an expensive brick. The only solution at that point is the de-soldering and reprogramming route, and I don’t have that kind of hardware in my office.
So I started writing the app Monday morning, using C# since I had to create a UI for the editor, and on Wednesday morning this is what I delivered:
So, in just 2 days I did what was “impossible”. I not only wrote all of the flash access code, I also wrote a hex editor control and an app UI to make use of the flash library.
Yes, VS 2012 will support CE development, including Compact Framework 3.9. Support is scheduled to be released in Q1 of next year. See this video for more details.
Occasionally I’m surprised at how old software never seems to really die off. Take for example an old port I did of the zlib compression library to Windows CE. Back in probably ’05 I built the original sources for the Windows CE platform. In ’07 I created a managed wrapper for the library and some samples on how to use that library. I put it on the web and then pretty much forgot about it.
Well when we migrated our web site to a new server, some old links died and this just happened to be one of them (if you know of others, please let me know) and today I got an email from someone asking if I still had the code. Sure, it wasn’t the day things went down, but it still means not only was someone looking for it, the cared enough to email me and ask.
For those looking for it, it’s got a new, hoipefully more permanent home on Codeplex: http://zlibce.codeplex.com
There has been rampant speculation for some time that Windows CE was dead and that Microsoft was abandoning it. The announcement that Windows 8 will run on ARM only added fuel to it, despite the fact that Win8 is undoubtedly going to have a large, desktop-style footprint and no capability for real-time operation. Well, Microsoft finally decided to tell us what many of us suspected for some time. Windows Embedded Compact (i.e. Windows CE) is still on their product roadmap. It will have a v Next, and it will be supported in newer versions of Visual Studio (well native development will be anyway). Read the full press release here.
Earlier today I published a tool for creating CE splash images. Well I already hit a limitation, so I’ve updated the tool. It now supports all common image formats (PNG, JPG, GIF and BMP) instead of just BMP. BIOSLoader also limits your image to 64k – anything larger might actually hand the device. The tool now detects when the result will be larger than 64k and will offer to resize it before compressing as well.
The latest binary and source are up in Codeplex.
If you’re booting an OS on a device that supports the BIOSLoader, an option is to display a “splash screen” image while the OS loads from disk. The file is, by default, called ‘splash.bmx’, which is expected to be a compressed binary file, *not* an image. The compressed binary file can be generated from a bitmap using bincompress.exe (which ships with Platform Builder).
While that seems all well and good, there are also some other limitations. For example the source bitmap (pre compression) must be 256-color, and I believe there is likely a maximum file size as well (I’m sure the loader allocates a static block of RAM to hold the image). Well my image editor of choice (Paint.NET) doesn’t have a simple mechanism to save as a 256-color bitmap, not all of my PCs have Platform Builder (and thereforebincompress) installed, and I’m a fan of simplifying multistep processes in general.
So I created a very simply Windows app that you use to browse to an image, then click a button and it converts it to 256-color and generates the splash.bmx file for you. It was just a couple hours of playing around, so it’s not overly robust (it could probably use a command-line interface for automation, and a “preview” of the conversion would be nice) but it’s functional for what I needed to get done this week. Here’s what it looks like:
I’ve published the work (source and binary) up on Codeplex.