Ethernet Boot Loader Code Implementation
An Ethernet connection is typically used to download OS image files to the target device. The Ethernet boot loader communicates with Platform Builder running on the development workstation to download OS images and configure debugging services. An Ethernet connection provides faster image transfer and better integration with the Windows CE Ethernet debugging services.
When you download the contents of a ROM image into RAM or flash memory on the target device, Windows CE treats the region of memory into which the image is loaded as ROM. This saves you from burning a new ROM each time you need to test a new image, while allowing you to emulate the ROM-based environment.
The following process shows the sequence of steps an Ethernet boot loader completes to download an OS image:
- The boot loader formats and sends a broadcast Ethernet debugging BOOTME packet. The format of the packet is defined in %_WINCEROOT%\Public\Common\Oak\Inc\Ethdbg.h. This packet informs Platform Builder of the target device availability and contains the target device IP address and name. Platform Builder uses this information to initiate the download of the OS image.
- The boot loader initiates a Trivial File Transfer Protocol (TFTP) to transfer the OS image to the target device. This step is skipped if the user elects not to download an image, for example, if the target device boots with an OS image previously written to flash memory.
- When the download is completed, the debug tool in control sends an Ethernet debugging JUMPIMG packet. %_WINCEROOT%\Public\Common\Oak\Inc\Ethdbg.h defines the format of the packet. The packet instructs the boot loader to jump to the loaded OS image and contains configuration information for the Ethernet debugging services. Depending on the implementation, the boot loader may pass this configuration information along to the OAL in a shared memory section. This is necessary to configure the Ethernet debugging services.
Platform Builder provides Eboot.lib, a Help library, to assist you in developing Ethernet boot loaders. Eboot.lib is located in %_WINCEROOT%\Public\Common\Oak\Drivers\Ethdbg\Eboot and contains the following platform-independent routines:
Routines | Description |
---|---|
DHCP routines | Used to obtain a dynamic IP address at boot time from a DHCP server. |
TFTP routines | Used to download an OS image to a target device. |
Ethernet debugging routines | Used to assist in formatting the Ethernet debugging messages, which are used to communicate. |
Platform Builder includes the BLCOMMON library, which is a common infrastructure that can be reused by all boot loaders. For a description of the functions in the new BLCOMMON infrastructure, see the source and header files in %_WINCEROOT%\Public\Common\Oak\Drivers\Ethdbg\Blcommon\Blcommon.c and %_WINCEROOT%\Public\Common\Oak\Inc\Blcommon.h, respectively. The following process describes the flow of control with this infrastructure:
- During the platform boot process, the startup code in the OEM adaptation layer (OAL) calls the platform-independent BootloaderMain function.
- BootloaderMain initializes the platform, chooses the download transport, and then initializes the download transport by calling a set of control flow functions.
- The boot loader starts downloading the image to the target device using a set of download-related and Flash-related functions. During the download process, the boot loader may want to implement functions to show download progress.
- Once the download is completed, the boot loader starts the OS by calling the OEMLaunch function, which jumps to the OS entry point.
For more information about the control flow, download, and Flash functions, see BLCOMMON Code Library.
The easiest way to develop your boot loader code is to begin with and reuse existing sample sources provided in Platform Builder. Platform Builder provides sample boot loader code for each development platform that is supported out of the box. The boot loader code is available as part of the BSP for that platform and is typically located in the %_WINCEROOT%\Platform*\<Platform Name>*\Eboot directory. For a list of all the BSPs supported in Platform Builder, see Supported Board Support Packages.
**Note **All the sample boot loaders developed for the Platform Builder BSPs primarily use the Ethernet port for downloading OS images. However, you can use alternative methods in your boot loader for downloading OS images, as long as the OS images are installed in a quick and reliable manner.
At a minimum, you will still be required to modify a reference boot loader to properly initialize your board. You need to write only platform-specific and CPU-specific code modules for the boot loader. These modules initialize the CPU, the serial port, and the Ethernet adapter for the target device.
For simplicity and to maximize code reuse, the boot loader typically uses the same routines implemented in the OAL kernel source code for CPU and board-level initialization, including PCI, serial UARTs, and Ethernet controllers. A debug serial port is an I/O channel used for debugging a device driver or target device. This is different from the normal serial port code, which is implemented in driver form in Serial.dll.
The following table summarizes the boot loader elements that you must implement.
Element | Description |
---|---|
OEM startup code | The OEM-specific startup routine that initializes the kernel. It jumps to the main entry point implemented in %_WINCEROOT%\Platform\<Platform Name>\Eboot\Main.c.
The OEM startup code is implemented in %_WINCEROOT%\Platform\<Platform Name>\Eboot\CPU-specific\ directory in either Init.s or Init.src (Fwp2.s for ARM), depending on your microprocessor. |
Kernel startup code | A minimal version of the normal kernel startup code for the boot loader used mainly to initialize the cache. This code is implemented in %_WINCEROOT%\Platform\<Platform Name>\Eboot\CPU-specific\Oemboot.c. |
OEM platform initialization code | The OEM-specific code can include functionality such as displaying a splash screen or checking switches to allow alternate entry to diagnostic code or to the firmware monitor. A splash screen is an initial screen that is displayed by interactive software, which usually contains a logo, version information, author credits, or a copyright notice.
This code is implemented in %_WINCEROOT%\Platform\<Platform Name>\Eboot\CPU-specific\Oemboot.c. |
The following table summarizes the boot loader elements that you should implement if you want to download your OS.
Element | Description |
---|---|
Image download code | Code that downloads an OS image using the download transport. The code to support an Ethernet-based download is implemented in %_WINCEROOT%\Platform\<Platform Name>\Eboot\Ethdown.c. |
Ethernet I/O code | Code that downloads an OS image using an Ethernet connection. For a sample code, see %_WINCEROOT%\Platform\<Platform Name>\Eboot\Ethdown.c. |
Debug serial I/O code | Routines that read and write data to the debug serial port. To simplify development of the debug serial port support I/O code, use a standard (16550-compatible or similar) universal asynchronous receiver transmitter (UART) on the target device. The boot loader uses the same debug serial port routines implemented in the OAL.
This code is implemented in %_WINCEROOT%\Platform\<Platform Name>\Kernel\Hal\Debug.c and can be reused. For more information, see Enabling the Debug Serial Port. |
Flash write code (optional) | Routines that write data to flash memory. This code is necessary for your boot loader to support downloading and flashing the image into nonvolatile storage for later use.
This code is implemented in %_WINCEROOT%\Platform\<Platform Name>\Eboot\Ethdown.c. |
Firmware monitor (optional) | Routines that provide debugging support, such as dumping memory contents or disassembling code. Once the boot loader is functioning properly, you can perform basic debugging by sending firmware monitor commands to the debug serial monitor port. |
See Also
Last updated on Wednesday, April 13, 2005
© 2005 Microsoft Corporation. All rights reserved.