Chinaunix首页 | 论坛 | 博客
  • 博客访问: 913106
  • 博文数量: 132
  • 博客积分: 9976
  • 博客等级: 中将
  • 技术积分: 1781
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-30 20:40
文章分类

全部博文(132)

文章存档

2013年(1)

2011年(1)

2010年(15)

2009年(77)

2008年(36)

2007年(2)

我的朋友

分类: C/C++

2009-05-19 14:08:52

U-BOOT下使用bootm引导内核
=================================================================================
from: http://lichengwulove.blog.163.com/blog/static/84648311200891011871/

U-BOOT下使用bootm引导内核  2008-10-10 13:01
分类:U-BOOT
字号: 大大  中中  小小

一、在开始之前先说明一下bootm相关的东西。

1、首先说明一下,S3C2410架构下的bootm只对sdram中的内核镜像文件进行操作(好像AT91架构提供了一段从flash复制内核镜像的代码,不过针对s3c2410架构就没有这段代码,虽然可以在u-boot下添加这段代码,不过好像这个用处不大),所以请确保你的内核镜像下载到sdram中,或者在bootcmd下把flash中的内核镜像复制到sdram中。

2、-a参数后是内核的运行地址,-e参数后是入口地址。

3、

1)如果我们没用mkimage对内核进行处理的话,那直接把内核下载到0x30008000再运行就行,内核会自解压运行(不过内核运行需要一个tag来传递参数,而这个tag建议是由bootloader提供的,在u-boot下默认是由bootm命令建立的)。

 

2)如果使用mkimage生成内核镜像文件的话,会在内核的前头加上了64byte的信息,供建立tag之用。bootm命令会首先判断bootm xxxx 这个指定的地址xxxx是否与-a指定的加载地址相同。

(1)如果不同的话会从这个地址开始提取出这个64byte的头部,对其进行分析,然后把去掉头部的内核复制到-a指定的load地址中去运行之

(2)如果相同的话那就让其原封不同的放在那,但-e指定的入口地址会推后64byte,以跳过这64byte的头部。

二、好,接着介绍使用mkimage生成镜像文件并下载运行的方法。

方法一、

1、首先,用u-boot/tools/mkimage这个工具为你的内核加上u-boot引导所需要的文件头,具体做法如下:

[root@localhost tftpboot]#mkimage -n 'linux-2.6.14' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d zImage zImage.img

Image Name:   linux-2.6.14

Created:      Fri Jan 12 17:14:50 2007

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    1262504 Bytes = 1232.91 kB = 1.20 MB

Load Address: 0x30008000

Entry Point:  0x30008000

这里解释一下参数的意义:

        -A ==> set architecture to 'arch'

        -O ==> set operating system to 'os'

        -T ==> set image type to 'type'

        -C ==> set compression type 'comp'

        -a ==> set load address to 'addr' (hex)

        -e ==> set entry point to 'ep' (hex)

        -n ==> set image name to 'name'

        -d ==> use image data from 'datafile'

        -x ==> set XIP (execute in place)

 

2 、下载内核

U-Boot 1.1.3 (Jan 12 2007 - 16:16:36)

U-Boot code: 33F80000 -> 33F9BAC0  BSS: -> 33F9FBAC

RAM Configuration:

Bank #0: 30000000 64 MB

Nor Flash: 512 kB

Nand Flash:  64 MB

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

sbc2410=>tftp 0x31000000 zImage.img       

TFTP from server 192.168.1.115; our IP address is 192.168.1.128

Filename 'zImage.img'.

Load address: 0x31000000

Loading: #################################################################

        #################################################################

        #################################################################

        ####################################################

done

Bytes transferred = 1263324 (1346dc hex)

3.运行

sbc2410=>bootm 0x31000000

## Booting image at 31000000 ...

  Image Name:   linun-2.6.14

  Image Type:   ARM Linux Kernel Image (uncompressed)

  Data Size:    1263260 Bytes =  1.2 MB

  Load Address: 30008000

  Entry Point:  30008000

  Verifying Checksum ... OK

OK

Starting kernel ...

Uncompressing Linux.............................................................Linux version 2.6.14 (root@luofuchong) (gcc version 3.4.1) #21 Fri Oct 20 17:206CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)

Machine: SMDK2410

Memory policy: ECC disabled, Data cache writeback

CPU S3C2410A (id 0x32410002)

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

USB Control, (c) 2006 sbc2410

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: console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.115:/frien"irq: clearing subpending status 00000002

PID hash table entries: 512 (order: 9, 8192 bytes)

timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c

Console: colour dummy device 80x30

Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)

Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)

Memory: 64MB = 64MB total

Memory: 62208KB available (1924K code, 529K data, 108K init)

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

softlockup thread 0 started up.

NET: Registered protocol family 16

S3C2410: Initialising architecture

SCSI subsystem initialized

usbcore: registered new driver usbfs

usbcore: registered new driver hub

S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics

DMA channel 0 at c4800000, irq 33

DMA channel 1 at c4800040, irq 34

DMA channel 2 at c4800080, irq 35

DMA channel 3 at c48000c0, irq 36

NetWinder Floating Point Emulator V0.97 (double precision)

devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)

devfs: devfs_debug: 0x0

devfs: boot_options: 0x1

yaffs Oct 18 2006 12:39:51 Installing.

Console: switching to colour frame buffer device 30x40

fb0: s3c2410fb frame buffer device

fb1: Virtual frame buffer device, using 1024K of video memory

led driver initialized

s3c2410 buttons successfully loaded

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 4096K size 1024 blocksize

usbcore: registered new driver ub

Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)

eth0: CS8900A rev E at 0xe0000300 irq=53, no eeprom , addr: 08: 0:3E:26:0A:5B

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

s3c2410-nand: mapped registers at c4980000

s3c2410-nand: timing: Tacls 10ns, Twrph0 30ns, Twrph1 10ns

NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bi)Scanning device for bad blocks

Bad eraseblock 1884 at 0x01d70000

Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":

0x00000000-0x00020000 : "vivi"

0x00020000-0x00030000 : "param"

0x00030000-0x00200000 : "kernel"

0x00200000-0x04000000 : "root"

usbmon: debugfs is not available

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

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

Initializing USB Mass Storage driver...

usbcore: registered new driver usb-storage

USB Mass Storage support registered.

usbcore: registered new driver usbmouse

drivers/usb/input/usbmouse.c: v1.6:USB HID Boot Protocol mouse driver

mice: PS/2 mouse device common for all mice

s3c2410 TouchScreen successfully loaded

UDA1341 audio driver initialized

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 4096 (order: 2, 16384 bytes)

TCP bind hash table entries: 4096 (order: 2, 16384 bytes)

TCP: Hash tables configured (established 4096 bind 4096)

TCP reno registered

TCP bic registered

NET: Registered protocol family 1

IP-Config: Complete:

     device=eth0, addr=192.168.1.128, mask=255.255.255.0, gw=192.168.1.1,

    host=luofuchong, domain=, nis-domain=(none),

    bootserver=192.168.1.1, rootserver=192.168.1.115, rootpath=

Looking up port of RPC 100003/2 on 192.168.1.115

Looking up port of RPC 100005/1 on 192.168.1.115

VFS: Mounted root (nfs filesystem).

Mounted devfs on /dev

Freeing init memory: 108K

init started:  BusyBox v1.1.3 (2006.09.20-14:52+0000) multi-call binary

Starting pid 696, console /dev/tts/0: '/etc/init.d/rcS'

Please press Enter to activate this console.

方法二、

1、首先,用u-boot/tools/mkimage这个工具为你的内核加上u-boot引导所需要的文件头,具体做法如下:

[root@localhost tftpboot]#mkimage -n 'linux-2.6.14' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d zImage zImage.img

Image Name:   linux-2.6.14

Created:      Fri Jan 12 17:14:50 2007

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    1262504 Bytes = 1232.91 kB = 1.20 MB

Load Address: 0x30008000

Entry Point:  0x30008040

 

2 、下载内核

U-Boot 1.1.3 (Jan 12 2007 - 16:16:36)

U-Boot code: 33F80000 -> 33F9BAC0  BSS: -> 33F9FBAC

RAM Configuration:

Bank #0: 30000000 64 MB

Nor Flash: 512 kB

Nand Flash:  64 MB

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

sbc2410=>tftp 0x30008000 zImage.img       

TFTP from server 192.168.1.115; our IP address is 192.168.1.128

Filename 'zImage.img'.

Load address: 0x30008000

Loading: #################################################################

        #################################################################

        #################################################################

        ####################################################

done

Bytes transferred = 1263324 (1346dc hex)

3.运行

sbc2410=>bootm 0x30008000

## Booting image at 30008000 ...

   Image Name:   linux-2.6.14

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    1261056 Bytes =  1.2 MB

   Load Address: 30008000

   Entry Point:  30008040

   Verifying Checksum ... OK

   XIP Kernel Image ... OK

内核启动信息省。。。。

三、固化

      

如果你想把镜像文件写入flash,每次开机后让u-boot帮你复制到sdram中,再使用bootm命令引导的话,可以按照这样操作:

sbc2410=>tftp 0x30008000 zImage.img

TFTP from server 192.168.1.115; our IP address is 192.168.1.128

Filename 'zImage.img'.

Load address: 0x30008000

Loading: #################################################################

        #################################################################

        #################################################################

        ####################################################

done

Bytes transferred = 1263324 (1346dc hex)

sbc2410=>nand erase 0x30000 0x1d0000

NAND erase: device 0 offset 196608, size 1900544 ... OK

sbc2410=>nand write 0x30008000 0x30000 0x1d0000

NAND write: device 0 offset 196608, size 1900544 ...  1900544 bytes written: OK

设置u-boot启动命令:

1、针对方法一:

sbc2410=>setenv bootcmd nand read 0x31000000 0x30000 0x1d0000\;bootm 0x31000000

sbc2410=>saveenv

Saving Environment to NAND...

Erasing Nand...Writing to Nand... done

2、针对方法二:

sbc2410=>setenv bootcmd nand read 0x30008000 0x30000 0x1d0000\;bootm 0x30008000

sbc2410=>saveenv

Saving Environment to NAND...

Erasing Nand...Writing to Nand... done

sbc2410=>reset

启动信息略。。。。

 

posted on 2007-01-12 23:13 lfc 阅读(8246) 评论(7)  编辑 收藏 引用

U-BOOT下使用bootm引导内核 - 云淡风清 - ARM+LINUX学习笔记

# caoyi

U-Boot 1.1.1---- (Apr 2 2007 - 16:59:45)

U-Boot code: 0C700000 -> 0C72135C BSS: -> 0C755CA8

RAM Configuration:

Bank #0: 0c000000 8 MB

Bank #1: 0e000000 8 MB

Flash0: 2 MB

In: serial

Out: serial

Err: serial

Hit any key to stop autoboot: 0

#cy# Booting image at 00050000 ...

#cy# Bad Magic Number

不知道为什么,我按照您的方法做了,还是无法实现bootm自动启动uclinux

我uclinux编译好有三个文件 image.bin linux.rom romfs.img

我是把image.bin文件加入头文件,用您介绍的mkimage的方法。然后下载到flash中或者sdram中,都无法运行

我linux.rom下载到sdram中是可以正常启动的。

如果您方便的话,请指导下,会给点提示。我qq47417879

邮箱 :caoyi41198@sina.com.cn

先谢谢了。  回复  更多评论

  # caoyi

hfrks3c44b0=>bootm 0xc007000

#cy# Booting image at 0c007000 ...

Image Name:

Created: 2007-04-28 3:23:16 UTC

Image Type: ARM Linux Kernel Image (uncompressed)

Data Size: 1464036 Bytes = 1.4 MB

Load Address: 0c008000

Entry Point: 0c008000

Verifying Checksum ... OK

OK

Starting kernel ...

跑到这里就死机了,是不是内核没办法解压啊?

郁闷啊  回复  更多评论

内核为2.6.17版本,u-boot 1.1.4,编译出zImage后,最后转换为uImage,命令如下:#mkimage -A arm -O linux -C gzip -a 0x20008000 -e 0x20008000 -d linux.bin.gz uImage

烧如到FLASH的命令为

u-boot>protec off 100080000 1037ffff

u-boot>erase 10080000 1037ffff

u-boot>tftp 20000000 uImage

u-boot>cp.b 20000000 10080000

reboot后手动bootm 10080000,最后就停在starting kernel.....界面了

如果#mkimage -A arm -O linux -C gzip -a 0x20008000 -e 0x20008040 -d linux.bin.gz uImage生成的uImage,bootm 10080000则在starting kernel.....后不久会重新开始解压(不是重启板子),然后starting kernel.....,如此循环  回复  更多评论

=================================================================================
from:

[求助]u-boot移植到s3c2410的板子,无法启动Linux内核

mic斑竹帮忙给瞧瞧吧
问题如下:
S3C2410的板子,64MB的SDRAM,64MB的Nand Flash
SDRAM地址为0x30000000~0x34000000
u-boot 1.1.4已经移植到板子上,可以正确读写/擦除Nand Flash,可以从Nand Flash启动,网络功能正常,可以使用tftp下载文件。
现有一个2.4.18-rmk7的ARM Linux内核,这个内核是买板子的时候厂家随板子给的,可以正常使用,文件系统也是用厂家给的,是一个11MB大小的cramfs。

u-boot的启动信息如下:
U-Boot 1.1.4 (Feb  7 2007 - 17:17:52)
U-Boot code: 33F80000 -> 33F9C0A4  BSS: -> 33FA018C
RAM Configuration:
Bank #0: 30000000 64 MB
Flash: 512 kB
NAND:  64 MB
*** Warning - bad CRC, using default environment
In:    serial
Out:   serial
Err:   serial
PY2410 #

然后我用tftp下载zImage内核镜像到板子上的0x30008000处,执行go 0x30008000后,串口输出如下:
PY2410 # go 0x30008000

## Starting application at 0x30008000 ...

Uncompressing Linux............................................................... done, booting the kernel.

Error: a

然后就停在这里不动了,只能reset板子

于是我又使用u-boot的mkimage工具做了一个uimage:
#mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 \
> -n 'linux-2.4' -d zImage zImage.img

把生成的zImage.img下载到板子上的0x33000000处,用bootm 0x33000000执行,输出如下:

PY2410 # bootm 0x33000000

## Booting image at 33000000 ...

  Image Name:   linux-2.4
  Created:      2007-02-07   9:21:31 UTC
  Image Type:   ARM Linux Kernel Image (uncompressed)
  Data Size:    882012 Bytes = 861.3 kB
  Load Address: 30008000
  Entry Point:  30008000
  Verifying Checksum ... OK

OK

Starting kernel ...

Uncompressing Linux............................................................... done, booting the kernel.

同样是解压缩之后就没反应了。

内核启动参数是:
bootargs= root=/dev/mtdblock2 load_ramdisk=0 init=/linuxrc console=ttyS0 mem=64M devfs=mount
这个参数也是从厂家给的bootloader上抄下来的
另外加载内核的之前设置了r0=0, r1=193,中断全关,mmu也关了,但不知道怎么回事内核就是起不来。我用nand read命令把板子上的zImage读到SDRAM中运行,也是一样不行。

初学嵌入式,现在特别迷惑,还请mic斑竹指点迷津

infohunter 发表于 2007-2-10 20:16

呵呵,问题已经解决了

jarodwang 发表于 2007-2-11 11:51

第一个使用go命令启动的方法的问题是:
r0 = 0,r1 = machine type,r2 = physical RAM address of params的ARM Linux启动条件没有满足。

第二个使用bootm命令启动的方法的问题是:
一种可能时0x3300 0000这个地址在SDRAM中太“高”了,内核映像文件在解压缩之前可是有2MB多啊;
另一种可能是不能直接使用zImage来制作uImage,而是一定要按照README文件中的步骤用vmlinux来做,即arm-linux-objcopy -> gzip -> mkimage。

[[i] 本帖最后由 jarodwang 于 2007-2-11 12:14 编辑 [/i]]

infohunter 发表于 2007-2-14 12:59

jarodwang兄,你常来LUPA么?

newer_zhk 发表于 2007-4-3 19:48

楼主怎么解决的

和我遇到的问题一样  

还有怎么设置r0 r1 r2寄存器啊

谢谢!

footballxi 发表于 2007-5-29 21:55

请问搂住你的问题最终是如何解决的呢?我也遇到了和你一样的问题不管是uImage和zImage都不行。

greatsnows 发表于 2007-7-11 09:36

怎么解决的?关心答复

zozowit 发表于 2008-1-9 15:42

鄙视这种人,只问问题,得到了答案也不公开

luyun 发表于 2008-1-19 17:18

内核无法启动

我按照网上的说明配置并编译内核,
并按照U boot中readme的方法制作uImage,可是就是无法启动
输出信息如下:

Created:      2008-01-19  5:57:43 UTC
  Image Type:  ARM Linux Kernel Image (gzip compressed)
  Data Size:    1078173 Bytes =  1 MB
  Load Address: 30008000
  Entry Point:  30008040
  Verifying Checksum ... OK
  Uncompressing Kernel Image ... OK
Starting kernel ...

就这些信息
过一会uboot又重启了

U-Boot 1.1.4 (Jan 14 2008 - 16:41:42)
U-Boot code: 33F80000 -> 33FA2540  BSS: -> 33FA6CF0
RAM Configuration:
Bank #0: 30000000 64 MB
Flash:  2 MB
NAND:  64 MB
In:    serial
Out:  serial
Err:  serial
Hit any key to stop autoboot:  0

改了 几次 bootargs 和commandline 总是调不通!!!

[[i] 本帖最后由 luyun 于 2008-1-19 17:19 编辑 [/i]]

mars51 发表于 2008-6-9 14:09

修改内核使u-boot的go命令能够启动内核
找到并打开arch/arm/kernel/head.S文件,直接将s3c2410的参数赋给内核。在如下代码:
__INIT
.type        stext, %function
ENTRY(stext)
后面添加:
mov                r0, #0
mov                r1, #0xc1
ldr                r2, =0x30000100
保存后关闭该文件。

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

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

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

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

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

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

阅读(1332) | 评论(0) | 转发(0) |
0

上一篇:u-boot on smartphone

下一篇:u-boot移植资料

给主人留下些什么吧!~~