The New Bradford Embedded

Come join me at the new home for Bradford Embedded at BradfordEmbedded.com. After 24 January 2012, there won't be any new posts on the Blogger version.

If you're following me via RSS, you can get the new RSS, too.

Thursday, March 17, 2011

What Is CLFS?

In this week's BeagleCast, my blog post about getting a kernel running on my BeagleBoard-xM with CLFS got a mention. That's cool! But there seemed to be some confusion around what CLFS really is. Let me try to explain, in my own words:

CLFS stands for Cross Linux From Scratch, it's an offshoot of the LFS (Linux From Scratch) project. The goal of both LFS and CLFS is to provide instruction on how to build a Linux system, step by step, from source. In both projects, first a toolchain is built and then a bootable GNU/Linux operating system is built using that toolchain. CLFS differs from LFS in that CLFS builds a GNU/Linux system for an architecture different than the one doing the building. For example, if I have an x86 based computer on my desk that I want to use to build GNU/Linux for a PowerPC system I just bought off eBay, I'd use CLFS rather than LFS.

The methods described by CLFS are very similar to the methods used by OpenEmbedded or Buildroot, but each step is described and there's very little automation. You literally manually build, step by step from upstream source, a toolchain and then a functioning GNU/Linux system. Throughout the books there is information on all the different choices you are required to make. For example: if targeting an ARM processor, when building GCC, you have to choose which ARM version to target, like "armv7-a" for Cortex-A8.

The CLFS project has three different books: Standard, Embedded, and Sysroot. The Standard book is the most developed book and mostly targets people who want to build a cross-compiled system for a desktop computer system. The Embedded book (the one I work on) builds a minimal GNU/Linux system using uClibc targeted at embedded devices where resources may be constrained. The Sysroot book uses a different technique to accomplish similar goals as the Standard book. Both the Standard and Embedded books are under active development, Sysroot hasn't been updated in a while.

Where OpenEmbedded and Buildroot hide a lot of the complexity of building a cross compiled version of GNU/Linux, CLFS hides almost nothing. Think of CLFS as more of a learning experience rather than a quick way to build a cross system. A big advantage of CLFS over an automated system is that errors are usually easy to identify, since everything's done manually you stay at the terminal and you'll probably watch the configure scripts and compiler output. If something doesn't look right, you will have a much better idea of where the problem is, if not what the problem is.

If you'd like to help with the CLFS project, or if you just have questions, come join the IRC channel (#cross-lfs) on Freenode and / or sign up for the clfs-support mailing list.

PS: On Freenode (both in #cross-lfs and #beagle), I'm user "bradfa".