bootelf命令:启动vmlinux

bootm命令:启动uImage

go命令:启动zImage

Linux几种内核镜像及其关系

前言:链接脚本

用户态程序不用关心section的具体位置;在用户态,内核会解析elf可执行文件的各个section、然后把它映射到虚拟地址空间。

然而,uboot和linux内核的启动都是从零开始的;所以,需要在编译时指定链接地址、而链接地址一般在lds文件中确定(链接器通过读取lds配置文件来决定)。

vmlinux(这个vmlinux属于未压缩,带调试信息、符号表的最初的内核)的入口地址:

kernel/arch/arm/kernel/vmlinux.lds

OUTPUT_ARCH(arm)
ENTRY(stext)
SECTIONS
{. = 0xC0008000;

kernel/arch/arm/kernel/head.S

ENTRY(stext)

zImage(由压缩后的vmlinux和自解压缩程序组成)的入口地址:

kernel/arch/arm/boot/compressed/vmlinux.lds

OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{. = 0;

kernel/arch/arm/boot/compressed/head.S

start:

说明:将zImage添加64Bytes的相关信息后就为uImage

=================================================================================================================================

以下附上skyeye1.2.6的下载地址(之前的skyeye1.2.8在uboot启动内核时有些问题):

http://pan.baidu.com/share/link?shareid=1673022906&uk=185233171&fid=1631621989

一、下载linux-2.6.14

http://download.csdn.net/download/bill_xiang/5240450

二、编译linux-交叉编译器arm-linux-gcc-3.4.1

交叉编译器下载地址:

http://ishare.iask.sina.com.cn/f/10838407.html

1.基本配置

修改顶层Makefile:

ARCH ?= arm
CROSS_COMPILE ?= /home/lianxi/skyeye/usr/local/arm/3.4.1/bin/arm-linux-

生成内核配置文件:

make smdk2410_defconfig

2.添加网卡驱动

cs8900.c cs8900.h   //具体可以在网上查找,这里不罗列

将上述文件拷贝至drivers/net/arm/

drivers/net/arm/Kconfig添加如下:

config ARM_CS8900tristate "CS8900 support"depends on NET_ETHERNET && ARM && ARCH_SMDK2410helpSupport for CS8900A chipset based Ethernet cards. If you have a network(Ethernet) card of this type, say Y and read the Ethernet-HOWTO, availablefrom as well as .To compile this driver as a module, choose M here and read.The module will be called cs8900.o.

drivers/net/arm/Makefile添加如下:

obj-$(CONFIG_ARM_CS8900) += cs8900.o

修改arch/arm/mach-s3c2410/mach-smdk2410.c

//add by tankai
#include <asm-arm/arch-s3c2410/smdk2410.h>
//end tankai
static struct map_desc smdk2410_iodesc[] __initdata = {/* nothing here yet *///add by tankai/* Map the ethernet controller CS8900A */{vSMDK2410_ETH_IO,pSMDK2410_ETH_IO, SZ_1M, MT_DEVICE}//end tankai
};

添加include/asm-arm/arch-s3c2410/smdk2410.h

#ifndef _INCLUDE_SMDK2410_H_
#define _INCLUDE_SMDK2410_H_
#include <linux/config.h>
#define pSMDK2410_ETH_IO 0x19000000
#define vSMDK2410_ETH_IO 0xE0000000
#define SMDK2410_ETH_IRQ IRQ_EINT9
#endif

3.其他重要修改

修改include/asm-arm/arch-s3c2410/map.h include/asm-arm/arch/map.h include/asm/arch/map.h include/asm/arch/arch-s3c2410/map.h

//#define S3C2410_CS6 (0x30000000)
#define S3C2410_CS6 (0xC0000000)

修改include/asm-arm/arch-s3c2410/memory.h include/asm-arm/arch/memory.h include/asm/arch/memory.h include/asm/arch/arch-s3c2410/memory.h

//#define PHYS_OFFSET (0x30000000UL)
#define PHYS_OFFSET (0xC0000000UL)

修改arch/arm/kernel/head.S

ENTRY(stext)//add by tankaimov    r0, #0mov    r1, #0xc1ldr    r2, =0x30000100//end tankai
msr cpsr_c, #PSR_F_BIT | PSR_I_BIT | MODE_SVC @ ensure svc mode

4.配置内核
make menuconfig

内核启动参数(这个是我们内存盘根文件系统的加载路径,要跟配置文件s3c2410.conf中一样):

Boot options->Default kernel command string

mem=32M console=ttySAC0 root=/dev/ram initrd=0xc1000000,0x00600000 ramdisk_size=8192 rw

添加网卡驱动:

Device Drivers->Network device support->Ethernet (10 or 100Mbit)->CS8900 support

支持RamDisk内存盘(因为initrd需要):

Device Drivers->Block devices->RAM disk support

(4096) Default RAM disk size (kbytes)改成(8192) Default RAM disk size (kbytes)

Device Drivers->Block devices->Initial RAM disk (initrd) support

NFS文件系统支持:

File systems->Network File Systems->NFS file system support

File systems->Network File Systems->Provide NFSv3 client support

ROM文件系统支持:

File systems->ROM file system support

ext2文件系统支持:

File systems->Second extended fs support

5.编译

make -j2

生成vmlinux

三、制作根文件系统-交叉编译器arm-linux-gcc-3.4.1

1.下载busybox-1.9.2

http://download.csdn.net/download/eqwewr/3154108

2.编译

修改顶层Makefile:

ARCH ?= arm
CROSS_COMPILE ?= /home/lianxi/skyeye/usr/local/arm/3.4.1/bin/arm-linux-

设置静态编译:

make menuconfig

Busybox Settings->Build Options->Build BusyBox as a static binary (no shared libs)

编译错误:

applets/applets.c:15:2: warning: #warning Static linking against glibc produces buggy executables
applets/applets.c:16:2: warning: #warning (glibc does not cope well with ld --gc-sections).
applets/applets.c:17:2: warning: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
applets/applets.c:18:2: warning: #warning Note that glibc is unsuitable for static linking anyway.
applets/applets.c:19:2: warning: #warning If you still want to do it, remove -Wl,--gc-sections
applets/applets.c:20:2: warning: #warning from scripts/trylink and remove this warning.
applets/applets.c:21:2: #error Aborting compilation.
make[1]: *** [applets/applets.o] 错误 1
make: *** [applets] 错误 2

解决:

applets/applets.c

//#error Aborting compilation.

scripts/trylink

去掉-Wl,--gc-sections

3.安装

make install

错误:

modutils/lib.a(insmod.o)(.text.insmod_main+0x4f0): In function `insmod_main':
: undefined reference to `query_module'
modutils/lib.a(insmod.o)(.text.insmod_main+0x52c): In function `insmod_main':
: undefined reference to `query_module'
modutils/lib.a(insmod.o)(.text.insmod_main+0x5d8): In function `insmod_main':
: undefined reference to `query_module'
modutils/lib.a(insmod.o)(.text.insmod_main+0x628): In function `insmod_main':
: undefined reference to `query_module'
modutils/lib.a(insmod.o)(.text.insmod_main+0x6f4): In function `insmod_main':
: undefined reference to `query_module'
modutils/lib.a(insmod.o)(.text.insmod_main+0x1118): In function `$a':
: undefined reference to `create_module'
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] 错误 1

解决:make menuconfig

去掉Linux Module Utilities->Support version 2.2.x to 2.4.x Linux Kernels

最终结果:在顶层目录下生成_install目录。

4.制作initrd格式的文件系统

创建镜像并挂载到initrd目录:

mkdir initrd
dd if=/dev/zero of=initrd.img bs=1k count=4096
mke2fs -F -v initrd.img
mount -o loop initrd.img initrd

添加命令到该镜像:

cd initrd
cp -r ../busybox-1.9.2/_install/* .

创建必要目录:

mkdir proc lib etc dev root home var tmp
chmod 777 tmp

创建设备节点:

cd dev
mknod -m 644 console c 5 1
mknod -m 644 null c 1 3
mknod -m 640 ram b 1 1
mknod -m 644 mem c 1 1
cd ..

创建脚本文件etc/inittab,内容如下:

::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh
::restart:/sbin/init
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a

chmod 644 etc/inittab

创建脚本文件etc/init.d/rcS, 内容如下:

#!/bin/sh
/bin/mount -t proc none /proc
/sbin/ifconfig lo 127.0.0.1 up
/sbin/ifconfig eth0 10.0.0.2 netmask 255.0.0.0 up
hostname skyeye
mkdir /var/tmp
mkdir /var/log
mkdir /var/run
mkdir /var/lock
/bin/ash

chmod 755 etc/init.d/rcS

执行实际的写入操作,生成initrd.img

cd ..
umount initrd

四、uboot部分修改u-boot-2011.12

1.交叉编译器——arm-linux-gcc-4.4.3

uboot/arch/arm/config.mk

CROSS_COMPILE ?= /home/lianxi/skyeye/opt/FriendlyARM/toolschain/4.4.3/bin/arm-linux-

2.dcache问题

uboot/arch/arm/lib/cache-cp15.c

void dcache_enable(void)
{//cache_enable(CR_C);
}
void dcache_disable(void)
{//cache_disable(CR_C);
}

uboot/arch/arm/cpu/arm920t/start.S

#define CONFIG_SKIP_LOWLEVEL_INIT //add by tankai

五、实际运行

1.硬件配置文件s3c2410.conf

#skyeye config file sample
cpu: arm920t
mach: s3c2410x
###########################################################################
mem_bank: map=M, type=RW, addr=0x00000000, size=0x01000000, file=./u-boot.bin, boot=yes
mem_bank: map=M, type=RW, addr=0x30000000, size=0x04000000
mem_bank: map=M, type=RW, addr=0xc0000000, size=0x01000000, file=./vmlinux
mem_bank: map=M, type=RW, addr=0xc1000000, size=0x00600000, file=initrd.img
mem_bank: map=M, type=RW, addr=0xc1600000, size=0x00a00000
##########################################################################
mem_bank: map=I, type=RW, addr=0x48000000, size=0x20000000
#mem_bank: map=I, type=RW, addr=0x19000300, size=0x00000020
#net: type=cs8900a, base=0x19000300, size=0x20,int=9, mac=0:4:3:2:1:f, ethmod=tuntap, hostip=10.0.0.1
#lcd:type=s3c2410x,mod=gtk
dbct:state=on

2.运行

skyeye -c s3c2410.conf

结果:

**************************** WARNING **********************************
If you want to run ELF image, you should use -e option to indicate
your elf-format image filename. Or you only want to run binary image,
you need to set the filename of the image and its entry in skyeye.conf.
***********************************************************************Your elf file is little endian.
arch: arm
cpu info: armv4, arm920t, 41009200, ff00fff0, 2
mach info: name s3c2410x, mach_init addr 0x427070
dbct info: turn on dbct!
uart_mod:0, desc_in:, desc_out:, converter:
SKYEYE: use arm920t mmu ops
Loaded RAM   ./u-boot.bin
Loaded RAM   ./vmlinux
Loaded RAM   initrd.img
TK-------uboot/arch/arm/lib/board.c>>>board_init_f
ERROR: s3c2410x_io_write_word(0x4c000000) = 0x00ffffff
ERROR: s3c2410x_io_write_word(0x4c000008) = 0x00048032U-Boot 2011.12 (Nov 08 2013 - 09:03:37)DRAM:  64 MiB
TK--------uboot/arch/arm/lib/board.c>>>board_init_r
TK--------uboot/arch/arm/lib/board.c>>>board_init_r>>call>>enable_caches()
WARNING: Caches not enabled
TK-------uboot/arch/arm/lib/cache-cp15.c>>>>cache_enable
TK--------uboot/arch/arm/lib/cache-cp15.c>>>dcache_enable
TK--------uboot/arch/arm/lib/cache-cp15.c>>>>>dcache_enable>>>11111
Flash: 1 MiB
NAND:  ERROR: s3c2410x_io_write_word(0x4e000000) = 0x00008377
ERROR: s3c2410x_io_write_word(0x4e000000) = 0xfffff7ff
ERROR: s3c2410x_io_write_word(0x4e000004) = 0x000000ff
ERROR: s3c2410x_io_write_word(0x4e000000) = 0xfffff7ff
raise: Signal # 8 caught
raise: Signal # 8 caught
ERROR: s3c2410x_io_write_word(0x4e000000) = 0xfffff7ff
ERROR: s3c2410x_io_write_word(0x4e000004) = 0x00000090
ERROR: s3c2410x_io_write_word(0x4e000000) = 0xfffff7ff
ERROR: s3c2410x_io_write_word(0x4e000008) = 0x00000000
ERROR: s3c2410x_io_write_word(0x4e000000) = 0xfffff7ff
raise: Signal # 8 caught
raise: Signal # 8 caught
ERROR: s3c2410x_io_write_word(0x4e000000) = 0xfffff7ff
ERROR: s3c2410x_io_write_word(0x4e000004) = 0x00000090
ERROR: s3c2410x_io_write_word(0x4e000000) = 0xfffff7ff
ERROR: s3c2410x_io_write_word(0x4e000008) = 0x00000000
ERROR: s3c2410x_io_write_word(0x4e000000) = 0xfffff7ff
raise: Signal # 8 caught
raise: Signal # 8 caught
No NAND device found!!!
ERROR: s3c2410x_io_write_word(0x4e000000) = 0xffffffff
0 MiB
*** Warning - bad CRC, using default environmentIn:    serial
Out:   serial
Err:   serial
Net:   CS8900-0
Warning: failed to set MAC addressSMDK2410 #

在uboot启动后,输入:bootelf 0xc0000000启动内核:

SMDK2410 # bootelf 0xc0000000
TK---------uboot/common/cmd_elf.c>>>>>do_bootelf
TK---------uboot/common/cmd_elf.c>>>>>do_bootelf>>>>addr is 0xc0000000
## Starting application at 0xc0008000 ...
TK----->>>kernel/init/main.c>>>>>>start_kernel
Linux version 2.6.14 (root@tankai-G41T-R3) (gcc version 3.4.1) #32 Fri Nov 8 11:00:06 CST 2013
CPU: ARM920Tid(wb) [41009200] revision 0 (ARMvundefined/unknown)
Machine: SMDK2410
Warning: bad configuration page, trying to continue
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410 (id 0x32410000)
S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
S3C2410 Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists
Kernel command line: mem=32M console=ttySAC0 root=/dev/ram initrd=0xc1000000,0x00600000 ramdisk_size=8192 rw
irq: clearing pending status 00004000
irq: clearing pending status 00008000
irq: clearing pending status 00800000
irq: clearing pending status 10000000
irq: clearing subpending status 00000093
PID hash table entries: 256 (order: 8, 4096 bytes)
timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c
Console: colour dummy device 80x30
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 32MB = 32MB total
Memory: 24332KB available (1505K code, 277K data, 92K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
TK-----kernel/init/initramfs.c>>>>__initramfs_start is 0xc001c560
TK-----kernel/init/initramfs.c>>>>__initramfs_end is 0xc001c5e6
TK-------kernel/init/initramfs.c>>>>>unpack_to_rootfs
TK-------kernel/init/initramfs.c>>>>>unpack_to_rootfs>>>>>11111,len is 134
TK-------kernel/init/initramfs.c>>>>>unpack_to_rootfs>>>>>2222
TK-----kernel/init/initramfs.c>>>>>err is 0x0
checking if image is initramfs...TK----kernel/init/initramfs.c>>>>>initrd_start is 0xc1000000
initrd_end is 0xc1600000
TK-------kernel/init/initramfs.c>>>>>unpack_to_rootfs
TK-------kernel/init/initramfs.c>>>>>unpack_to_rootfs>>>>>11111,len is 6291456
TK-------kernel/init/initramfs.c>>>>>unpack_to_rootfs>>>>>2222
it isn't (bad gzip magic numbers); looks like an initrd
softlockup thread 0 started up.
Freeing initrd memory: 6144K
NET: Registered protocol family 16
S3C2410: Initialising architecture
Console: switching to colour frame buffer device 80x25
fb0: Virtual frame buffer device, using 1024K of video memory
s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
eth0: incorrect signature 0x0000
mice: PS/2 mouse device common for all mice
NET: Registered protocol family 2
IP route cache hash table entries: 512 (order: -1, 2048 bytes)
TCP established hash table entries: 2048 (order: 1, 8192 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
RAMDISK: ext2 filesystem found at block 0
RAMDISK: Loading 4096KiB [1 disk] into ram disk... done.
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 92K
init started: BusyBox v1.9.2 (2013-11-05 10:11:12 CST)
starting pid 15, tty '': '/etc/init.d/rcS'
ifconfig: SIOCSIFADDR: No such device
/bin/ash: can't access tty; job control turned off
# 

skyeye模拟uboot启动linux(initrd方式)相关推荐

  1. uboot启动linux内核流程分析(三)

    uboot bootz命令流程图 Uboot启动linux内核是使用bootz命令,bootz是如何启动linux内核?uboot的生命周期是怎么终止的?linux是如何启动? 启动linux内核的时 ...

  2. 手把手教你在友善之臂tiny4412上用uboot启动Linux内核

    要想用uboot启动内核,我推荐一种方法,用dnw下载内核到开发板上,然后用uboot命令启动: 首先我在网上随便下了一个dnw工具,经过移植修改后,代码如下: /* YYX--->for ti ...

  3. uboot启动Linux内核(一):uboot启动流程

    1. uboot介绍:    uboot是bootloader的一种,是Linux内核的引导启动程序.会初始化嵌入式平台上的一些外设(比如:ddr等),把Linux内核镜像从flash中加载到内存,在 ...

  4. uboot启动linux,uboot中ramdisk启动linux的两种方法

    首先要确保内核支持ramdisk启动: The configuration of the kernel is as follow: 1) General setup-->[*] Initial  ...

  5. U-Boot启动流程(Linux内核)的分析

    http://www.360doc.com/content/12/0816/10/7775902_230452499.shtml     前面一段时间一直在移植U-Boot,Linux内核和构建根文件 ...

  6. U-Boot启动流程(Linux内核)的分析(写得好)

    前面一段时间一直在移植U-Boot,Linux内核和构建根文件系统,其中有些地方还不是很明白,现在回过头来,理解一下U-boot的启动流程,以及 u-Boot是如何加载引导内核启动的.这里的分析也都是 ...

  7. U-boot启动流程(Linux内核)的分析(四)

    在上一篇中分析到u-Boot启动Linux内核的函数do_bootm_linux,这一篇则着重分析,U-boot是如果一步一步启动内核的. 我们可以看到在,start_armboot()函数的最后,在 ...

  8. u-boot启动过程

    目录: 一.初识u-boot 3 1,Bootloader介绍 3 2,Bootloader的启动方式 3 (1)网络启动方式 4 (2)磁盘启动方式 4 (3)Flash启动方式 4 3,U-boo ...

  9. U-Boot启动过程--详细版的完全分析

    目录: 一.初识u-boot 3 1,Bootloader介绍 3 2,Bootloader的启动方式 3 (1)网络启动方式 4 (2)磁盘启动方式 4 (3)Flash启动方式 4 3,U-boo ...

最新文章

  1. MIB in SNMP
  2. 小程序json字符串转 json对象 { name :你好} 转成 { name :你好}
  3. ViewTreeObserver简介
  4. 【EI/Scopus检索】第六届电子技术与信息科学国际学术会议诚邀您投稿参会!
  5. 关于子网划分的几个捷径
  6. Maven开发笔记(四)—— Maven中plugins和pluginManagement
  7. 初探PostgreSql
  8. 敏捷开发“松结对编程”系列之七:问题集之一
  9. 如何格式化用过的磁带,让他被新磁带机重复利用
  10. java jvm参数获取_在java代码中获取JVM参数
  11. Java爬虫开发总结
  12. 人工智能(腾讯AI)-身份证识别技术使用接口说明
  13. Win10下 QT的安装配置 (亲测可用)
  14. 计算机操作系统有几种基本管理,操作系统有哪些管理功能
  15. 比google earth还好的实景地图
  16. android实现刷卡功能,Android 实现银联刷卡机消费后手动签名的功能(示例代码)
  17. 在线手写汉字识别工具
  18. linux终端关闭xmanager,xmanager之linux 解决方法
  19. “年薪百万”的视频剪辑师?Adobe专家让这一切都成为可能
  20. 重拾Eclipse开发

热门文章

  1. [附源码]计算机毕业设计Python港口集团仓库管理系统(程序+源码+LW文档)
  2. java列出100以内的素数_Java判断100以内的素数
  3. UiPath PDF数据提取
  4. 基于软件和超融合基础架构的长期规划助力华南师范大学 在疫情期间保证持续优质的教学体验
  5. html获取中国天气,Json获取中国天气网天气预报的代码
  6. web页面制作基础(部分重要知识总结)
  7. Android API与Android版本的关系
  8. 远景html制造机模板,10.11仿冒声卡驱动:经历无数个夜晚终于制作成功,自己总结了一套制作教程分享给大家...
  9. python绘制草莓熊
  10. Saleae Logic16 逻辑分析仪使用说明