linux内核跳转到文件系统,Uboot到Kernel到文件系统(Cortex_A9)移植详细文档

处理器:Exynos4412  Cortex_A9 四核

一: 4412 uboot 目录:

0818b9ca8b590ca3270a3433284dd417.png

uboot基本配置编译

make xxx_config

编译结果如上图。

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.内存布局

http://blog.chinaunix.net/uid-29589379-id-5571499.html

4.u-boot 中的命令实现

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 传参数和kernel 读取参数

1.u-boot 给kernel 传RAM 参数

http://blog.chinaunix.net/uid-29589379-id-5573412.html

2.kernel 读取参数

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 工程的总体结构

http://blog.chinaunix.net/uid-29589379-id-5573487.html

2.u-boot 的流程、主要的数据结构、内存分配

1.u-boot 的启动流程:

http://blog.chinaunix.net/uid-29589379-id-5573503.html

2.u-boot 主要的数据结构

http://blog.chinaunix.net/uid-29589379-id-5573522.html

3.u-boot重定位后的内存分布

http://blog.chinaunix.net/uid-29589379-id-5573529.html

uboot 引导 kernel 关键地方

上面Uboot启动第二阶段分析第4节:  U-boot 给kernel 传参数和kernel 读取参数

.u-boot 给kernel 传RAM 参数

./common/cmd_bootm.c 文件中, bootm 命令对应的 do_bootm 函数,当分析 uImage 中信息发现 OS 是 Linux 时 ,

调用 ./lib_arm/bootm.c 文件中的 do_bootm_linux 函数来启动 Linux kernel 。

Kernel 读取U-boot 传递的相关参数

对于 Linux Kernel , ARM 平台启动时,先执行

arch/arm/kernel/head.S

,此文件

会调用 arch/arm/kernel/head-common.S 中的函数,并最后调用 start_kernel :

......

b start_kernel

......

init/main.c 中的 start_kernel 函数中会调用 setup_arch 函数来处理各种平台相关的动作,包括了 u-boot 传递过来参数的分析和保存:

start_kernel()

{

......

setup_arch(&command_line);

......

}

setup_arch 函数在

arch/arm/kernel/setup.c

文件中实现

二:

Kernel

启动过程详细分析

Kernel 目录如下图:

0818b9ca8b590ca3270a3433284dd417.png

先用make menuconfig 配置内核 , 编译内核   make zImage

编译生成由uboot引导的内核镜像  make  uImage

编译模块   make modules

内核启动流程1---汇编部分:

内核启动流程代码入口:

linux 内核编译连接后生成的ELF映像文件是vmlinux,从内核源代码顶层目录下的Makefile 中可以找到vmlinux的生成规则。

vmlinux : $ (vmlinux-lds)  $(vmlinux-init) $(vmlinux-main) vmlinux.o $(kallsyms.o) FORCE

0818b9ca8b590ca3270a3433284dd417.png

顶层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 中,入口标号是 stext,因此可以判定,非压缩 ARM Linux 内核的入口点是 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 )   //切换数据,最终跳转到C语言函数start_kernel()(在__switch_data结束时,调用b start_kernel)

arch/arm/kernel/head-common.S 中103行 b start_kernel.

http://blog.chinaunix.net/uid-29589379-id-5574581.html

内核启动流程2---C语言部分:

C语言部分由  start_kernel 函数开始,到第一个用户进程 init 结束,过程中调用了一系列的初始化函数对内核组件进行初始化。

其中,start_kernel , rest_init , kernel_init , init_post 等四个函数构成了整个初始化过程的主线

0818b9ca8b590ca3270a3433284dd417.png

1.start_kernel() 定义于 init/main.c 。

http://blog.chinaunix.net/uid-29589379-id-5575333.html

start_kernel()对基本硬件,系统的结构进行初始化。最后调用rest_init()函数,该函数用于创建并启动内核线程init。

内核启动流程3.1----Busybox 的 init 进程 (纯Linux,没有Android)

Busybox 的 init 进程在 init/init.c 文件中

0818b9ca8b590ca3270a3433284dd417.png

init/init.c

http://blog.chinaunix.net/uid-29589379-id-5575380.html

http://blog.csdn.net/conowen/article/details/7251057

init 启动详细流程

http://blog.chinaunix.net/uid-29589379-id-4592751.html

//来自

的博客

更多的驱动暂时没有。

Linux 系统完。

Android 系统启动过程分析 内核启动流程3.2----Android 文件系统  (Linux上的中间件Android)

1.Android 文件系统 ramdisk.img

http://blog.chinaunix.net/uid-29589379-id-5576460.html

2.

Android 的启动流程分析

Android从Linux系统启动有4个步骤;

(1) init进程启动

(2) Native服务启动

(3) System Server,Android服务启动

(4) Home启动

Android 移植详细分析

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);

//获取内核关于文件系统的参数,通过这个参数来启动Android。  linux和Android 的接口

http://blog.chinaunix.net/uid-29589379-id-5577496.html

Linux驱动开发学习的一些必要步骤

http://blog.csdn.net/luobin1984/article/details/7945620

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值