U-BOOT下使用bootm引导内核方法
注:
  u-boot 使用的是打上:
http://www.hhcn.com/cgi-bin/topic.cgi?forum=3&topic=651&show=0
上keety大侠提供的补丁生成的u-boot-1.1.3

这段时间不断有人问我u-boot启动内核的问题,记得在上次提供的u-boot源码中提到了go的方案,不过其实u-boot本来有一种更好的方案: bootm
花了不少时间,查看了论坛上不少的帖子,认真阅读了bootm的源码,终于使用bootm把内核给跑起来了, 现把解决方法介绍如下:

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

1、首先说明一下,S3C2410架构下的bootm只对sdram中的内核镜像文件进行操作(好像AT91架构提供了一段从flash复制内核镜像的代码,不过针对s3c2410架构就没有这段代码,虽然可以在u-boot下添加这段代码,不过好像这个用处不大),所以请确保你的内核镜像下载到sdram中,或者在bootcmd下把flash中的内核镜像复制到sdram中。
2、-a参数后是内核的运行地址,-e参数后是入口地址。
3、
1)如果我们没用mkp_w_picpath对内核进行处理的话,那直接把内核下载到0x30008000再运行就行,内核会自解压运行(不过内核运行需要一个tag来传递参数,而这个tag建议是由bootloader提供的,在u-boot下默认是由bootm命令建立的)。
 
2)如果使用mkp_w_picpath生成内核镜像文件的话,会在内核的前头加上了64byte的信息,供建立tag之用。bootm命令会首先判断bootm xxxx 这个指定的地址xxxx是否与-a指定的加载地址相同。
(1)如果不同的话会从这个地址开始提取出这个64byte的头部,对其进行分析,然后把去掉头部的内核复制到-a指定的load地址中去运行之
(2)如果相同的话那就让其原封不同的放在那,但-e指定的入口地址会推后64byte,以跳过这64byte的头部。

二、好,接着介绍使用mkp_w_picpath生成镜像文件并下载运行的方法。
方法一、
1、首先,用u-boot/tools/mkp_w_picpath这个工具为你的内核加上u-boot引导所需要的文件头,具体做法如下:
[root@localhost tftpboot]#mkp_w_picpath -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 p_w_picpath type to 'type'
        -C ==> set compression type 'comp'
        -a ==> set load address to 'addr' (hex)
        -e ==> set entry point to 'ep' (hex)
        -n ==> set p_w_picpath name to 'name'
        -d ==> use p_w_picpath 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 p_w_picpath 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/mkp_w_picpath这个工具为你的内核加上u-boot引导所需要的文件头,具体做法如下:
[root@localhost tftpboot]#mkp_w_picpath -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 p_w_picpath 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
启动信息略。。。。

转载于:https://blog.51cto.com/herojames/264170

U-BOOT下使用bootm引导内核方法相关推荐

  1. Centos7多内核情况下修改默认启动内核方法

    1.1  进入grub.cfg配置文件存放目录/boot/grub2/并备份grub.cfg配置文件 [root@linux-node1 ~]# cd /boot/grub2/ [root@linux ...

  2. 嵌入式linux加载引导内核和根文件系统的方法

    总体来说,嵌入式Linux内核和根文件的引导与PC机差不多. 嵌入式linux内核和根文件系统可以存放在各种可能的存储设备中,一般情况下我 们将内核和根文件系统直接烧入到Flash中(包括NOR和NA ...

  3. Windows10 Ubuntu18.04 双系统下修复GRUB引导(亲测当boot-repair工具无效时,该方法完美解决)

    Windows10 Ubuntu18.04 双系统下修复GRUB引导(亲测当boot-repair工具无效时,该方法完美解决) 0.准备条件 1.问题描述: 2.修复Ubuntu18.04的引导 0. ...

  4. mini2440 uboot使用nfs方式引导内核,文件系统

    mini2440 uboot使用nfs方式引导内核,文件系统 成于坚持,败于止步 看了一段时间的u-boot了,到今天才真正完全实现u-boot引导内核和文件系统,顺利开机,在此记录完整过程 1.首先 ...

  5. u-boot-2011.06在基于s3c2440开发板的移植之引导内核与加载根文件系统

    http://www.linuxidc.com/Linux/2012-09/70510.htm  来源:Linux社区  作者:赵春江 uboot最主要的功能就是能够引导内核启动.本文就介绍如何实现该 ...

  6. tiny4412 uboot 2020.10版本移植(四)——uboot修改支持sd卡、eMMC引导内核及其他一些杂项设置

    本文在<tiny4412 uboot 2020.10版本移植(三)--uboot初步启动> 的基础上继续向tiny4412 uboot 2020.10版添加功能. 主要有三块内容:1. D ...

  7. 巧妙恢复 /boot 下的文件

    前言 /boot目录是一个系统启动最重要的目录,系统在上电自检MBR引导之后,系统就要读取/boot目 录下的文件.详细的内容见:http://vinsent.blog.51cto.com/13116 ...

  8. Linux与Windows双系统下的Grub引导管理器安装。

    转载自品略图书馆 http://www.pinlue.com/article/2020/04/0710/1410126301133.html 大多数人日常工作所用的系统是Windows,如果想尝试或者 ...

  9. 一种微型计算机实现多重引导的方法

    [摘要] 具体描述了在一台富士通 FMV-253L 笔记本上安装 RedHat Linux 9.0 的方案,这一方案不仅因为硬件条件的限制需要采用 Linux 的本地硬盘安装,而且要保证不能破坏原有的 ...

最新文章

  1. 技术不够时间来凑,梦圆国一永不放弃
  2. 虚拟机中docker安装mysql远程无法访问解决方法
  3. BZOJ 3740. 【TJOI2014】电源插排
  4. VTK:几何对象演示用法实战
  5. Hive belline提交命令Error: org.apache.thrift.transport.TTransportException: java.net.SocketException:
  6. FCPX插件:科幻切割分屏转场效果XEffects Tech Transitions mac版
  7. Mysql-savepoint
  8. 微胖女孩穿什么样的衣服好看?
  9. 有人问我,一个人创业需要什么技能?
  10. JQ实现标签栏切换效果、导航栏下滑效果以及动画队列和stop()方法
  11. 液晶显示器模拟接口时,屏幕重影照片
  12. 电脑里面英文系统的中文简介
  13. 学会了手工计算开平方
  14. Redis实战篇一 (短信登录)
  15. 必读论文|信息检索与推荐必读论文10篇
  16. C/C++班主任管家系统
  17. iOS-微信支付总结
  18. 计算机组成原理与汇编语言资源分享
  19. airflow重启出现Error: Already running on PID 8254 (or pid file '/root/airflow/airflow-webserver.pid' is
  20. python架构师是做什么的_架构师成长之路(1)--什么是架构师

热门文章

  1. PLUICameraViewController 拍照页面崩溃
  2. C# 检测文件是否被其他进程占用
  3. 支付宝app支付总结
  4. 网络带宽与传输性能的基本计算方法
  5. 如何低价坐飞机头等舱
  6. 黑马程序员---基础加强-----------------第二天(新特性:注解、泛型)
  7. flex4实现图片的动态切换
  8. Dynamics Ax 2012 – AIF Import CSV File
  9. 与基础事务管理器通讯失败
  10. 第三课 查询指定id的单个对象