linux内核跳转到文件系统,Uboot到Kernel到文件系统(Cortex_A9)移植详细文档
處理器:Exynos4412 ?Cortex_A9 四核
一: 4412 uboot 目錄:
uboot基本配置編譯
make xxx_config
編譯結(jié)果如上圖。
Uboot啟動第一階段分析:
1. cpu/arm_cortexa9/start.S
http://blog.chinaunix.net/uid-29589379-id-5568665.html
2.cpu/arm_cortexa9/u-boot.lds
http://blog.chinaunix.net/uid-29589379-id-5569651.html
cpu/arm_cortexa9/s5pc210/cpu_init.S
http://blog.chinaunix.net/uid-29589379-id-5571447.html
board/samsung/smdkc210/lowlevel_init.S
http://blog.chinaunix.net/uid-29589379-id-5571454.html
3.內(nèi)存布局
http://blog.chinaunix.net/uid-29589379-id-5571499.html
4.u-boot 中的命令實現(xiàn)
http://blog.chinaunix.net/uid-29589379-id-5570660.html
Uboot啟動第二階段分析:
第二階段入口地址為: start_armboot?在lib_arm/board.c?中定義。
1.lib_arm/board.c
http://blog.chinaunix.net/uid-29589379-id-5571531.html
2.u-boot 編譯過程
http://blog.chinaunix.net/uid-29589379-id-5572684.html
3.NAND 閃存中啟動U-BOOT
http://blog.chinaunix.net/uid-29589379-id-5573356.html
4.U-boot 給kernel 傳參數(shù)和kernel 讀取參數(shù)
1.u-boot 給kernel 傳RAM 參數(shù)
http://blog.chinaunix.net/uid-29589379-id-5573412.html
2.kernel 讀取參數(shù)
http://blog.chinaunix.net/uid-29589379-id-5573393.html
3.U-boot 中的bd 和gd
http://blog.chinaunix.net/uid-29589379-id-5573420.html
U-BOOT 源碼分析及移植
1.u-boot 工程的總體結(jié)構(gòu)
http://blog.chinaunix.net/uid-29589379-id-5573487.html
2.u-boot 的流程、主要的數(shù)據(jù)結(jié)構(gòu)、內(nèi)存分配
1.u-boot 的啟動流程:
http://blog.chinaunix.net/uid-29589379-id-5573503.html
2.u-boot 主要的數(shù)據(jù)結(jié)構(gòu)
http://blog.chinaunix.net/uid-29589379-id-5573522.html
3.u-boot重定位后的內(nèi)存分布
http://blog.chinaunix.net/uid-29589379-id-5573529.html
uboot 引導(dǎo) kernel 關(guān)鍵地方
上面Uboot啟動第二階段分析第4節(jié):? U-boot 給kernel 傳參數(shù)和kernel 讀取參數(shù)
.u-boot 給kernel 傳RAM 參數(shù)
./common/cmd_bootm.c 文件中, bootm 命令對應(yīng)的 do_bootm 函數(shù),當(dāng)分析 uImage 中信息發(fā)現(xiàn) OS 是 Linux 時 ,
調(diào)用 ./lib_arm/bootm.c 文件中的 do_bootm_linux 函數(shù)來啟動 Linux kernel 。
Kernel 讀取U-boot 傳遞的相關(guān)參數(shù)
對于 Linux Kernel , ARM 平臺啟動時,先執(zhí)行
arch/arm/kernel/head.S
,此文件
會調(diào)用 arch/arm/kernel/head-common.S 中的函數(shù),并最后調(diào)用 start_kernel :
......
b start_kernel
......
init/main.c 中的 start_kernel 函數(shù)中會調(diào)用 setup_arch 函數(shù)來處理各種平臺相關(guān)的動作,包括了 u-boot 傳遞過來參數(shù)的分析和保存:
start_kernel()
{
......
setup_arch(&command_line);
......
}
setup_arch 函數(shù)在
arch/arm/kernel/setup.c
文件中實現(xiàn)
二:
Kernel
啟動過程詳細(xì)分析
Kernel 目錄如下圖:
先用make menuconfig 配置內(nèi)核 , 編譯內(nèi)核?? make zImage
編譯生成由uboot引導(dǎo)的內(nèi)核鏡像 ?make? uImage
編譯模塊?? make modules
內(nèi)核啟動流程1---匯編部分:
內(nèi)核啟動流程代碼入口:
linux?內(nèi)核編譯連接后生成的ELF映像文件是vmlinux,從內(nèi)核源代碼頂層目錄下的Makefile?中可以找到vmlinux的生成規(guī)則。
vmlinux : $?(vmlinux-lds)? $(vmlinux-init) $(vmlinux-main) vmlinux.o $(kallsyms.o)?FORCE
頂層Makefile
http://blog.chinaunix.net/uid-29589379-id-5574552.html
其中 $(vmlinux-lds) 是連接器腳本,對于ARM平臺而言,就是 arch/arm/kernel/vmlinux-lds 文件。從該腳本的可以看出,第一個被鏈接的段是 “.text.head“
SECTIONS
* {
*?. = START;
*?__init_begin = .;
*
HEAD_TEXT_SECTION
*?INIT_TEXT_SECTION(PAGE_SIZE)
*?INIT_DATA_SECTION(...)
*?PERCPU_SECTION(CACHELINE_SIZE)
*?__init_end = .;
......
}
1.?$(vmlinux-lds) 是連接器腳本:
http://blog.chinaunix.net/uid-29589379-id-5574566.html
2 .text.head 段定義于 arch/arm/kernel/head.S 中,入口標(biāo)號是 stext,因此可以判定,非壓縮 ARM Linux 內(nèi)核的入口點是 arch/arm/kernel/head.S?中的 stext。
arch/arm/kernelhead.S
http://blog.chinaunix.net/uid-29589379-id-5574569.html
3.THUMB(?add?r12, r10, #PROCINFO_INITFUNC?)???//切換數(shù)據(jù),最終跳轉(zhuǎn)到C語言函數(shù)start_kernel()(在__switch_data結(jié)束時,調(diào)用b start_kernel)
arch/arm/kernel/head-common.S?中103行 b start_kernel.
http://blog.chinaunix.net/uid-29589379-id-5574581.html
內(nèi)核啟動流程2---C語言部分:
C語言部分由? start_kernel?函數(shù)開始,到第一個用戶進程 init 結(jié)束,過程中調(diào)用了一系列的初始化函數(shù)對內(nèi)核組件進行初始化。
其中,start_kernel , rest_init , kernel_init , init_post 等四個函數(shù)構(gòu)成了整個初始化過程的主線
1.start_kernel()?定義于 init/main.c?。
http://blog.chinaunix.net/uid-29589379-id-5575333.html
start_kernel()對基本硬件,系統(tǒng)的結(jié)構(gòu)進行初始化。最后調(diào)用rest_init()函數(shù),該函數(shù)用于創(chuàng)建并啟動內(nèi)核線程init。
內(nèi)核啟動流程3.1----Busybox 的?init 進程 (純Linux,沒有Android)
Busybox 的 init 進程在 init/init.c 文件中
init/init.c
http://blog.chinaunix.net/uid-29589379-id-5575380.html
http://blog.csdn.net/conowen/article/details/7251057
init?啟動詳細(xì)流程
http://blog.chinaunix.net/uid-29589379-id-4592751.html
//來自
的博客
更多的驅(qū)動暫時沒有。
Linux?系統(tǒng)完。
Android 系統(tǒng)啟動過程分析 內(nèi)核啟動流程3.2----Android 文件系統(tǒng)??(Linux上的中間件Android)
1.Android?文件系統(tǒng) ramdisk.img
http://blog.chinaunix.net/uid-29589379-id-5576460.html
2.
Android 的啟動流程分析
Android從Linux系統(tǒng)啟動有4個步驟;
(1) init進程啟動
(2) Native服務(wù)啟動
(3) System Server,Android服務(wù)啟動
(4) Home啟動
Android 移植詳細(xì)分析
http://blog.chinaunix.net/uid-29589379-id-5494749.html
http://blog.csdn.net/luoshengyang/article/details/8923485?//老羅的Android?博客
init進程啟動
system/core/init/init.c
kernel會啟動第一個用戶級別的進程:init
.
init始終是第一個進程。
PS:可以通過:ps ?| grep init命令來查看其Pid為1。
import_kernel_cmdline(0, import_kernel_nv);
//獲取內(nèi)核關(guān)于文件系統(tǒng)的參數(shù),通過這個參數(shù)來啟動Android。? linux和Android 的接口
http://blog.chinaunix.net/uid-29589379-id-5577496.html
Linux驅(qū)動開發(fā)學(xué)習(xí)的一些必要步驟
http://blog.csdn.net/luobin1984/article/details/7945620
總結(jié)
以上是生活随笔為你收集整理的linux内核跳转到文件系统,Uboot到Kernel到文件系统(Cortex_A9)移植详细文档的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: “升”了!FF晋升贾跃亭为Section
- 下一篇: linux 设置gbk编码格式,设置ub