轉自: http://www.cnblogs.com/EmbeddedBoy/archive/2010/04/23/1718490.html
接上……
錯誤顯示:不知道的操作碼??
應該是彙編文件的問題,但彙編語言沒什麼問題,那就是彙編格式有問題了。在每一句前面加上縮進(Tab鍵),再build –c
就沒錯了;恭喜通過了……
驗證 %_WINCEROOT\Platform\My_2410\target\ARMV4I\Debug\Eboot.exe 是否已被創建。
7. Implement the boot loader's StartUp function.
關於這裏,看英文很爽,不過我推薦去這個牛人寫的看看:http://blog.csdn.net/nanjianhui/archive/2008/10/12/3065291.aspx
已經分析得很好了
但是我們可以先不要這麼詳細實現先,這一步可以留着以後去實現:
於是我的StartUp.s是這樣的
8. Create a boot loader main function.
main函數由Startup函數調用,是函數的入口點;The main function turns around and calls BootloaderMain, which is defined in the BLCOMMON library.
BLCOMMON庫定義了boot loader的基本結構,爲boot loader開發過程提供很多具體的實現;具體請Google
To create a boot loader main function
- Create a file called Main.c.
- Add the implementation for the main routine in the Main.c file.
The following code example shows the implementation of the main routine for the hardware platform used in this boot loader example.
void main(void)
{
// Common boot loader (blcommon) main routine.
//
BootloaderMain();
// Should never get here.
//
SpinForever();
}
9. Create stub versions for a number of OEM functions, including generic hardware platform routines and flash memory operations.
Stubs are routines that do not contain executable code. They act as placeholders位置標誌符for functions that need to be fully implemented later. When implementing stubs, you can leave comments that describe what you eventually need to do to add functionality to your function.
You need to create stubs for some generic hardware platform routines and flash memory operations because BLCOMMON expects to call these functions, but they have not yet been implemented. You can revisit these functions and then fully implement them later.
簡單地講,Stubs就是一些BLCOMMON需要去調用的函數的聲明,你可以在其他的地方實現這些函數
The stub versions added to Main.c are for the following generic hardware platform routines:
也就是說,我們main函數中聲明它們,然後實現它們;
The stub versions added to Flash.c are for the following flash memory-related functions:
- OEMStartEraseFlash
- OEMContinueEraseFlash
- OEMFinishEraseFlash
- OEMIsFlashAddr
- OEMWriteFlash
- OEMMapMemAddr
If the boot loader being developed does not need to erase or write to flash memory on your device, the flash memory routines can remain as stub versions and do not have to be fully implemented later.
flash.c中就具體的實現以上提到的函數,但如果你的設備不需要擦除或寫flash的話,有些函數是不需要實現的;
於是我main函數如下:main.c
flash函數如下:
flash.c
10. Add the new source files, Main.c. and Flash.c, created in the previous step to the SOURCES line in the sources file.
在sourcefile文件中的sources行添加main.c 、flash.c
然後就要解決鏈接依賴的問題:在sources文件中添加TARGETLIBS(定義要鏈接的庫文件) ,比如:
TARGETLIBS=$(_COMMONOAKROOT)\lib\$(_CPUDEPPATH)\blcommon.lib \
$(_COMMONOAKROOT)\lib\$(_CPUDEPPATH)\fulllibc.lib
它就解決了main函數中BootloaderMain調用的鏈接依賴;
所以總的sources文件內容如下:
11. Create the .bib file, which will be used by Romimage.exe to convert the boot loader .exe file into .bin and .nb0 files.
哈,我們若要產生.bin和.nb0文件就要用到這個.bib文件了
bib文件介紹請看:http://www.cnblogs.com/EmbeddedBoy/articles/1718835.html
創建一個Boot.bib文件,內容如下:
接着創建一個Makefile.inc文件,內容如下:
BootImage:
romimage boot.bib
接着把WINCETARGETFILES=BootImage加到sources文件中(已經加了)。
12. Rebuild the boot loader.
再次編譯:build -c
看%_WINCEROOT%\Platform\My2410\Target\ARMV4I\Debug中就有了吧
到這步是最基礎的,沒完待續……