Chinaunix首页 | 论坛 | 博客

OS

  • 博客访问: 2211620
  • 博文数量: 691
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2660
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-05 12:49
个人简介

不浮躁

文章分类

全部博文(691)

文章存档

2019年(1)

2017年(12)

2016年(99)

2015年(207)

2014年(372)

分类: 嵌入式

2015-12-07 21:13:36

处理器:Exynos4412  Cortex_A9 四核

一: 4412 uboot 目录:



uboot基本配置编译
make xxx_config
编译结果如上图。

Uboot启动第一阶段分析:
//一直没有弄明白 uboot.lds 与 start.S,一直以为start.S 会先执行。其实是我理解错了,红色代表之前的位置。

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
//http://blog.csdn.net/itxiebo/article/details/50938753

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 目录如下图:
  
   先用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
   
    顶层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 等四个函数构成了整个初始化过程的主线 
      
      
     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 文件中 
       
       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  //来自草根老师的博客

      20190217:
      突然想到一个问题linux内核是如何与Busybox进行交互的呢?找到一个大牛写的博客才知道Busbox也是调用的内核接口实现控制kernel的。
      https://blog.csdn.net/wavemcu/article/details/8544333
      更多的驱动暂时没有。 
       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
          

 
阅读(4624) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~