從u-boot傳bootargs給kernel

1. rebuild u-boot with CONFIG_CMDLINE_TAG defined in include/configs/XXX.h
2. in u-boot:

setenv bootargs xxx=xxx;
Refer to uImage + u-boot的啟動方式 任一方法,用go的不行
setenv flashaddr 10040000;setenv kfile uImage; setenv ramaddr 1500000;tftp $(ramaddr) $(kfile); bootm $(ramaddr);
結果

Star Dorado2 # setenv bootargs xxx=xxx;
Star Dorado2 # setenv flashaddr 10040000;setenv kfile uImage; setenv
ramaddr 1500000;tftp $(ramaddr) $(kfile); bootm $(ramaddr);
config VSC7385
MAC0 PHY Link Status : UP!
INIT VSC8601
VSC8601 Type B Chip
TFTP from server 172.20.5.185; our IP address is 172.20.150.151
Filename 'uImage'.
Load address: 0x1500000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
###################################################
done
Bytes transferred = 1590076 (18433c hex)
## Booting image at 01500000 ...
Image Name: Linux-2.6.16-star
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1590012 Bytes = 1.5 MB
Load Address: 01500000
Entry Point: 01500040
Verifying Checksum ... OK
XIP Kernel Image ... OK

Starting kernel ...

Uncompressing
Linux................................................................................................ done, booting the kernel.
Linux version 2.6.16-star (root@test-laptop) (gcc version 3.4.6) #7 Tue Jun
3 14:41:53 CST 2008
CPU: FA526id(wb) [66015261] revision 1 (ARMv4)
Machine: STAR STR9100
Memory policy: ECC disabled, Data cache writeback
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 2, 16 byte lines, 512 sets
CPU0: D cache: 16384 bytes, associativity 2, 16 byte lines, 512 sets
CPU clock at 250MHz
AHB clock at 125MHz
APB clock at 62MHz
Enable I-ScratchPad Address Start : c002c000
Built 1 zonelists
Kernel command line: xxx=xxx
(..............................................)





转载:非常不错的u-boot ppt
http://blog.chinaunix.net/u/22617/showart_466018.html



bootm命令浅析
http://blog.chinaunix.net/u1/47239/showart_377972.html

http://blog.youkuaiyun.com/menuconfig/archive/2008/04/09/2270429.aspx
http://www.sudu.cn/info/html/edu/linux/20070102/291441.html


使用initrd文件系统 U-boot引导Linux方法
http://linux.chinaitlab.com/administer/753535.html

bootm 0x100000 0x240000
(其中:0x100000是linux内核在flash中的地址,0x240000是initrd在flash中的地
址)

setenv bootargs console=ttyS0,115200n8 root=/dev/ram rw mem=32M
当u-boot使用上面的设置时,能够正常引导linux加载initrd !


http://www.hhcn.com/cgi-bin/topic.cgi?forum=3&topic=735
14.3.5. Linux Kernel Ignores my bootargs

Question:
Why doesn't the kernel use the command-line options I set in the "bootargs"
environment variable in U-Boot when I boot my target system?

Answer:
This problem is typical for ARM systems only. The following discussion is
ARM-centric:

First, check to ensure that you have configured your U-Boot build so that
CONFIG_CMDLINE_TAG is enabled. (Other tags like CONFIG_SETUP_MEMORY_TAGS or
CONFIG_INITRD_TAG may be needed, too.)
This ensures that u-boot will boot
the kernel with a command-line tag that incorporates the kernel options you
set in the "bootargs" environment variable.

If you have the CONFIG_CMDLINE_TAG option configured, the problem is almost
certainly with your kernel build. You have to instruct the kernel to pick up
the boot tags at a certain address
. This is done in the machine descriptor
macros, which are found in the processor start-up C code for your
architecture. For the Intel DBPXA250 "Lubbock" development board, the
machine descriptor macros are located at the bottom of the file
arch/arm/mach-pxa/lubbock.c, and they look like this:

MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform")
MAINTAINER("MontaVista Software Inc.")
BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
FIXUP(fixup_lubbock)
MAPIO(lubbock_map_io)
INITIRQ(lubbock_init_irq)
MACHINE_END

The machine descriptor macros for your machine will be located in a similar
file in your kernel source tree. Having located your machine descriptor
macros, the next step is to find out where U-Boot puts the kernel boot tags
in memory for your architecture
. On the Lubbock, this address turns out to
be the start of physical RAM plus 0x100, or 0xa0000100. Add the
"BOOT_PARAMS" macro with this address to your machine descriptor macros; the
result should look something like this:

MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform")
MAINTAINER("MontaVista Software Inc.")
BOOT_PARAMS(0xa0000100)
BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
FIXUP(fixup_lubbock)
MAPIO(lubbock_map_io)
INITIRQ(lubbock_init_irq)
MACHINE_END

If there is already a BOOT_PARAMS macro in your machine descriptor macros,
modify it so that it has the correct address. Then, rebuild your kernel and
re-install it on your target. Now the kernel should be able to pick up the
kernel options you have set in the "bootargs" environment variable.

### 使用 U-Boot 在 QEMU 中加载 Linux 内核 为了在 QEMU 中使用 U-Boot 加载 Linux 内核,需遵循一系列配置和命令来设置虚拟环境。具体操作如下: #### 准备工作 确保已安装必要的软件包和支持工具。对于基于 Debian 或 Ubuntu 的系统,可以执行以下命令来安装所需依赖项: ```bash sudo apt-essential libncurses5-dev \ libssl-dev texinfo git qemu-system-arm device-tree-compiler wget ``` #### 下载并编译 U-BootLinux 内核 下载最新版本的 U-Boot 源码,并按照官方说明进行编译[^4]: ```bash git clone https://source.codeaurora.org/external/u-boot/u-boot.git cd u-boot make distclean make CROSS_COMPILE=arm-linux-gnueabi- qemuu_armv7_defconfig make CROSS_COMPILE=arm-linux-gnueabi- ``` 同样地,获取适合 ARM 架构的 Linux 内核源码并完成编译过程。 #### 配置 QEMU 参数 当拥有编译好的 U-Boot (`u-boot.bin`) 及压缩后的内核镜像(如 `zImage`),可通过指定这些文件作为参数启动 QEMU 实例。下面是一个典型的命令行示例: ```bash qemu-system-arm -M versatilepb -cpu arm1176 -m 256 -kernel zImage \ -initrd rootfs.cpio.gz -append "console=ttyAMA0,115200" \ -nographic -dtb versatile-pb.dtb -sd sdcard.img \ -drive file=u-boot.bin,if=mtd,readonly ``` 此命令设置了 Versatile PB 板模型、ARM11 CPU 类型以及分配给系统的内存大小;指定了要使用的内核映像及其附加选项;禁用了图形界面输出以便于调试信息显示;还提供了设备树二进制 (DTB) 文件用于描述硬件布局[^1]。 #### 进入 U-Boot 控制台 一旦 QEMU 成功启动并将控制权交给 U-Boot,则会进入交互式的命令提示符处。此时可以根据实际情况调整环境变量以适应特定需求,比如修改 bootargs 字符串来递额外参数给即将启动的操作系统实例。 #### 执行 Boot 命令 最后,在确认所有准备工作无误之后,输入相应的引导指令让 U-Boot 开始加载并运行 Linux 内核。通常情况下只需简单地键入 `boot` 即可触发默认行为,即自动寻找合适的存储介质上的内核映像并尝试将其加载到 RAM 中执行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值