U-BOOT下使用bootm引导内核方法

原文转自http://linux.chinaunix.net/techdoc/system/2008/09/01/1029296.shtml

 

一、在开始之前先说明一下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 ... 
                
                                                                                                                                                                                                        
方法二、
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
启动信息略。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值