NSLU2-Linux
view · edit · print · history

Debian.ChangeKernelCommandLine History

Hide minor edits - Show changes to markup

November 09, 2008, at 07:55 PM by john -- apex-env comment
Changed lines 8-9 from:

The Debian apex-nslu2 package includes a utility apex-env which can be used to change the APEX configuration environment in which the kernel command line is stored. However, the Debian etch installer ships with a zero padded copy of the MTD block that contains APEX, but apex-env will not work unless the MTD block is padded with 0xffs.

to:

The Debian apex-nslu2 package includes a utility apex-env which can be used to change the APEX configuration environment in which the kernel command line is stored. However, the Debian etch installer ships with a zero padded copy of the MTD block that contains APEX, but apex-env will not work unless the MTD block is padded with 0xffs. [Update: 9th November 2008, with daily image of Debian apex-env works fine without changing anything in the mtdblock2 partition ]

May 17, 2007, at 05:08 PM by Cedric Boutillier -- added a missing parameter to apex-env to change the kernel command line
Changed line 46 from:
 $ sudo apex-env setenv 'console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug'
to:
 $ sudo apex-env setenv cmdline 'console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug'
May 17, 2007, at 05:06 AM by dumfrac -- Decrease the size of the headings
Changed lines 1-2 from:

How to change the kernel command line used by Debian / NSLU2

to:

How to change the kernel command line used by Debian / NSLU2

Changed lines 6-7 from:

Using apex-env on Debian/NSLU2 (etch)

to:

Using apex-env on Debian/NSLU2 (etch)

Changed lines 54-55 from:

Using apexctl (written by Phil Endecott)

to:

Using apexctl (written by Phil Endecott)

May 17, 2007, at 05:05 AM by dumfrac -- Add some introductory text and spacing lines
Added lines 3-5:

The kernel command line used by a Debian/NSLU2 system is passed to the kernel by the second-stage boot loader, APEX. Two utilities for changing the kernel command line stored in the APEX configuration environment are described on this page. Apart from these two utilities, the command line can also be changed by rebuilding APEX. This option is not described here. Please see CompileApex for information on compiling APEX.


Changed lines 8-9 from:

The kernel command line used by a Debian/NSLU2 system is passed to the kernel by the second-stage boot loader, APEX. The Debian apex-nslu2 package includes a utility apex-env which can be used to change the APEX configuration environment in which the kernel command line is stored. However, the Debian etch installer ships with a zero padded copy of the MTD block that contains APEX, but apex-env will not work unless the MTD block is padded with 0xffs.

to:

The Debian apex-nslu2 package includes a utility apex-env which can be used to change the APEX configuration environment in which the kernel command line is stored. However, the Debian etch installer ships with a zero padded copy of the MTD block that contains APEX, but apex-env will not work unless the MTD block is padded with 0xffs.

Added line 53:

May 14, 2007, at 12:17 PM by dumfrac -- Make instructions more clear.
Added lines 32-33:

to overwrite the existing copy of APEX in the NSLU2 flash.

Changed line 43 from:
 $ sudo apex-env setenv 'console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug rootdelay=5'
to:
 $ sudo apex-env setenv 'console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug'
Added lines 46-47:

You can add any additional kernel options you want to set, e.g. 'rootdelay=10' to the end of the kernel command line.

May 14, 2007, at 12:12 PM by dumfrac -- Fix instructions
Changed line 29 from:
 $ su -c 'cat mtdblock2.bin > /dev/mtdblock2'
to:
 $ su -c 'cat etch-modified-mtdblock2.bin > /dev/mtdblock2'
April 28, 2007, at 04:02 PM by dumfrac -- Suppress a Wiki link
Changed lines 3-4 from:

Using apex-env on NSLU2 (etch)

to:

Using apex-env on Debian/NSLU2 (etch)

April 28, 2007, at 04:02 PM by dumfrac -- Fix the text a little.
Changed lines 48-51 from:

Phil Endecott wrote a utility (apexctl which allows one to edit the APEX configuration environment. His program does not require that the APEX MTD block be padded with 0xffs.

I have written a simple program to read and write the APEX environment variables from linux via the /dev/mtd interface to the flash. Using this it should be possible to make safe one-off changes to the kernel command line etc. as I have previously proposed here. Here's an example of the program:

to:

Phil Endecott wrote a utility (apexctl) which allows one to edit the APEX configuration environment. His program does not require that the APEX MTD block be padded with 0xffs. This program reads and writes the APEX environment variables from Linux via the /dev/mtd interface to the flash. It should be possible to make safe one-off changes to the kernel command line etc. Below are examples of how to use the program.

April 28, 2007, at 03:58 PM by dumfrac -- Try inserting linebreaks in the code blocks
Changed lines 67-68 from:
 # apexctl -d /dev/mtdblock2 -o 0x1c000 printenv cmdline = console=ttyS0,115200 rtc-x1205.probe=0,0x6f  noirqdebug root=/dev/nfs ip=any nfsroot=/nfsroot/%s \
to:
 # apexctl -d /dev/mtdblock2 -o 0x1c000 printenv cmdline = console=ttyS0,115200 rtc-x1205.probe=0,0x6f \ 
noirqdebug root=/dev/nfs ip=any nfsroot=/nfsroot/%s \ \\
Changed line 73 from:
 # /tmp/apexctl -d /dev/mtdblock2 -o 0x1c000 getenv cmdline console=ttyS0,115200 rtc-x1205.probe=0,0x6f \
to:
 # /tmp/apexctl -d /dev/mtdblock2 -o 0x1c000 getenv cmdline console=ttyS0,115200 rtc-x1205.probe=0,0x6f \ \\
Changed lines 82-83 from:
 # /tmp/apexctl -d /dev/mtdblock2 -o 0x1c000 printenv cmdline = console=ttyS0,115200 rtc-x1205.probe=0,0x6f  noirqdebug root=/dev/nfs ip=any nfsroot=/nfsroot/%s \
to:
 # /tmp/apexctl -d /dev/mtdblock2 -o 0x1c000 printenv cmdline = console=ttyS0,115200 rtc-x1205.probe=0,0x6f \ 
noirqdebug root=/dev/nfs ip=any nfsroot=/nfsroot/%s \ \\
April 28, 2007, at 03:53 PM by dumfrac -- Add section on Phil Endecott\'s apexctl program
Added lines 3-4:

Using apex-env on NSLU2 (etch)

Added lines 45-91:

Using apexctl (written by Phil Endecott)

Phil Endecott wrote a utility (apexctl which allows one to edit the APEX configuration environment. His program does not require that the APEX MTD block be padded with 0xffs.

I have written a simple program to read and write the APEX environment variables from linux via the /dev/mtd interface to the flash. Using this it should be possible to make safe one-off changes to the kernel command line etc. as I have previously proposed here. Here's an example of the program:

 # apexctl
 Usage:
 apexctl [options] printenv
 apexctl [options] getenv variable
 (exit status 2 if not found)
 apexctl [options] setenv variable value
 apexctl [options] init
 Options:
 -d device specify /dev/mtd* device containing environment
 -o offset specify offset into device of start of environment
 (in decimal; prefix with 0x for hex)
 # apexctl -d /dev/mtdblock2 -o 0x1c000 printenv cmdline = console=ttyS0,115200 rtc-x1205.probe=0,0x6f  noirqdebug root=/dev/nfs ip=any nfsroot=/nfsroot/%s  startup = copy -s nor:0x1a0000+0x150000 0x00008000; wait 20 Type ^C key to cancel autoboot.; boot
 # /tmp/apexctl -d /dev/mtdblock2 -o 0x1c000 getenv cmdline console=ttyS0,115200 rtc-x1205.probe=0,0x6f  noirqdebug root=/dev/nfs ip=any nfsroot=/nfsroot/%s
 # /tmp/apexctl -d /dev/mtdblock2 -o 0x1c000 setenv foo blah
 # /tmp/apexctl -d /dev/mtdblock2 -o 0x1c000 printenv cmdline = console=ttyS0,115200 rtc-x1205.probe=0,0x6f  noirqdebug root=/dev/nfs ip=any nfsroot=/nfsroot/%s  startup = copy -s nor:0x1a0000+0x150000 0x00008000; wait 20 Type ^C key to cancel autoboot.; boot foo = blah

The source code is here http://svn.chezphil.org/utils/trunk/apexctl.cc. It relies on some library utility stuff from http://svn.chezphil.org/libpbe/trunk/.

If you would like to try this but don't have the necessary tools to compile it, let me know and I can send a binary; it's about 33k.

You may have noticed from the example output above that I have been experimenting with an NFS root filesystem. This is a bit tricky if you don't have an initramfs. I got this working eventually; let me know if you're interested.

April 28, 2007, at 03:52 AM by dumfrac -- Add a wiki link for the NSLU2/Debian FAQ
Changed lines 24-25 from:

To replace the Debian etch APEX copy, download etch-modified-mtdblock2.bin, and copy it to your NSLU2. You may want to make a backup of you current flash at this stage (see the Debian FAQ). Then do

to:

To replace the Debian etch APEX copy, download etch-modified-mtdblock2.bin, and copy it to your NSLU2. You may want to make a backup of you current flash at this stage (see the NSLU2/Debian FAQ). Then do

April 28, 2007, at 03:43 AM by dumfrac -- Update page for apex-env
Changed lines 3-58 from:

The kernel command line used by a Debian / NSLU2 system is passed to it by the second-stage boot loader, APEX.

At some point in the future it should become easy to change the command line that APEX passes. APEX supports environment variables which can be stored somewhere in flash; a program running on the NSLU2 will be able to change the contents of that flash and therefore the kernel command line passed by APEX on subsequent boots. But at present the NSLU2 port of APEX hasn't implemented this flash storage and there is no program for editting it. Instead, for the time being, you need to recompile and re-install APEX with a different kernel command line built in.

Here is how to do that. This assumes that you compile APEX on a PC; you'll need a standard cross-compilation environment (gcc, binutils etc). It is also possible to compile it natively on the NSLU2; that may be simpler but is not described here.

// Download, unpack.
$ wget ftp://ftp.buici.com/pub/apex/apex-1.4.7.tar.gz
$ tar xzf apex-1.4.7.tar.gz
$ cd apex-1.4.7

// APEX uses something like the Linux kernel configuration system.
// This copies the default NSLU2 config to ./.config.
$ make debian-nslu2-arm_config

// Now make the necessary changes:
$ make menuconfig
// change CROSS_COMPILE to arm-linux-gnu-
// change default kernel command line as required

// Build.  Not sure if ARCH=arm is needed.
$ make ARCH=arm

// Now swap the endianness of the binary file.
// Endianness is complex in the NSLU2 boot process!
$ devio '<<apex.bin' >apex_swapped.bin 'xp $$,4'

// We need a prepend a 16-byte header indicating the length of the binary:
$ ls -l apex_swapped.bin 
-rw-r--r-- 1 phil staff 41536 2006-11-25 22:50 apex_swapped.bin
// 41536 dec = A240 hex
$ printf '\x00\x00\xA2\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' > a240hdr.bin
$ cat a240hdr.bin apex_swapped.bin > new_mtd2.bin

// Copy this to the NSLU2:
$ scp new_mtd2.bin slug:/tmp

// On the NSLU2 below here

// APEX is in flash block 2 - look in /proc/mtd

// Sanity check
$ od -x /tmp/new_mtd2.bin
$ od -x /dev/mtdblock2
// Do the first and last bits look vaguely similar?

// Now program it into the flash
# cat /tmp/new_mtd2.bin > /dev/mtdblock2

// Verify:
# cmp /dev/mtdblock2 /tmp/new_mtd2.bin
// Should EOF on /tmp/new_mtd2.bin, since it doesn't occupy the whole region

Now reboot, and see if it works. If you have a serial interface you should see APEX display it just before starting the kernel and the kernel display it shortly afterwards. Once the system has started you can check in /proc/cmdline.

to:

The kernel command line used by a Debian/NSLU2 system is passed to the kernel by the second-stage boot loader, APEX. The Debian apex-nslu2 package includes a utility apex-env which can be used to change the APEX configuration environment in which the kernel command line is stored. However, the Debian etch installer ships with a zero padded copy of the MTD block that contains APEX, but apex-env will not work unless the MTD block is padded with 0xffs.

You can try to regenerate a copy of a 0xff padded /dev/mtdblock2 yourself, and then edit the APEX configuration environment using apex-env, but to make life easier for you, I have created a copy of a 0xff padded APEX MTD block. Replacing the Debian etch APEX with the 0xff padded copy will allow you to use apex-env. Martin Michlmayr is kindly hosting the copy of the MTD block (etch-modified-mtdblock2.bin) on his web site. It contains the following configuration in the APEX environment:

 $ sudo apex-env printenv
 bootaddr *= 0x00008000
 cmdline = console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug rootdelay=10
 cmdline-alt *= console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug
 fis-drv *= nor:0x7e0000+4k
 kernelsrc *= fis://kernel
 kernelsrc-alt *= fis://kernel
 ramdiskaddr *= 0x01000000
 ramdisksrc *= fis://ramdisk
 ramdisksrc-alt *= fis://ramdisk
 startup *= copy -s $kernelsrc $bootaddr; copy -s $ramdisksrc
 $ramdiskaddr; wait 10 Type ^C key to cancel autoboot.; boot

Note The APEX configuration in this file has the rootdelay parameter set to 10 seconds which is required if your root partition is an LVM logical volume or is contained on a RAID system (add reference to appropriate Wiki page). you use this file, you'll be able to use apex-env to set the rootdelay parameter to anything you want (see below).

To replace the Debian etch APEX copy, download etch-modified-mtdblock2.bin, and copy it to your NSLU2. You may want to make a backup of you current flash at this stage (see the Debian FAQ). Then do

 $ su -c 'cat mtdblock2.bin > /dev/mtdblock2'

Check that your APEX configuration matches the one listed above by doing

 $ sudo apex-env printenv

If it does, you should be able to change the kernel command line stored in the APEX configuration environment by by doing

 $ sudo apex-env setenv 'console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug rootdelay=5'

See 'apex-env --help' or 'man apex-env' for more information.

November 25, 2006, at 11:11 PM by Phil Endecott -- Wiki doesn\'t like \"Debian/NSLU2\" - hope spaces fix it. Preview also broken.
Changed lines 1-4 from:

How to change the kernel command line used by NSLU2

The kernel command line used by a NSLU2 system is passed to it by the second-stage boot loader, APEX.

to:

How to change the kernel command line used by Debian / NSLU2

The kernel command line used by a Debian / NSLU2 system is passed to it by the second-stage boot loader, APEX.

November 25, 2006, at 11:09 PM by Phil Endecott -- Create this page
Added lines 1-58:

How to change the kernel command line used by NSLU2

The kernel command line used by a NSLU2 system is passed to it by the second-stage boot loader, APEX.

At some point in the future it should become easy to change the command line that APEX passes. APEX supports environment variables which can be stored somewhere in flash; a program running on the NSLU2 will be able to change the contents of that flash and therefore the kernel command line passed by APEX on subsequent boots. But at present the NSLU2 port of APEX hasn't implemented this flash storage and there is no program for editting it. Instead, for the time being, you need to recompile and re-install APEX with a different kernel command line built in.

Here is how to do that. This assumes that you compile APEX on a PC; you'll need a standard cross-compilation environment (gcc, binutils etc). It is also possible to compile it natively on the NSLU2; that may be simpler but is not described here.

// Download, unpack.
$ wget ftp://ftp.buici.com/pub/apex/apex-1.4.7.tar.gz
$ tar xzf apex-1.4.7.tar.gz
$ cd apex-1.4.7

// APEX uses something like the Linux kernel configuration system.
// This copies the default NSLU2 config to ./.config.
$ make debian-nslu2-arm_config

// Now make the necessary changes:
$ make menuconfig
// change CROSS_COMPILE to arm-linux-gnu-
// change default kernel command line as required

// Build.  Not sure if ARCH=arm is needed.
$ make ARCH=arm

// Now swap the endianness of the binary file.
// Endianness is complex in the NSLU2 boot process!
$ devio '<<apex.bin' >apex_swapped.bin 'xp $$,4'

// We need a prepend a 16-byte header indicating the length of the binary:
$ ls -l apex_swapped.bin 
-rw-r--r-- 1 phil staff 41536 2006-11-25 22:50 apex_swapped.bin
// 41536 dec = A240 hex
$ printf '\x00\x00\xA2\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' > a240hdr.bin
$ cat a240hdr.bin apex_swapped.bin > new_mtd2.bin

// Copy this to the NSLU2:
$ scp new_mtd2.bin slug:/tmp

// On the NSLU2 below here

// APEX is in flash block 2 - look in /proc/mtd

// Sanity check
$ od -x /tmp/new_mtd2.bin
$ od -x /dev/mtdblock2
// Do the first and last bits look vaguely similar?

// Now program it into the flash
# cat /tmp/new_mtd2.bin > /dev/mtdblock2

// Verify:
# cmp /dev/mtdblock2 /tmp/new_mtd2.bin
// Should EOF on /tmp/new_mtd2.bin, since it doesn't occupy the whole region

Now reboot, and see if it works. If you have a serial interface you should see APEX display it just before starting the kernel and the kernel display it shortly afterwards. Once the system has started you can check in /proc/cmdline.

view · edit · print · history · Last edited by john.
Based on work by Cedric Boutillier, dumfrac, and Phil Endecott.
Originally by Phil Endecott.
Page last modified on November 09, 2008, at 07:55 PM