|
|
Booting Windows CE from a hard drive through PC BIOS
2006-06-22
IntroductionThis article explains the build process for the Windows CE BIOS bootloader and is derived from build instructions developed by engineers at e-con Systems together with a collection of postings on the MSDN Embedded newsgroups. It is intended for embedded engineers who are involved in the development of Windows CE using CEPC on PCs, or on other PC-compliant platforms that have a...
standard PC BIOS and hard disk. The Windows CE image (NK.BIN) is loaded by the BIOS directly from the hard disk, without any user intervention, in a process similar to the way a normal PC BIOS loads the OS from hard disk. This BIOS boot loader component is responsible for loading the Windows CE OS from the OS partition on the hard disk into RAM, and passing control to it. Scope This article is limited to the steps involved in the building of the BIOS bootloader and the modifications done in the existing source code provided by Microsoft. The BIOS boot loader code is a standard x86 boot code and the changes made are very specific to the buffer size. Build Environment The build environment is Windows CE 5.0 Platform Builder. We have used both a normal PC as a CEPC platform and an x86-based PC-compliant target board from ICOP. The build instructions have been tested on both platforms. Building the BIOS Bootloader (BLDR)
It is necessary to create a setup diskette that contains all the necessary components to make a hard disk partition bootable. Before creating the setup diskette, the handler for ".144" files must be registered through the following one-time-only operation:
The setup diskette contains a file called boot.ini that specifies a number of important parameters. Edit this file as follows:
After running mkdisk, copy the boot.ini (that was edited above), splash.bmx and eboot.bix files from the setup diskette to C: nk.bin The final problem is to get an appropriate Windows CE image, nk.bin, onto the hard disk. This nk.bin will be placed in the boot partition to be loaded by BLDR. It should be a thoroughly tested release version with no debugging support. To make this, go to Platform->Settings menu on the Windows CE Platform Builder (with your platform workspace loaded). Go to the Build Options tab and uncheck all the check boxes. Build the image, which is a release version of nk.bin. This nk.bin must somehow be copied to the boot partition on C:. Here's how we do it:
At power-on, the BIOS loads the master boot record into RAM at 0000:7C00 (Real mode) and jumps to it. Typical MBR code reads the available operating systems and displays them to the user. It then loads the corresponding loader for the OS that the user selects. This is known as a "two-stage bootloader," an example being GRUB. In our case, the MBR code simply looks for BLDR, loads it into RAM, and passes control to it. There is no interaction with the user, the boot code just displays the string "Microsoft Windows CE BIOS Bootloader" on the screen. If BLDR is not found, it displays the error message "Unable to load BLDR!" Next, BLDR takes over and configures the screen, initiates the OS loading process, and configures the debug serial port. It then locates and loads nk.bin and gives the control to it. This finally brings up the Windows CE desktop, and we're done. Troubleshooting the BIOS loader If the loader is not able to load the OS, or configure the display, for example, it will output appropriate error messages on serial port COM1. COM1 is configured for 38.4 kbaud, 8 data bits, 1 stop bit, no parity and no flow control. The loader outputs error, warning, and info codes only unless it is built in debug mode with FULLMESSAGES defined. The full text corresponding to the error codes is found in the file debug.h located at WINCE500\PUBLIC\COMMON\OAK\CSP\X86\BIOSLOADER\LOADER. When FULLMESSAGES is defined the text in debug.h is built into the loader binary. If the loader reports that it can't load the bootloader it may be useful to format the partition again to be sure the BLDR file is stored on contiguous sectors. Also note that the loader size is fixed and defined by the symbol READ_LENGTH. If you add code to the loader it may be necessary to update this setting. A search of groups.google.com using the error message can often yield helpful hints. The next step is to have a custom boot logo and our own boot progress bar. Do you have questions or comments on this article? talkback here Ashok Babu is the Program Manager at e-con Systems in Chennai, India. His software specialities include developing Windows device drivers and designing Video codecs, and he also has hands-on experience in both Windows CE and Windows Mobile. He holds a Bachelor of Engineering, and his hobbies include music, soccer, and debugging. You can reach him by email, at "ashok at e-consystems dot com."
|