Click here to learn
about this Sponsor:
Home  |  News  |  Articles  |  Polls  |  Forum  |  Directory

Keywords: Match:
Booting Windows CE from a hard drive through PC BIOS
by K. Ashok Babu (Updated Jul. 3, 2006)

Introduction

This 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)
  • Start the Windows CE 5.0 Command Prompt

  • Go to Public\common\oak\misc

  • Run the WinCE.bat file with the target cpu type, project name and platform name:

      wince.bat x86 cepctest CEPC

    Note that the arguments are case sensitive. This sets up the environment variables for the build process.

  • Go to PUBLIC\COMMON\OAK\CSP\X86\BIOSLOADER\LOADER

  • Open the fat.h file and change the READ_BUFFER_LENGTH_MAX from 0x4000 to 0x3000

  • Then enter build –c on the command line. This should build the BLDR file in the same directory with a size of 20 KB

  • If the build fails, it might be because iniparse.lib is not built. If so go to PUBLIC\COMMON\OAK\CSP\X86\BIOSLOADER\INIPARSER and build that first. Then build the loader directory
Making the Setup Disk

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:
  • Go to INSTALL_PARTITION:\Program Files\Windows CE Platform Builder\5.00\CEPB\UTILITIES

  • Execute websetup.exe
With that step out of the way, create the setup diskette as follows:
  • Go to PUBLIC\COMMON\OAK\CSP\X86\BIOSLOADER\DISKIMAGES

  • Put a floppy in the A: drive and double click SETUPDISK.144.

  • After setupdisk.144 runs successfully, the setup diskette is ready. Open the diskette and replace BLDR with the BLDR built in the previous section with READ_BUFFER_LENGTH_MAX as 0x3000.
Editing the Boot.ini file

The setup diskette contains a file called boot.ini that specifies a number of important parameters. Edit this file as follows:
  • Change the DisplayWidth, DisplayHeight and DisplayDepth to suit your requirements. For our board we set them as 1024, 768, 16

  • Change the line BinFile=eboot.bix to BinFile=nk.bin. This specifies which OS image to boot. We specify it as nk.bin and keep a working Windows CE OS image nk.bin in the hard disk.

  • Set BakBinFile=eboot.bix

  • Copy this boot.ini file to the setup diskette or keep it in another floppy. It will also be copied to the hard disk.
Setting the Environment
  • Start the target board or CEPC with the just created setup

  • Use fdisk to create a partition on the hard disk or CF or DiskOnChip from which Windows CE will boot automatically.

  • Ensure that the Primary partition is less than 512MB. There is much discussion in the newsgroups on this restriction. For our case, we keep the primary partition to 32MB, just enough to hold nk.bin and the registry. Set this primary partition as Active, again using fdisk. Let us call this primary partition C:

  • Create and configure other partitions as necessary. For our case we create one more partition from the remaining 220 MB.

  • The detailed fdisk steps are:
    • Delete the present C: partition by selecting 3 in the fdisk menu
    • Then select 1 to create a partition, select 1 again for primary partition and set the size to 32 MB
    • Make that partition active by selecting 2. This creates the C: drive
    • Create another extended partition for the remaining storage space. This becomes the D: drive
    • Format the C and D drives

  • Once partitioning is complete, run the mkdisk command with the argument C: i.e. mkdisk C:
mkdisk copies the bootsect.img and the BLDR files from the diskette to the proper sectors of the hard disk. bootsect.img is placed in the first sector, i.e., track zero, head zero, sector one of the hard disk, also called the MBR (Master boot Record). BLDR is copied to contiguous sectors.

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:
  • Create a test platform with hard disk, Ethernet, and FTP enabled. We build the platform to get a Windows CE image that we'll call nkloader.bin

  • Use the CEPCBoot diskette to boot the target machine (or CEPC) and use Ethernet to load and run nkloader.bin

  • Connect the test platform to the target machine and use FTP to copy the release version of nk.bin from the FTP home directory (by default /Temp) to the boot partition, C:, of the hard disk

  • Remove the diskette

  • Configure the BIOS to use the hard disk as the default boot device and reboot the target (or CEPC)
The boot process

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.



Talk Back!


Do you have questions or comments on this article? talkback here



About the author


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."


Related Stories


(Click here for further information)


Windows XP for Embedded Applications
This white paper describes the benefits of using Windows XP when developing embedded applications.

A Manager's Guide to Selecting a Mobile Device Operating System
This white paper offers a comparative review of Microsoft Windows CE and Windows Mobile.

Visual Basic 6.0 to .NET Migration
This paper focuses on the methodology and techniques which Infosys (Microsoft Technology Center) has developed for migrating VB 6.0 Applications to .NET. Our approach ensures a smooth, cost effective, and efficient migration.

Mobile Device Security: Securing the Handheld, Securing the Enterprise
This whitepaper identifies security threats to corporate data on mobile devices and details how mobile devices can become a "backdoor" to the enterprise.

Mobile Device Security: The Eight Areas of Risk
It's common knowledge that adding mobile devices to your network increases security risks. There are multiple facets to mobile security, all of which should be paid close attention to. This E-Guide presents a more in depth look into the eight key areas of securing wireless devices.

Quality Assurance and .NET
This paper discusses best practices for functional, regression and load testing of .NET applications.

SCADA Security in Integrated Networks
As businesses leverage their SCADA systems by integrating them into the business networks, they must also assure the security of the SCADA system.

The Advantages of Small Form Factor HMI
HMIs have mutated and changed with new requirements, and they have become more flexible and capable. And while they've been doing that, they've become smaller and more useful.

9 Critical Requirements for Web Application Security
Learn why your Web applications expose dangerous security breaches and what’s required to effectively protect your Web applications and the sensitive information behind them.

 


Got a HOT tip?   please tell us!
Free weekly newsletter
Enter your email...
Click here for a profile of each sponsor:
PLATINUM SPONSORS
(Become a sponsor)

ADVERTISEMENT
(Advertise here)


Updated! The latest Windows-powered...

mobile phones!

other cool
gadgets

HOT TOPICS
Microsoft targets PNDs with new embedded OS
Microsoft tips .NET MF 3.0 highlights
Microsoft previews Windows Embedded Standard
Microsoft offers free Windows CE 6.0 textbook
Microsoft renames embedded operating systems
Microsoft unveils Windows Mobile 6.1
New Atom models target low-cost PCs
REFERENCE GUIDES
Windows Device Showcase
Intro to Windows Embedded
Intro to Shared Source
Real-time Windows Embedded
Windows Embedded books
Join our Windows Embedded discussion forums:
Windows XP Embedded
Windows CE
Windows Mobile


Windows Embedded developer newsgroups
Windows CE
XP Embedded
PocketPC
Smartphone

Microsoft's Windows Embedded resources
Embedded dev center
Mobile dev center
Windows CE tutorials
XP Embedded tutorials
Windows Embedded seminars
Windows Embedded application categories
3rd-party partners


BREAKING NEWS

• Asus soft-launches "fashion" netbook
• Truck computer runs Windows Mobile
• ETX module targets military apps
• Cross-platform dev tool adds Windows Mobile
• Freescale wants out of cellular business
• Touch Cruise gets Windows Mobile 6.1
• Zune software slated for Windows Mobile
• Embedded confab does Windows
• GPS module sips 1.8 Volts
• Windows Mobile phone sports custom interface
• Webcast demos "battery-friendly" Windows Mobile apps
• Ethernet module runs .NET MF
• Speech tech supports Windows devices
• Windows Mobile devices attack desktops via ActiveSync
• Atom-based module trims COM Express


MOST POPULAR (last 90 days)
• "Netbook" uses Intel's Atom N270
• Windows CE takes on Linux in low-end netbooks
• Windows Mobile 6.1 phone has GPS
• T-Mobile's Touch Diamond clone does HSUPA
• iPhone-like Windows Mobile device has 16GB of storage
• HTC phone has slide-out keyboard and TV output
• Windows Mobile trouncing the iPhone?
• HTC releases Touch Diamond ROM upgrade
• Sprint upgrades HTC Touch, Mogul
• Intel's Atom powers mini-ITX board
MOST POPULAR (Classics from the vault)
Windows XP Embedded USB boot
Troubleshooting Windows XPe's blue screen "Stop 0x0000007B" error
Asus reveals $190 mini notebook
Windows Mobile 6 SDKs available for download
Windows Mobile VPN client plays with Cisco
HTC adds GPS to Windows Mobile Touch line
Microsoft unveils Windows Mobile 6.1
Guide to HTC's Windows Mobile smartphone platforms
Customizing Windows XP Embedded thin clients
Visual Studio 2008 adds mobile application features

Also visit our sister sites:


Sign up for WindowsForDevices.com's...

news feed

Home  |  News  |  Articles  |  Polls  |  Forum  |  Directory  |  About  |  Contact
 

Ziff Davis Enterprise Home | Contact Us | Advertise | Link to Us | Reprints | Magazine Subscriptions | Newsletters
Tech RSS Feeds | White Papers | ROI Calculators | Tech Podcasts | Tech Video | VARs | Channel News

Baseline | Careers | Channel Insider | CIO Insight | DesktopLinux | DeviceForge | DevSource | eSeminars |
eWEEK | Enterprise Network Security | LinuxDevices | Linux Watch | Microsoft Watch | Mid-market | Networking | PDF Zone |
Publish | Security IT Hub | Strategic Partner | Web Buyer's Guide | Windows for Devices

Developer Shed | Dev Shed | ASP Free | Dev Articles | Dev Hardware | SEO Chat | Tutorialized | Scripts |
Code Walkers | Web Hosters | Dev Mechanic | Dev Archives | igrep

Use of this site is governed by our Terms of Service and Privacy Policy. Except where otherwise specified, the contents of this site are copyright © 1999-2008 Ziff Davis Enterprise Holdings Inc. All Rights Reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff Davis Enterprise is prohibited. Windows is a trademark or registered trademark of Microsoft Corporation in the United States and/or other countries and is used by WindowsForDevices under license from owner. All other marks are the property of their respective owners. WindowsForDevices is an independent publication not affiliated with Microsoft Corporation.