You are here

Booting The Linux Kernel Interactively from U-Boot

The U-Boot environment variable "bootargs" is used to hold the list of parameter options passed to the Linux kernel, as the kernel's command line parameters. (See "Documentation/kernel-parameters.txt" in the Linux source directory for details.)

Typically the required set of kernel parameters are:

  • Console settings
  • Memory organisation
  • Location of root file system

Optionally, the following parameters may also be set:

  • Ethernet configuration
  • Flash MTD partition configuration
  • Co-processor memory allocation

Booting The Linux Kernel With A NFS Root Filesystem

This example shows how to setup U-Boot, to boot a linux kernel (resident in flash) with an NFS mounted root filesystem. It is assumed that all the network parameters for U-Boot (that is: "ipaddr", "serverip", "gatewayip", "netmask" and "ethaddr") are still correct for linux, and were appropriately setup as per the example in Network Setup. This example will use eth0, with /dev/ttyAS0 as the serial console device, with 128MiB of memory.

MB618> setenv hostname my-target
MB618> setenv ip ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:eth0:off
MB618> setenv nfsroot nfsroot=/opt/STM/STLinux-2.3/devkit/sh4/target
MB618> setenv nfsroot ${nfsroot},nfsvers=2,rsize=4096,wsize=8192,tcp
MB618> setenv nwhwconf nwhwconf=device:eth0,hwaddr:${ethaddr}
MB618> setenv bootargs console=ttyAS0,115200 mem=128M
MB618> setenv bootargs ${bootargs} ${ip} ${nwhwconf}
MB618> setenv bootargs ${bootargs} rw root=/dev/nfs ${nfsroot}
MB618> saveenv
Saving Environment to Flash...
Unprotecting Flash...
. done
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash...
........ done
Protecting Flash...
. done
Protected 1 sectors

Once the linux command-line parameters are safely saved to non-volatile storage, then the kernel may be booted from flash, and U-Boot will automatically pass the contents of the expanded environment variable "bootargs" to the kernel. This expansion takes place just before control is passed from U-Boot to linux. So, if the kernel is stored in flash at an address of 0xA0060000, then the following is sufficient to boot it.

MB618> bootm A0060000
## Booting image at a0060000 ...
   Image Name:   Linux-2.6.23.17_stm23_0117-mb618
   Image Type:   SuperH Linux Kernel Image (gzip compressed)
   Data Size:    1845268 Bytes =   1.8 MiB
   Load Address: 8c001000
   Entry Point:  8c002000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
 
Starting kernel console=ttyAS0,115200 mem=128M ip=164.129.15.15:164.129.15.56:0.0.0.0:255.255.248.0:my-target:eth0:off nwhwconf=device:eth0,hwaddr:AA:00:04:00:0F:0F rw root=/dev/nfs nfsroot=/opt/STM/STLinux-2.3/devkit/sh4/target,nfsvers=2,rsize=4096,wsize=8192,tcp - 0x00000000 - 0 ...
 
Linux version 2.6.23.17_stm23_0117-mb618-mb618 (products@macaroni.bri.st.com) (gcc version 4.2.4 (snapshot) (STMicroelectronics/Linux Base 4.2.4-42)) #1 PREEMPT Tue Oct 21 00:43:26 BST 2008
 
... (rest omitted)

Booting The Linux Kernel With A Hard Disk Root Filesystem

It is also possible to boot linux with a partition on a hard disk drive as the target's root filesystem. Thus a partition on an IDE (PATA or SATA) disk can be used instead of NFS as the root filesystem. In this case, all the necessary files required by the target system will need to be copied into the partition beforehand.

MB618> setenv rootpart sda1
MB618> setenv bootargs console=ttyAS0,115200 mem=128M
MB618> setenv bootargs ${bootargs} ro root=/dev/${rootpart}
MB618> saveenv
... (omitted)
MB618> bootm A0060000
... (omitted)

Booting The Linux Kernel With A RAM Disk Root Filesystem

It is also possible to boot linux with a ramdisk as the target's root filesystem. This requires a special ramdisk image, with all the necessary files required by the target system to be created, and then also burned in to flash beforehand. See Creating The RAM Disk Image for details on how to do this.

In order to use a ramdisk, U-Boot must copy both the ramdisk image from flash to RAM; as well as copying the linux kernel image from flash to RAM. Hence the "bootm" command requires 2 parameters to be used when using a ramdisk image:

  1. Address of the linux image in FLASH
  2. Address of the ramdisk image in FLASH
MB618> setenv bootargs console=ttyAS0,115200 mem=128M
MB618> setenv bootargs ${bootargs} rw root=/dev/ram0 ramdisk_size=16384
MB618> saveenv
Saving Environment to Flash...
Unprotecting Flash...
. done
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash...
........ done
Protecting Flash...
. done
Protected 1 sectors
MB618> bootm A0060000 A0300000
## Booting image at a0060000 ...
   Image Name:   Linux-2.6.23.17_stm23_0117-mb618
   Image Type:   SuperH Linux Kernel Image (gzip compressed)
   Data Size:    1845268 Bytes =   1.8 MiB
   Load Address: 8c001000
   Entry Point:  8c002000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
   Image Name:   ST40 Linux ramdisk
   Image Type:   SuperH Linux RAMDisk Image (gzip compressed)
   Data Size:    4739544 Bytes =   4.5 MiB
   Load Address: 8c800000
   Entry Point:  8c800000
   Verifying Checksum ... OK
   Loading Ramdisk to 8cb7a000, length 004851d8 ... OK
 
Starting kernel console=ttyAS0,115200 mem=128M rw root=/dev/ram0 ramdisk_size=16384 - 0x00b7a000 - 4739544 ...
 
Linux version 2.6.23.17_stm23_0117-mb618-mb618 (products@macaroni.bri.st.com) (gcc version 4.2.4 (snapshot) (STMicroelectronics/Linux Base 4.2.4-42)) #1 PREEMPT Tue Oct 21 00:43:26 BST 2008
 
... (rest omitted)

Booting The Linux Kernel Image On Reset

On reset, U-Boot automatically runs the script held in the environment variable "bootcmd". This allows for any number of actions to be performed by U-Boot, before ultimately booting the kernel. To boot the kernel image already saved in flash, automatically, then set "bootcmd" as follows:

MB618> setenv bootcmd bootm A0060000
MB618> saveenv
... (omitted)
MB618> reset
... (omitted)
target# reboot
... (omitted)

Adding A Delay Prior To Booting (Stopping The Boot Process)

It is also possible to enable a timed delay, prior to executing the "bootcmd" command, to give a user a chance to halt the boot process. The "bootdelay" environment variable (if set) contains the number of seconds to delay. See "doc/README.autoboot" for more details on the "autoboot" options.

MB618> setenv bootdelay 10
MB618> saveenv
... (omitted)
MB618> reset
... (omitted)

Speeding Up The Boot Process

For ST40 targets, in 29-bit mode (SE=0), you can speed up the boot from flash times by providing a P1 (cachable) address, instead of a P2 (uncachable) address for the location of the kernel (and ramdisk) images in flash. The caches are enabled when U-Boot copies the images from flash into SDRAM, so by using cachable addresses, there will be a performance improvement. See ST40 Memory for further information on the cacheability of memory for the ST40.

To convert an uncachable P2 address to a cachable P1 address then, use the following ("C") expression:

P1 = (P2 & 0x1fffffff) | 0x80000000;

For the above examples, then the following will be logically identical, but faster, in a 29-bit system:

MB618> bootm 80060000
## Booting image at 80060000 ...
   Image Name:   Linux-2.6.23.17_stm23_0117-mb618
   Image Type:   SuperH Linux Kernel Image (gzip compressed)
   Data Size:    1845268 Bytes =   1.8 MiB
   Load Address: 8c001000
   Entry Point:  8c002000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
 
... (rest omitted)