Boot Loader in wince Development

Source: Internet
Author: User
I am glad that the product development process of the company is not subject to the resistance caused by boot loader, because we use msdos + loadcepc to start the CE operating system. Obviously, this is not always lucky, so you should have enough research and understanding about boot loader to plan ahead.

Boot Loader is an important part of development in the process of customizing the Windows CE operating system. The role of boot loader is just like the two words in the name: boot, which guides the system. If Ce-based products use BIOS for hardware initialization and configuration, then Boot Loader only needs to guide the software system. If the BIOS is not used, the function of the boot loader also includes implementing the basic functions of the BIOS. The loader not only loads the operating system, after the system is started normally, Boot Loader loads the Kernel File nk of CE in different ways. bin. After the boot loader decompress NK. bin to ram, it gives the CPU control to the CE kernel. The most types of Boot Loader are available on the X86 platform. The following describes the boot loader on the x86 Platform:


X86 ROM Boot Loader


It is also called ROM boot. Remember to mention ROM boot in previous articles. Rom Boot is designed to be stored in Flash/EEPROM, that is, the original BIOS location. After power-on, the CPU runs the code at a fixed address, that is, the Code contained in ROM boot is executed, it initializes and detects the entire hardware system and supports downloading NK from a remote machine through the NIC. bin or search for nk from the active partition of the local IDE/ATA hard disk. binfile loading. The advantage of ROM boot is that boot is fast and it has completed all its operations, so that it does not need bios, msdos, or loadcepc. The disadvantage is that Ce developers need to understand its source code and modify it. Ce provides all the source code of ROM boot. You can find the help document titled "x86 source organization". This document lists all related directories and contents, the driver source code directory of the four NICS is also listed.


X86 BIOS Boot Loader


BiOS boot loader is similar to msdos + loadcepc. BIOS Boot Loader only does not require the msdos operating system. It still requires the bios and FAT file system. The following describes the boot sequence of the system using BIOS Boot Loader: After the system is powered on, the BIOS checks the boot sequence of the boot device after hardware initialization and configuration is completed, if the boot device is a hard disk, a CF card, or a DOC (Disk-on-chip) storage device, load the primary Boot Sector (Master Boot Sector) on the memory) and then execute the code. The Code mentioned here is called as the Master Boot Record (MBR ). MBR first searches for active partitions in the Partition Table (also in the primary Boot Sector). If active partitions exist, load the code on the first sector of the active partition to the memory, then execute the code. The first sector of the active partition mentioned here is called the Boot Sector ). The function of the Code on the boot sector is to find and load the BIOS boot loader, and then the BIOS Boot Loader loads NK. Bin. The source code of the boot sector is located in the directory % _ winceroot %/public/common/oak/CSP/istrap/biosloader/bootsector. There is a ready-made Boot Sector image file with the PATH % _ winceroot %/public/common/oak/CSP/istrap/biosloader/diskimages/setupdisk/bsect. IMG. For BIOS boot loader, Ce provides the setupdisk.144 and bootdisk.144 files. I have discussed how to decompress files with the extension ". 144" in the previous article. After the two files are unbound, they both contain the Boot Sector and boot loader image files. Run the "mkdisk C:" Batch Processing Command to write the two image files to the disk. Mkdisk sets the hidden attribute of boot loader, so that all files in the root directory are not displayed.


Msdos + loadcepc

This method is very simple. After msdosstarts, execute loadcepc.exe, let loadcepc load NK. bin to the memory, and then give the CPU control to the CE kernel program. Loadcepc has already mentioned it in the previous article.


The following describes the components of Boot Loader Based on the general boot loader source code:


The boot loader consists of the OEM startup code and main code ). The OEM startup Code is the first part to be executed. Its function is to initialize memory registers, set CPU frequency, and initialize the cache. Then it jumps to the main code for execution. Generally, the OEM startup code is compiled in assembly. The main code is generally written in C language. It is responsible for all other tasks and can display the execution information on the screen at the same time. Generally, the company logo or other startup logos are modified here.


The main code consists of several parts: The image download code, which can be downloaded from a remote computer through a parallel port or network card. bin; Serial debugging code, including reading and writing functions on the serial port. You can call these functions to communicate with the local computer through the serial port; write flash code, includes functions for writing images to flash; Hardware monitoring code.


For the general execution process of boot loader, see:

The functions of each function in are as follows:


Startup (): the first function executed by the CPU. That is, the startup code.


Bootloadermain (): Call functions such as kernelrelocate, oemdebuginit, oemplatforminit, and oempredownload. The source code file path of this function is % _ winceroot %/public/common/oak/Drivers/ethdbg/blcommon.


Oemdebuginit (): Initialize the serial port.


Oemplatforminit (): executes initialization for a specific platform, such as clock and some drivers.


Oempredownload (): Prepare for the download. It is generally used for feedback to users.


Downloadimage (): Download the operating system image to Ram or flash.


Oemlaunch (): starts the image.


Oemreaddata (): reads data from a remote computer.


Oemmapmemaddr (): used for flash writing. Because the flash writing speed is very slow, this function temporarily caches the flash image to ram.


Oemshowprogress (): It can be seen from the function name.


Oemisflashaddr (): determines whether an address is a flash Address.


Oemfinisheraseflash (): determines whether the Flash content has been erased.


Oemwriteflash (): writes an image to flash.


Oemstarteraseflash (): Start to erase flash.


Oemcontinueeraseflash (): Continue to erase flash.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.