U-Boot-2009.8引导Linux的2.6.32.2内核
来源:互联网 发布:get. it 编辑:程序博客网 时间:2024/04/29 17:03
1、机器码的确认:
U-Boot和Linux中都有一个机器码,只有当这两个机器码一致的时候,才能够正确的引导Linux内核。在这个版本中的U-boot和Linux 中,对MINI2440的板子支持的都很好了,也有了官方的机器码,只要添加上就可以了。在U-Boot中我们可以看到,在u-boot- 2009.08/include/asm-arm/mach-types.h文件中的1985行附近的位置
#define MACH_TYPE_Q2440 1997
#define MACH_TYPE_QQ2440 1998
#define MACH_TYPE_MINI2440 1999 //mini2440的机器码
#define MACH_TYPE_COLIBRI300 2000
#define MACH_TYPE_JADES 2001
f5d8231_4_v2 MACH_F5D8231_4_V2 F5D8231_4_V2 1996
q2440 MACH_Q2440 Q2440 1997
qq2440 MACH_QQ2440 QQ2440 1998
mini2440 MACH_MINI2440 MINI2440 1999 //Linux中的MINI2440的机器码
colibri300 MACH_COLIBRI300 COLIBRI300 2000
jades MACH_JADES JADES 2001
gpio->GPHUP = 0x000007FF;
/* arch number of SMDK2410-Board */
#if defined(CONFIG_S3C2440)
gd->bd->bi_arch_number = MACH_TYPE_MINI2440; //为u-boot添加机器码
//gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
#endif
MACHINE_START(MINI2440, "FriendlyARM MINI2440 development board")
通常,kernel的启动需要u-boot提供一些参数信息,比如ramdisk在RAM中的地址。经过编译后的u-boot在根目录下的tools目录 中,会有个叫做mkimage的工具,他可以给zImage添加一个header,也就是说使得通常我们编译的内核zImage添加一个数据头信息部分, 我们把添加头后的image通常叫uImage,uImage是可以被u-boot直接引导的内核镜像。我们如何使用这个工具生成我们需要的uImage格式的镜像文件呢?
1) 编译u-boot成功后会在u-boot-2009.08/tools下生成mkimage的可执行的文件,为了我们在任何地方都可以使用这个命令,首先 我们可以把这个可执行文件复制到/usr/local/bin.这样就可以在任意的目录下执行这个命令了。复制完以后我们在终端下输入 “mkimage”,并按下回车。可以看到下面的输出的信息,说明我们已经可以使用改命令了。
Usage: mkimage -l image
//用于指定CPU类型,比如ARM
-l ==> list image header information
mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
-A ==> set architecture to 'arch'
//用于指定操作系统,比如Linux
-O ==> set operating system to 'os'
//用于指定image类型,比如Kernelramdisk
-T ==> set image type to 'type'
//指定压缩类型
-C ==> set compression type 'comp'
//指定image的载入地址
-a ==> set load address to 'addr' (hex)
//内核的入口地址,一般是:image的载入地址+0x40(信息头的大小)
-e ==> set entry point to 'ep' (hex)
//image在头结构中的命名
-n ==> set image name to 'name'
//无头信息的image文件名
-d ==> use image data from 'datafile'
//设置执行位置即不进行文件的拷贝,在当前位置执行
-x ==> set XIP (execute in place)
mkimage [-D dtc_options] -f fit-image.its fit-image
对于ARM linux内核映象用法:
-A arm -------- 架构是arm
-O linux -------- 操作系统是linux
-T kernel -------- 类型是kernel
-C none/bzip/gzip -------- 压缩类型
-a 20008000 ---- image的载入地址(hex),通常为0xX00008000
-e 200080XX---- 内核的入口地址(hex),XX为0x40或者0x00
-n linux-XXX --- image的名字,任意
-d nameXXX ---- 无头信息的image文件名,你的源内核文件
uImageXXX ---- 加了头信息之后的image文件名,任意取
mkimage -n 'linux-2.6.32.2' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d zImage uImage.img
在u-boot-2009.08/include/configs/mini2440.h文件中
#define CONFIG_BOOTDELAY 3 //自动启动前延时3秒,不过这个要和下面的另一个配置一
//
起定义后才会其作用
#define CONFIG_BOOTARGS "noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200 mem=64M"
// 只有这个宏定义了以后 上面的哪个宏的定义才会生效,否则还是会直接的出现命令行的提示符,不会引导内核的。 root=/dev/mtdblock3 这是有我们Linux中的nand Flash分区所决定的,我的NandFlash的第四个分区为根文件系统所以是mtdblock3,如果不是的话请修改
我的NandFlash的情况是这样的
"U-boot",0x00000000 -- 0x00040000,
"param", 0x00040000--0x00060000,
"Kernel",
0x00060000---
0x00560000,
"root", 0x00560000---结束
#define CONFIG_SETUP_MEMORY_TAGS 1 //向内核传递内存分布信息
#define CONFIG_INITRD_TAG
#define CONFIG_CMDLINE_TAG 1 //向内核传递命令行参数
#define CONFIG_MTD_NAND_YAFFS2 1
#define MTDIDS_DEFAULT "nand0=nandflash0"
#define MTDPARTS_DEFAULT "mtdparts=nandflash0:256k(bootloader),"\
"128k(params),"\
"5m(kernel),"\
"-(root)" //这里要和Linux内核中的分区信息相一致
#define CONFIG_ENV_OFFSET 0x40000 //将环境变量保存在Nand中的0x30000位置
#define CONFIG_ENV_SIZE 0x20000 //Total Size of Environment Sector
#define CONFIG_BOOTCOMMAND "nand read 0x32000000 0x60000 0x560000;bootm 0x32000000"
//这个宏定义的意思是将nand中0x60000-0x560000(和kernel分区一致)的内容读到内存0x32000000中,然后用bootm命令来执行
我们先把内核下载到内存中,然后我们执行bootm命令(同一个地址)看能不能启动系统。在U-Boot下执行:
tftp 0x31000000 uImage.img (或uImage)
在提示下载完成后再执行:
bootm 0x31000000
如果成功则证明我们的设置没有问题。
4、下载固化
在前面我们看到了NandFlash的分区信息。下面我们使用命令,把我们的Linux内核和制作的根文件系统下载到NandFlash中,以便以开始启动就可以引导Linux内核。
起始地址 结束地址
uboot : 0x00000000 0x00040000 0
param : 0x00040000 0x00060000 0
root : 0x00560000 0x07FFFFFF 0
在u-boot下输入tftp 0x30000000 uImage.img(或uImage),稍等即可下载uImage到内存中。
nand erase[clean][off size] 擦除NANDFlash。加上“clean”时,表示在每个块的第一个扇区的OOB区加写入清除的标记:off size表示要擦除的开始偏移地址和长度,如果省略off size 擦除整个NandFlash。现在可以从新启动开发板,从NandFlash启动可以看到启动的信息了。
下载Linux 镜像
[U-Boot@mini2440]#tftp 0x30000000 uImage.img
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 10.27.10.48; our IP address is 10.27.10.23
Filename 'uImage.img'.
Load address: 0x30000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###################
done
Bytes transferred = 2092996 (1fefc4 hex)
[U-Boot@mini2440]#nand erase 0x60000 0x500000
NAND erase: device 0 offset 0x60000, size 0x500000
Erasing at 0x54000002800000 -- 0% complete.
OK
[U-Boot@mini2440]#nand write 0x30000000 0x60000 0x500000
NAND write: device 0 offset 0x60000, size 0x500000
5242880 bytes written: OK
[U-Boot@mini2440]#tftp 30000000 rootfs.img
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 10.27.10.48; our IP address is 10.27.10.23
Filename 'rootfs.img'.
Load address: 0x30000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
####
done
Bytes transferred = 7339200 (6ffcc0 hex)
[U-Boot@mini2440]#nand erase 0x560000
NAND erase: device 0 offset 0x560000, size 0x7aa0000
Erasing at 0x7fe000007aa0000 -- 0% complete.
OK
[U-Boot@mini2440]#nand write.yaffs2 0x30000000 0x560000 0x6ffcc0
NAND write: device 0 offset 0x560000, size 0x6ffcc0
skip first good block 56000000020000
Writing at 0xc4000000020000 --100% is complete 7116800 bytes written: OK
U-Boot 2009.08 ( 4??月 24 2010 - 17:34:23)
DRAM: 64 MB
Flash: 2 MB
NAND Device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-b)
NAND: 128 MiB
*** Warning - bad CRC or NAND, using default environment
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
NAND read: device 0 offset 0x60000, size 0x500000
5242880 bytes read: OK
## Booting kernel from Legacy Image at 32000000 ...
Image Name: linux-2.6.32.2
Created: 2010-04-24 3:25:34 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2092932 Bytes = 2 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux.............................................................
Linux version 2.6.32.2 (zfz@zfz) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-70
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: FriendlyARM MINI2440 development board
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0M
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60500KB available (3672K code, 418K data, 132K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:85
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
JFFS2 version 2.2. (NAND) ?© 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
yaffs Apr 20 2010 11:10:26 Installing.
msgmni has been set to 118
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach
s3c2410-lcd: probe of s3c2410-lcd failed with error -22
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-b)
Scanning device for bad blocks
Creating 5 MTD partitions on "NAND 128MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "U-boot"
0x000000040000-0x000000060000 : "param"
ftl_cs: FTL header not found.
0x000000060000-0x000000560000 : "Kernel"
ftl_cs: FTL header not found.
0x000000560000-0x000040560000 : "root"
mtd: partition "root" extends beyond the end of device "NAND 128MiB 3,3V 8-bit"0
ftl_cs: FTL header not found.
0x000000000000-0x000040000000 : "nand"
mtd: partition "nand" extends beyond the end of device "NAND 128MiB 3,3V 8-bit"0
dm9000 Ethernet Driver, V1.31
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
ALSA device list:
No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
yaffs: dev is 32505859 name is "mtdblock3"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.3, "mtdblock3"
yaffs: auto selecting yaffs2
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 132K
/etc/init.d/rcS: line 7: echo--------- munt all--------: not found
*************************
**********************Frankzfz ARM**************
Kernel version:linux-2.32.2
Student:zfz
Data:2010,4,19
***********************
Please press Enter to activate this console.
[root@"Frankzfz"=W]#ls
bin etc linuxrc proc sys var
boot home lost+found root tmp
dev lib mnt sbin usr
- U-Boot-2009.8引导Linux的2.6.32.2内核
- U-boot引导Linux-2.6.39.3内核问题
- U-boot如何引导Linux内核启动
- U-boot如何引导Linux内核启动
- U-boot如何引导Linux内核启动?
- U-BOOT 引导内核
- U-BOOT 引导内核
- u-boot 自引导内核
- u-boot引导zImage内核
- u-boot.lds分析(u-boot-1.3.4 nandflash启动 引导linux内核)
- u-boot.lds分析(u-boot-1.3.4 nandflash启动 引导linux内核)
- 从bootm看u-boot引导内核的过程
- u-boot无法引导initramfs内核的问题
- 记录u-boot不能引导内核的解决过程
- U-Boot启动引导内核分析(一)
- U-Boot启动引导内核分析(二)
- U-Boot启动引导内核分析(三)
- 转: U-Boot启动引导内核分析
- 字符串转整型(atoi)
- C语言#define条件编译避免多重包含头文件
- 漫水填充算法
- android Layout XML属性
- 黑马程序员-Java基础综合练习:简易聊天服务器
- U-Boot-2009.8引导Linux的2.6.32.2内核
- How do you set, clear and toggle a single bit in C?
- U-Boot启动流程(Linux内核)的分析(一转)
- IIS应用程序池添加ASP.NET v4.0
- 端口查看和复用
- U-Boot启动流程(Linux内核)的分析(二转)
- U-boot启动流程(Linux内核)的分析(三转)
- 使用eclipse开发linux驱动
- U-boot启动流程(Linux内核)的分析(四转)