Building a bootloader isn't much different than building a driver or an application. In fact, if you have already built your project more than likely your bootloader has already been built. But what if you want to make a change to the bootloader? Then knowing how to build it, and more important what happens when you build it, will help get from changing code to testing faster.
The first step is to find the source code. The source code may be in different places depending on the version of Windows CE that you are targeting and the BSP that you are using. The following are some locations to look:
Windows CE 4.2 and earlier:
            %_WINCEROOT%\Platform\<BSP Name>\eboot
            %_WINCEROOT%\Platform\<BSP Name>\sboot
Windows CE 5.0 and 6.0:
            %_WINCEROOT%\Platform\<BSP Name>\src\Bootloader
If you have received your BSP from a third party, the location could be different.
The next step is to identify what your bootloader will be named when it is built. The bib file for the bootloader will tell you the name of the file. The bib file will be you the bootlaoder folder usually. 
Let's look at the relevant lines in both C:\WINCE600\PLATFORM\CEPC\SRC\BOOTLOADER\EBOOT\boot.bib and
C:\WINCE600\PLATFORM\CEPC\SRC\BOOTLOADER\SBOOT\boot.bib and see how they are different:
;   Name     Start     Size      Type
;   ------- -------- -------- ----
    EBOOT   00130000 00020000 RAMIMAGE
;   Name     Start     Size      Type
;   ------- -------- -------- ----
    SBOOT    00130000 00010000 RAMIMAGE
The "Name" column for "Type" RAMIMAGE determines the file names that are created. In this case, eboot will create eboot.bin and eboot.nb0 while sboot will create sboot.bin and sboot.nb0. These files will be created and put in the appropriate sub folders in your platform's Target folder.
Now we know what to build to create the bootloader, what is created, and where the files end up after building. Let's build the bootloader.
Open a build window, which I discussed in << Platform Builder: Build Tools, Opening a Build Window >> and change directories to the bootloader folder. Then run build.exe << Platform Builder: Using Build.exe >>, and you are done.
So how did it do it? The following discussion will look at C:\WINCE600\PLATFORM\CEPC\SRC\BOOTLOADER\EBOOT:
1.      Build processed the sources file and then ran nmake to build the source files
2.      Nmake linked the object files and pre-built libraries to create eboot.exe (yes, I know that nmake doesn't actually do the linking)
3.      In the sources file, WINCETARGETFILES is defined to be equal to RomImage. WINCETARGETFILES tells build to process the target RomImage after building the target defined in the sources file. 
4.      Build "knows" that the rule for WINCETARGETFILES is defined in
5.      The rule for WINCETARGETFILES is:

!IF "$(NOLINK)" == ""   
      romimage boot.bib
!IF "$(WINCEREL)"=="1"
      copy $(_TARGETPLATROOT)\target\$(_TGTCPU)\$(WINCEDEBUG)\eboot.* $(_FLATRELEASEDIR)

which says:
                                                               i.      When building target RomImage, if the environment variable NOLINK is not set to some value, then run "romimage boot.bib" which creates the ROM images
                                                             ii.      When building target RomImage, if the environment variable WINCEREL is set to 1, then copy the ROM images from the Target folder to the _FLATRELEASEDIR
Copyright © 2008 – Bruce Eitman
All Rights Reserved