GRUB - Linux Embedded systems

GRUB is the boot loader commonly used in desktop systems, having supplanted LILO in the past few years. GRUB performs the same job as LILO: after the first-stage boot loader has run, GRUB finds a kernel, puts it into memory, and lets the system start.

GRUB divides booting into three stages: 1, 1.5, and 2. The stage 1 boot loader fits into the MBR of the device; its job is to mount the devices necessary to run the stage 2 GRUB boot loader, which reads a configuration file and presents a user interface. The 1.5 boot loader is necessary when the code required to find the stage 2 boot loader doesn’t fit into the 512 bytes of the MBR.

GRUB is controlled by the /boot/grub/menu.lst file stored on the boot partition configured when you install GRUB This file is divided into one section (at the start of the file) with global options and a second section containing a list of kernels to boot. A typical menu.lst file for an embedded system looks like the following:
title Linux
root (hd0,1)
kernel /zImage root=/dev/hda2 ro

The root parameter indicates that the / should be mapped to the device hd0’s first partition. The next line tells the system to get the kernel at /zImage. Because there’s only one entry, grub doesn’t display a menu. This root parameter doesn’t have an effect on the root file system that the kernel eventually mounts; it’s the root file system for the boot loader itself.

The root device format is different than Linux, which can result in confusion. In GRUB, a device has the following format:
(device[bios number][,partition])

Device can be one of the following values: hd for fixed disks, fd for floppy disks, or nd for network drives. The number that follows is the identifier assigned by the computer’s BIOS. You can find this in the BIOS setup for the computer; the assigned numbers start at 0 and work upward. The partition is the logical division of the drive. To find the partitions on a drive, use the sfdisk command:
$ sudo /sbin/sfdisk -l

GRUB allows you to load the kernel from a TFTP server. To do this, you need to configure the IP parameters and use (nd) instead of (hd0,1) as the root device. For example:
ifconfig –address= –server=
kernel (nd)/bzImage

This results in GRUB configuring the adapter to have an IP address of and use the default netmask ( and contact to download the kernel file bzImage via TFTP to boot the system.

About Flash Memory
Flash memory resembles other types of memory in that it’s one large array of bytes. The starting address is at 0 and the ending address is one less than the total number of bytes on the device. In order to make this pool of memory more manageable, the concept of flash partitions was added a few years back; these are analogous to partitions on disk drives. With flash partitions, a small amount of flash is reserved and populated with a start address, length, and name. You can refer to the starting address using a name rather than a hex number; and when partitions change in size or location, code that refers to the names of partitions doesn’t need to change.

The kernel also uses the partition table to manage the flash memory. In Linux, the device used to access flash is /dev/mtdN, where N is the ordinal of the flash partition, starting at 0. The first flash partition is 0, and the number increases for each entry subsequent partition. Memory technology device (MTD) is the generic term for EEPROM storage devices in Linux.

Flash memory comes in two flavors: NOR and NAND. Although the MTD software interface presents a uniform interface to these flavors, they’re very different. The differences between NAND and NOR from a functional perspective are that because NAND memory can’t be read and written in a random manner, each block within a NAND device (where a block is a subdivision of the device’s memory) must be accessed sequentially. On a NAND device, the driver can’t write to byte 5 on block 100 without first writing to bytes 0 through 4. NOR memory also has a different tolerance for errors: the device can have some number of bad blocks that the driver software must be able to work around, as opposed to NOR memory, which is designed to have no bad areas.

When booting, the kernel needs to know what device contains the root file system. If the kernel uses a flash-based root file system, one of these partitions contains the root file system; looking at the flash partition table tells you the location of the root file system so the proper device name can be sent to the kernel.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Linux Embedded systems Topics