How to boot the board and start Linux

What to Do After Unpacking the Board The best way to assess what is supplied with the board is to plug in the board and get Linux up and running. If you have problems locating what's necessary to boot the board, t...
This article was sent to us by: Scott Larsen at 01232010

1 Software » How to boot the board and start Linux
Bookmark and Share

What to Do After Unpacking the Board

The best way to assess what is supplied with the board is to plug in the board and get Linux up and running. If you have problems locating what's necessary to boot the board, that fact is a good indication of the work that lies ahead. The board contains a guide with important information regarding the physical configuration of the hardware: what the DIP switches do and the location of the serial, video, USB, and other ports. In the trade, this is called a data sheet, leaving you with the impression that it's one page; but it's usually 50 to over 100 pages long. Depending on the board, these ports may not have connectors. The guide also contains information about how the board's serial port is configured: this is important information, because figuring out the communication parameters is a trial and error process otherwise. These guides are usually very well organized.

Have Linux? Boot It!

The easiest way to see what the kernel supports is to boot the board and have it tell you what it supports. To boot Linux, you need to check whether the distribution contains the following in binary form:

• Compiled Linux kernel with an initrd

• Root file system There isn't a dependable way to determine by inspection what these files are, so the documentation is key at this point. Here are some conventions:

• Kernels are frequently in zImage format, so file names have these patterns:

• zFileName

• FileName.zimage

• If the kernel is for an x86 board, it's usually in bzImage format. A bzImage is a compressed image that looks like a x86 boot sector, only it's larger than the boot sector size. It's compressed with gzip, not bzip2, as the bz leads some to believe. Here are the file name patterns:

• bzFileName

• FileName.bzImage

• If the board uses the U-Boot boot loader (the board's manual explains if it does), the kernel is named like the following. A uImage is a zImage with some additional information for the U-Boot boot loader:

• uFileName Copy the kernel file into the /tftpboot directory. This is the default location where the TFTP server looks for files. If this is an x86 using PXE boot, copy the file to the /tftpboot/default directory. The root file system is easier to find. It's usually a compressed tar file. Tar means tape archive and is a holdover from the early days of Unix when it was a tool for creating backups on reel-to-reel media. There are two ways to compress a tar file but several ways to name the file for each compression type. Unlike with the kernel, you can determine if a tar file contains a root file system by inspection. Use the view-contents command to output the list of files in the archive to the console, and use the less pager to look at the contents:

# tar tzf <file> | less

It should contain what looks like the file system on your desktop. It should have the /dev, /etc, /bin, and /sbin directories. If this appears to be the root file system, extract it into the directory exported in the /etc/exports directory. The board now needs to be cabled-up, usually via the serial connector. Start minicom:

# minincom –o

Minicom usually does the right thing by default. Press the spacebar a few times, and the boot loader should appear. Nothing on the display? Make sure the following are correct: 1. Check the cables. Are they securely attached? Is the cable a null modem? A null modem is a cable in which the send and receive lines have been crossed along with the clear-to-send and ready-to-send lines. Two serial ports can be connected with this cable; when data is transmitted by one, it appears as input on the other. The clear-to-send and ready-to-send pins handle flow control, so the machine at the receiving end can ask the sender to wait as it processes data. 2. Working with the right port and settings? Press Ctrl+A, O to open the configuration menu, and select Serial Port Setup. Make sure the serial device is the one that the board is attached to and that flow control is off (although your null modem cable may be configured to handle flow control, it isn't frequently implemented in a boot loader). After updating, select Save as dflt so the changes are stored as the default options. 3. Check the communication speed. Adjust it by pressing Ctrl+A, P. You can choose a few other options: start at the slowest speed and work upward. After you select a speed, press the spacebar a few times to see if that made a difference. 4. Still having problems? Check the cables again, and consult the data sheet. Chances are, you skipped checking everything thoroughly the first time. The communication configuration for the board may also be nonstandard: you may have attached the cable to the wrong port if the board has several serial connectors.

The board should include instructions for using the boot loader and what commands to use to load the kernel into memory and start execution. This is different for every board. You need to know the following, though, no matter what boot loader is being used:

• The IP address of the machine running the TFTP server

• The IP address of the machine running the NFS server, if the board includes a file system suitable for mounting via NFS

• The name of the kernel

• The location of the root file system if it isn't packaged as part of the kernel binary When Linux boots, a few pages of information scroll past. Those diagnostic messages tell you what hardware is discovered, what drivers are loaded, and much more. Chances are, the scroll-back buffer doesn't have enough room for all these messages. Use the following command to retrieve this information for review:

# dmesg | less

The less command results in a nice pager that lets you move forward and backward through the output. I explain critical parts of this output next; other noise output has been clipped. The dmesg command prints the contents of the kernel's ring buffer, which is the accumulated output from printk (the kernel analog to printf) function calls. You can configure the size of this buffer to just a few kilobytes to conserve space. A ring, or circular, buffer is one where capacity is fixed; when it's reached, the data at the start of the buffer is overwritten. This sort of buffer is failsafe in that it can't overflow in exchange for data fidelity. The following tells you when the kernel was built and with what compiler. What appears here is completely under the control of the person building the kernel:

Linux version 2.6.17-rc3 (paul@wren) (gcc version 4.1.0 (CodeSourcery ARM))
   #53 Thu May 4 15:05:18 BST 2006

Then get the CPU information. It's the same data, more or less, that's contained in the /proc/cpuinfo file. After the kernel starts, print out the contents of /proc/cpuinfo to check. The data here isn't read from the chip: the programmer working on the chip-specific parts of the kernel populates a data structure containing this information. As you'll see later, the /proc file system contains information about the system hardware, kernel configuration, and networking information as well as information for all the processes running on the system. The /proc file system isn't really a file system—it's a view into the kernel's data structures structured as a file system. The kernel can be passed parameters by the boot loader. This is done by having the boot loader and kernel agree on an area of memory where the parameters are placed by the boot loader before running the kernel. You can configure the kernel not to accept kernel parameters as well; however, this isn't usually the case, because the parameters let you control some parameters of the boot process that change frequently, like the location of the root file system or console device without a rebuild. You can also compile the kernel with default parameters. The parameters passed in during boot are appended to the ones compiled into the kernel. Being able to see this line make it obvious what the command-line parameters were when the kernel booted.

Kernel command line: console=ttyAMA0

This means the kernel found a valid initramfs image:

CPU: Testing write buffer coherency: ok
   checking if image is initramfs... it is

The initramfs is a file system attached to the kernel that lets the kernel load additional device drivers if necessary. Some embedded systems use the initramfs as the only file system. The kernel always checks to see whether this file system exists and uses it if it does. The kernel, as it's booting, is nice enough to tell you the device names for these ports. The kernel continues being nice by creating these device nodes for you in a little, temporary /dev file system that allows the kernel command line to refer to a console or fixed-storage device node before a /dev file system is properly mounted. This can be a source of confusion if you're learning about embedded Linux, because there are references to device nodes (/dev/something); however, because / hasn't been mounted, how does the kernel interact with a device in an unmounted file system? This kernel has been configured for RAM disks:

RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize

RAM disks are convenient when you have a flash-based file system because the /tmp directory can be mounted to a RAM disk. This reduces wear on the flash memory while increasing performance, because frequent create/delete cycles are slow in flash and many programs store small cache files in /tmp for the purpose of increasing performance. RAM disks waste space if they aren't used in the system. Make a note of this when you're optimizing the kernel for size.

Legal Disclaimer

Our website is not responsible for the information contained by this article. Articleinput.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.

Related Articles

1. Explanation of the Embedded Linux development process
Embedded Linux is a topic with many interdependencies; this article lays out the big points and purposely lacks detail so you can see the big picture without getting dist...

2. Basics to understanding the structure of an embedded Linux system
Anatomy of an Embedded Linux System At runtime, an embedded Linux system contains the following software components: • Boot loader: What gets the ope...

3. The resemblance between the GCC compiler and the kernel in Linux
The GNU Compiler Collection The GCC compiler, like the kernel, is designed for portability. Like all open source programs, GCC is available in source form, and ...

4. Automake and Autoconf discover the state of the target environment
Automake/Autoconf Open source software is designed to be distributed in source code form so that it can be compiled for the target platform. When target platfor...

5. How and where does a software developer get help
Where to Get Help All software developers depend on little helpers, whether visible or invisible. Open Source developers tend to call upon a large number of res...

6. Necessary additional steps to get Linux running
Host Services After the software is installed, some additional configuration steps are necessary to get the packages in running order. This part goes through co...

7. Virtualization and the computer resource sharing
Target Emulation and Virtual Machines Virtualization is a mature technology that lets several operating systems share the physical resources of a machine, such ...

8. Development of hosting code and use of virtualization software
Virtualization Software for x86 Hosts If you're developing code for an x86 host, why bother using virtualization? The host and target are identical, so using vi...

9. Root file system and kernel as parts of a Linux system
Understand the RFS The kernel is only one part of a Linux system. The root file system is a necessary component for a running system and is frequently overlooke...