来源:linux-2.6.30.4/Documentation/arm/Booting ARM Linux

Booting ARM Linux
            =================

Author:    Russell King
Date  : 18 May 2002

The following documentation is relevant to 2.4.18-rmk6 and beyond.

In order to boot ARM Linux, you require a boot loader, which is a small
program that runs before the main kernel.  The boot loader is expected
to initialise various devices, and eventually call the Linux kernel,
passing information to the kernel.

Essentially, the boot loader should provide (as a minimum) the
following:

1. Setup and initialise the RAM.
2. Initialise one serial port.
3. Detect the machine type.
4. Setup the kernel tagged list.
5. Call the kernel image.

1. Setup and initialise RAM
---------------------------

Existing boot loaders:        MANDATORY
New boot loaders:        MANDATORY

The boot loader is expected to find and initialise all RAM that the
kernel will use for volatile data storage in the system.  It performs
this in a machine dependent manner.  (It may use internal algorithms
to automatically locate and size all RAM, or it may use knowledge of
the RAM in the machine, or any other method the boot loader designer
sees fit.)

2. Initialise one serial port
-----------------------------

Existing boot loaders:        OPTIONAL, RECOMMENDED
New boot loaders:        OPTIONAL, RECOMMENDED

The boot loader should initialise and enable one serial port on the
target.  This allows the kernel serial driver to automatically detect
which serial port it should use for the kernel console (generally
used for debugging purposes, or communication with the target.)

As an alternative, the boot loader can pass the relevant 'console='
option to the kernel via the tagged lists specifying the port, and
serial format options as described in

Documentation/kernel-parameters.txt.

3. Detect the machine type
--------------------------

Existing boot loaders:        OPTIONAL
New boot loaders:        MANDATORY

The boot loader should detect the machine type its running on by some
method.  Whether this is a hard coded value or some algorithm that
looks at the connected hardware is beyond the scope of this document.
The boot loader must ultimately be able to provide a MACH_TYPE_xxx
value to the kernel. (see linux/arch/arm/tools/mach-types).

4. Setup the kernel tagged list
-------------------------------

Existing boot loaders:        OPTIONAL, HIGHLY RECOMMENDED
New boot loaders:        MANDATORY

The boot loader must create and initialise the kernel tagged list.
A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE.
The ATAG_CORE tag may or may not be empty.  An empty ATAG_CORE tag
has the size field set to '2' (0x00000002).  The ATAG_NONE must set
the size field to zero.

Any number of tags can be placed in the list.  It is undefined
whether a repeated tag appends to the information carried by the
previous tag, or whether it replaces the information in its
entirety; some tags behave as the former, others the latter.

The boot loader must pass at a minimum the size and location of
the system memory, and root filesystem location.  Therefore, the
minimum tagged list should look:

+-----------+
base ->    | ATAG_CORE |  |
    +-----------+  |
    | ATAG_MEM  |  | increasing address
    +-----------+  |
    | ATAG_NONE |  |
    +-----------+  v

The tagged list should be stored in system RAM.

The tagged list must be placed in a region of memory where neither
the kernel decompressor nor initrd 'bootp' program will overwrite
it.  The recommended placement is in the first 16KiB of RAM.
(比如:我用的是tq2440的板子,内存起始地址是0x30000000,那么taglist建议放在0x30000000~0x30004000范围内,

实际在使用时放在了0x30000100的地方)

5. Calling the kernel image
---------------------------

Existing boot loaders:        MANDATORY
New boot loaders:        MANDATORY

There are two options for calling the kernel zImage.  If the zImage
is stored in flash, and is linked correctly to be run from flash,
then it is legal for the boot loader to call the zImage in flash
directly.

The zImage may also be placed in system RAM (at any location) and
called there.  Note that the kernel uses 16K of RAM below the image
to store page tables.  The recommended placement is 32KiB into RAM.

对于tq2440,zImage被加载到内存的0x30008000的地方,其中将来0x30004000~0x30008000的地址范围被用来存放一级页表,

一级页表的大小固定为16KiB(可以参考《ARM体系结构与编程》P179)。上面建议将zImage放到距离物理内存起始地址偏移32KiB的地方,

对于tq2440,物理内存起始地址是0x30000000,所以zImage应该放到0x30008000处。之前由于不知道这个知识点,尝试将zImage读到小于

0x30008000的地方,发现内核无法启动,但是如果将zImage加载到大于0x30008000的地方是可以启动的,比如0x3000A000,我是这么做的:

由于我在NandFlash中烧写的是uImage(64B+zImage),

 

nand read 0x30009fc0 0x200000 0x300000  (由于NandFlash的0x200000处存放的是uImage,这样的话,正好将zImage加载到0x3000a000处)

go2 0x3000a000  (go2这个命令是我加的,

 

#include <common.h>
#include <command.h> static struct tag *params; static void setup_start_tag(void)
{
params = (struct tag *)0x30000100; params->hdr.tag = ATAG_CORE;
params->hdr.size = tag_size (tag_core); params->u.core.flags = ;
params->u.core.pagesize = ;
params->u.core.rootdev = ; params = tag_next (params);
} static void setup_memory_tags(void)
{
params->hdr.tag = ATAG_MEM;
params->hdr.size = tag_size (tag_mem32); params->u.mem.start = 0x30000000;
params->u.mem.size = **; params = tag_next (params);
} static void setup_commandline_tag(char *cmdline)
{
int len = strlen(cmdline) + ; params->hdr.tag = ATAG_CMDLINE;
params->hdr.size = (sizeof (struct tag_header) + len + ) >> ; strcpy (params->u.cmdline.cmdline, cmdline); params = tag_next (params);
} static void setup_end_tag(void)
{
params->hdr.tag = ATAG_NONE;
params->hdr.size = ;
} static int do_go2 (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
ulong addr, rc;
int rcode = ; void (*theKernel)(int zero, int arch, uint params); if (argc < ) {
cmd_usage(cmdtp);
return ;
} addr = simple_strtoul(argv[], NULL, ); printf ("## Starting application at 0x%08lX ...\n", addr);
setup_start_tag();
setup_memory_tags();
/*setup_commandline_tag("noinitrd root=/dev/mtdblock2 rootfstype=yaffs init=/linuxrc mem=64M console=ttySAC0,115200");*/
setup_commandline_tag(getenv("bootargs"));
/*printf("bootargs = %s\n", getenv("bootargs"));*/
setup_end_tag(); /*run_command("nand read 0x30008000 0x200000 0x300000", 0);*/ printf ("##pengdonglin ##\n"); theKernel = (void (*)(int, int, uint))addr; theKernel(, , 0x30000100); /***************/ printf ("## Application terminated, rc = 0x%lX\n", rc);
return rcode;
} /* -------------------------------------------------------------------- */ U_BOOT_CMD(
go2, CONFIG_SYS_MAXARGS, , do_go2,
"start application at address 'addr'",
"addr [arg ...]\n - start application at address 'addr'\n"
" passing 'arg' as arguments"
);

 可以参考韦东山的视频教程。

)


In either case, the following conditions must be met:

- Quiesce all DMA capable devices so that memory does not get
  corrupted by bogus network packets or disk data. This will save
  you many hours of debug.

- CPU register settings
  r0 = 0,
  r1 = machine type number discovered in (3) above.
  r2 = physical address of tagged list in system RAM.

- CPU mode
  All forms of interrupts must be disabled (IRQs and FIQs)
  The CPU must be in SVC mode.  (A special exception exists for Angel)

- Caches, MMUs
  The MMU must be off.
  Instruction cache may be on or off.
  Data cache must be off.

- The boot loader is expected to call the kernel image by jumping
  directly to the first instruction of the kernel image.

Booting ARM Linux的更多相关文章

  1. arm linux kernel 从入口到start_kernel 的代码分析

    参考资料: <ARM体系结构与编程> <嵌入式Linux应用开发完全手册> Linux_Memory_Address_Mapping http://www.chinaunix. ...

  2. 构建 ARM Linux 4.7.3 嵌入式开发环境 —— BusyBox 构建 RootFS

    上一篇我们已经成功将 ARM Linux 4.7.3 的内核利用 U-BOOT 引导了起来.但是细心的你会发现,引导到后面,系统无法启动,出现内核恐慌 (Kernel Panic). 原因是找不到文件 ...

  3. 构建 ARM Linux 4.7.3 嵌入式开发环境 —— U-BOOT 引导 Kernel

    经过若干天的反复测试,搜索.终于成功利用 Qemu 在 u-boot 下引导 ARM Linux 4.7.3 内核.如下详细解释整个构建过程. 准备环境 运行环境:Ubuntu 16.04 需要的虚拟 ...

  4. ARM linux的启动部分源代码简略分析【转】

    转自:http://www.cnblogs.com/armlinux/archive/2011/11/07/2396784.html ARM linux的启动部分源代码简略分析 以友善之臂的mini2 ...

  5. How to build and run ARM Linux on QEMU from scratch

    This blog shows how to run ARM Linux on QEMU! This can be used as a base for later projects using th ...

  6. 引导 ARM Linux

    引导 ARM Linux 本文翻译自:https://www.kernel.org/doc/html/latest/arm/booting.html 引导 ARM Linux 需要一个引导加载程序,它 ...

  7. ARM Linux Qt 5.x.x 无标题栏

    /********************************************************************************* * ARM Linux Qt 5. ...

  8. ARM Linux 3.x的设备树(Device Tree)

    http://blog.csdn.net/21cnbao/article/details/8457546 宋宝华 Barry Song <21cnbao@gmail.com> 1.     ...

  9. ARM Linux启动代码分析

    前言 在学习.分析之前首先要弄明白一个问题:为什么要分析启动代码? 因为启动代码绝大部分都是用汇编语言写的,对于没学过或者不熟悉汇编语言的同学确实有一定难度,但是如果你想真正深入地学习Linux,那么 ...

随机推荐

  1. Hbase学习记录(2)| Shell操作

    查看表结构 describe '表名' 查看版本 get '表名','zhangsan'{COLUMN=>'info:age',VERSIONS=>3} 删除整行 deleteall '表 ...

  2. 第二百二十七天 how can I 坚持

    今天去了蟒山,天池,刚去的时候身体有点难受,整天都是那样,回来就好多了,不知道怎么回事. 天池竟然是个人造池,挺大,没有去十三陵,回来都很晚了. 去天池竟然是走的小路,已经关了,不让进,里边玲玲清清的 ...

  3. <转>linux进程间通信<一>

    这篇文章真心不错,只是代码比较久,有些地方需求大家自行修改.先全文转载,以备复习只用.原文链接为:http://www.ibm.com/developerworks/cn/linux/l-ipc/pa ...

  4. Hadoop学习笔记(2)

    Hadoop学习笔记(2) ——解读Hello World 上一章中,我们把hadoop下载.安装.运行起来,最后还执行了一个Hello world程序,看到了结果.现在我们就来解读一下这个Hello ...

  5. oracle max()函数和min()函数

    当需要了解一列中的最大值时,可以使用MAX()函数:同样,当需要了解一列中的最小值时,可以使用MIN()函数.语法如下. SELECT          MAX (column_name) / MIN ...

  6. JS、OnClientClick、OnClick

    OnClientClick是客户端事件处理方法,一般采用JavaScript来进行处理,也就是直接在浏览器端运行,一点击就运行: OnClick是服务器端事件处理方法,在服务器端也就是IIS中运行,点 ...

  7. CSS画出的各种形状图

    利用CSS可以画出各种需要的图形目录[1]矩形[2]圆形[3]椭圆[4]直角三角形[5]正三角形[6]平行四边形[7]梯形[8]六角星[9]六边形[10]五角星简单图形 矩形div{ width: 1 ...

  8. [转]Torch是什么?

    Torch是一个广泛支持机器学习算法的科学计算框架.易于使用且高效,主要得益于一个简单的和快速的脚本语言LuaJIT,和底层的C / CUDA实现:Torch | Github 核心特征的总结:1. ...

  9. 关于IE开发人员工具(F12)找不到的问题

    关于IE开发人员工具(F12)找不到的问题 解决方案:第一步,像往常一样F12或者,工具->开发人员工具,点击后,这个时候你是看不到工具界面(当然,如果你正好遇到了找不到这个问题);第二步,这个 ...

  10. 创建类模式(四):原型(Prototype)

    定义 用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象. 原型模式允许一个对象再创建另外一个可定制的对象,根本无需知道任何如何创建的细节,工作原理是:通过将一个原型对象传给那个要发动创建 ...