U-Boot的命令為用戶提供了交互功能,并且已經(jīng)實現(xiàn)了幾十個常用的命令。如果開發(fā)板需要很特殊的操作,可以添加新的U-Boot命令。U-Boot的每一個命令都是通過U_Boot_CMD宏定義的。這個宏在
#defineU_BOOT_CMD(name,maxargs,rep,cmd,usage,help)\
cmd_tbl_t__u_boot_cmd_##nameStruct_Section={#name,maxargs,rep,cmd,usage}
其中:
·name:命令的名字,他不是一個字符串,不能用雙引號括起來
·maxargs:最大的參數(shù)個數(shù)
·command:對應的函數(shù)指針
·usage:一個字符串,簡短的使用說明
·help:一個字符串,比較詳細的使用說明
對于bootm命令,其定義如下:
[plain]view plaincopy
1.U_BOOT_CMD(//bootm命令
2.bootm,CFG_MAXARGS,1,do_bootm,
3."bootm-bootapplicationimagefrommemory\n",
4."[addr[arg...]]\n-bootapplicationimagestoredinmemory\n"
5."\tpassingarguments'arg...';whenbootingaLinuxkernel,\n"
6."\t'arg'canbetheaddressofaninitrdimage\n"
7.#ifdefCONFIG_OF_FLAT_TREE
8."\tWhenbootingaLinuxkernelwhichrequiresaflatdevice-tree\n"
9."\tathirdargumentisrequiredwhichistheaddressoftheofthe\n"
10."\tdevice-treeblob.Tobootthatkernelwithoutaninitrdimage,\n"
11."\tusea'-'forthesecondargument.Ifyoudonotpassathird\n"
12."\tabd_infostructwillbepassedinstead\n"
13.#endif
14.);
bootm命令是用來引導經(jīng)過U-Boot的工具mkimage打包后的kernelimage的。U-Boot源代碼的tools/目錄下有mkimage工具,這個工具可以用來制作不壓縮或者壓縮的多種可啟動映象文件。 mkimage在制作映象文件的時候,是在原來的可執(zhí)行映象文件的前面加上一個0x40字節(jié)的頭,記錄參數(shù)所指定的信息,這樣uboot才能識別這個映象是針對哪個CPU體系結(jié)構(gòu)的,哪個OS的,哪種類型,加載內(nèi)存中的哪個位置,入口點在內(nèi)存的那個位置以及映象名是什么。
U-Boot正是通過bootm命令引導Linux內(nèi)核的。bootm命令調(diào)用do_bootm函數(shù),下面我們來分析一下:
do_bootm函數(shù)流程分析
do_bootm_linux函數(shù)
-
Linux
+關(guān)注
關(guān)注
87文章
11511瀏覽量
213851 -
Uboot
+關(guān)注
關(guān)注
4文章
129瀏覽量
29103
原文標題:非常詳細!圖文帶你詳解U-Boot引導內(nèi)核分析
文章出處:【微信號:gh_c472c2199c88,微信公眾號:嵌入式微處理器】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
發(fā)布評論請先 登錄
U-Boot介紹
U-boot的基本介紹

U-Boot是如何引導系統(tǒng)的
u-boot詳解
u-boot引導啟動Linux 2.6的內(nèi)核
U-Boot的啟動及移植分析
Porting U-Boot to the Control
u-boot的Makefile分析
U-Boot結(jié)構(gòu)功能介紹

U-Boot源代碼分析之Linux的引導
u-boot簡介
U-Boot架構(gòu)淺析

tiny4412編譯與移植U-Boot

評論