Skip to main content

Build an embedded Linux distro from scratch

Peter Seebach, Freelance author, Plethora.net
Peter Seebach
Peter Seebach has been collecting video game consoles for years, but has only been running Linux on them recently. He is still not sure whether this is a Linux machine that plays video games, or a game machine that runs Linux.

Summary:  Learn how to build a custom Linux® distribution to use in an embedded environment, in this case to drive a Technologic Systems TS-7800 single-board computer. In this tutorial, you learn about cross-compiling, the boot loader, file systems, the root file system, disk images, and the boot process, all with respect to the decisions you make as you're building the system and creating the distribution.

Date:  12 Aug 2008
Level:  Intermediate PDF:  A4 and Letter (86 KB | 21 pages)Get Adobe® Reader®

Comments:  

Building the kernel

Downloading the source

Download Technologic's Linux source and TS-7800 configuration files and unzip them in a suitable location.

Kernel configuration

A complete discussion of kernel configuration is beyond the scope of this tutorial. In this case, the ts7800_defconfig target gave me a default usable configuration for the 7800, with one small hiccup: the CONFIG_DMA_ENGINE setting ended up off when it should have been on.

Tweaking the kernel

It is usually best to edit the kernel using make menuconfig, which offers a semi-graphical interface to kernel configuration. This interface is navigated using arrow keys to move the cursor, the Tab key to select options from the bottom of the screen, and the space or Enter keys to select options. For instance, to exit without changing anything, press Tab until the <Exit> at the bottom of the screen is highlighted, then press Enter. Running make menuconfig again reopens the editor.

Changing the default console

The TS-7800 normally boots silently, because the default kernel configuration specifies a null console device to keep the display quiet. To change this, use the arrow keys to navigate down to "Boot options," and press Enter. The third line shows the default kernel options, which select the ramdisk, the startup script, and the console. Use the arrow keys to navigate down to this line, press Enter, and change console none to console ttyS0,115200. Then, press Tab to move the cursor to the <Ok> at the bottom of the panel, and press Enter. Now press Tab to select <Exit> and press Enter, bringing you back to the main menu.

For the goal of booting as fast as possible, the console device isn't useful, and indeed, even at a high baud rate, sending kernel messages can take a noticeable fraction of the time the system takes to boot. For debugging and playing around, though, you want the console.

Enabling the DMA engine

Navigate down to "Device drivers" and press Enter. This list is longer than the usual display, so you will have to scroll down to the very end to reach the option for "DMA Engines." Navigate to that with the arrow keys, and press Enter. There are two options at the top of this page that have square brackets indicating a boolean option. The second, "Support for DMA engines," was not enabled by default in the download I started with. Navigate to it with the arrow keys, and press space to toggle its state. Now use Tab and Enter to select <Exit> from each screen to navigate out to the top level of the program, and then <Exit> one more time to leave the program. When asked whether you wish to save your new kernel configuration, tab to <Yes> and press Enter.

Compiling the kernel

Type make. Yes, it really is that simple. This builds a kernel, as well as a collection of modules. Once again, multi-core users might want multiple jobs; try make -j 5. For the purposes of this project, I'm going to ignore kernel modules, and favor compiling-in any needed features. The bootstrap ramdisk technique used to get needed drivers into the kernel early seems excessive, and building a root file system is already complicated enough. This, of course, brings up the question of how to get a kernel booting, the subject of the next section.

4 of 12 | Previous | Next

Comments



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=330452
TutorialTitle=Build an embedded Linux distro from scratch
publish-date=08122008
author1-email=developerworks@seebs.plethora.net
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).