ECE497 Modifying Kernel Command Line Parameters

Revision as of 19:49, 28 April 2011 by Lesterwm (Talk | contribs)

Jump to: navigation, search

The linux kernel is booted with a series of parameters known as the kernel command line. On the BeagleBoard, the uBoot bootloader handles both the booting and the passing of parameters. A typical command line on the BeagleBoard might look something like this:

#console=ttyS2,115200n8 console=tty0 root=/dev/mmcblk0p2 rw rootwait

Modification of the kernel command line is necessary for things like:

ECE497 Static MAC Addresses or

ECE497 Pico Projector

In order to edit the command line, we need to edit a few uBoot files.

Modifying Boot.scr

When uBoot finishes its initilization phase, it looks for a file called boot.scr This is a binary file which is read by uBoot before it loads uImage which allows us to modify environment variables such as 'bootargs' (the kernel command-line) before we boot.


Boot.cmd is the plain text, uncompiled version of boot.scr. A standard BeagleBoard boot.cmd might look like:

if fatload mmc 0 80200000 uImage
\techo ***** Kernel: /dev/mmcblk0p1/uImage *****
echo ***** Kernel: /dev/mtd3 *****
nand read 80200000 280000 400000

echo ***** RootFS: /dev/mmcblk0p2 *****
setenv bootargs 'console=ttyS2,115200n8 console=tty0 ethaddr=01:2b:03:01:23:45 g_ether.host_addr=00:dc:c8:f7:75:05  g_ether.dev_addr=00:dd:dc:eb:6d:f1 root=/dev/mmcblk0p2 rw rootwait'

bootm 80200000 

The key part of this file is the line

setenv bootargs 'console=ttyS2,115200n8 console=tty0 ...'

This is the kernel command line, any additional parameters added on this line will be passed to the kernel when it is booted.

Compiling with mkimage

Once the boot.cmd file has been authored, we need to compile it to produce a boot.scr file. This is done with the mkimage program. On Ubuntu, this program is available through the package 'uboot-mkimage'. It should be similarly available for most distributions.

Once mkimage is installed, you'll want to run it on boot.cmd to create boot.scr:

mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'Execute uImage' -d boot.cmd boot.scr

Replacing the old boot.scr

Once the new boot.scr file has been created, place it in the root directory of the BeagleBoard's SD card (the same directory as uImage).