Linux From Scratch

Drop in for a chat and a cup of tea

8 posts
by chorlton » Fri Mar 09, 2012 8:27 am
http://www.linuxfromscratch.org/lfs/

Linux From Scratch provides a step-by-step manual for building your own Linux from source code; from the kernel up to a set of base shell and development packages. It looks ideal for learning how Linux hangs together. Possibly too advanced/time-consuming for a school project but certainly educational.

I know I won't get a graphical desktop with a full set of packages ready for download, but I will get a minimal terminal from where I can compile any server software I want.

By default, the manual assumes compiling for Intel 32bit architecture. Would I be setting myself up for a world of pain trying to adapt the instructions for ARM?

Just off the top of my head, I've considered:


  • Compilation will likely be sloooow – but I can kick things off and leave runnig over night.

  • I'll need to work on a USB hard disk to have enough space – which will likely be sloooow

  • I've tried cross-compilation before with mixed success. Do I face a nightmare of trying to determine kernel and compilation options to ensure correct Endian-ness, floating point compatibility, etc?

  • I won't have sound which is fine, but when it comes to actually producing a video signal, will the Linux kernel talk to whatever hardware/driver is on the Pi and "just work"? Scratch that - I can run headless and telnet in from another machine.


Do any of the smart cookies on here have experience of kernel compilation on non-intel architectures?

I'm just looking to guage whether this would be possible for someone with reasonable linux skills, i.e. partitioning, C compilation, shell scripting.

Thanks

Gordon
Posts: 50
Joined: Mon Feb 06, 2012 1:57 pm
by rasbeer » Fri Mar 09, 2012 9:18 am
chorlton said:


http://www.linuxfromscratch.org/lfs/

I'm just looking to guage whether this would be possible for someone with reasonable linux skills, i.e. partitioning, C compilation, shell scripting.


Did you see this:

http://trac.cross-lfs.org/

This also looks relevant:

http://www.pierrox.net/cmsms/o...../clfs.html

I think lack of access to a second - mess-upable without consequences - x86 machine to try LFS on might be discouraging many potential LFSers.

So a good clear RasPi LFS guide might really help get people digging into the guts of Linux. (Assuming there's not some horrible extra complexity that would make the process even more arcane & inaccessible...)
Posts: 242
Joined: Wed Mar 07, 2012 8:35 am
by chorlton » Fri Mar 09, 2012 9:31 am
I know I mentioned cross-compiling but that was just to provide an example of previous experience where I ran into issues with wading through hundred sof kernel parameters trying to decide which applied to ARM. The intention here would be to use the standard Debian or Fedora distro on the Pi as the development environment.

If I give this a try, and I manage to buy a Pi at some point, this is just for my own education at the moment. Although I'm happy to document/screenshot/blog as I go and then possibly edit into a coherent manual as time allows.
Posts: 50
Joined: Mon Feb 06, 2012 1:57 pm
by Jim Manley » Sat Mar 10, 2012 5:26 am
If you're not already aware, the R-Pi GPU actually boots directly from the SD card and a bootloader sets up and kicks off the ARM CPU, where things become more typical for any ARM development.  Rumor has it that the GNU gcc and related tools are not included in the initial Fedora port (not sure about the Debian and ArchLinux ports), which would make it more than difficult to do much building directly on the BCM2835.  I suspect that development on the R-Pi directly is painful enough that all of the developers are cross-compiling and building on PCs and then generating the execution environment that is then loaded and run on the R-Pi.  There's no reason why you couldn't do it, but, keep in mind you have a maximum of 256 MB of RAM, and SD I/O is notoriously slow, especially if you're using cards below the upper levels of performance, like Class 10 (last I heard, no Class 10 cards have been found to work with the R-Pi, yet).

The good news is that everything you need to build should be available from the Foundation (soon?) since several OS teams have now completed ports of their OSes and, by looking at the sources they had to modify to get things working, you should be able to use them as-is, or make very small changes for particular things you might want to do.  Once you've got file I/O and can tell the CPU how to do your bidding, everything else is a SMOP (a Small Matter Of Programming), as the hardware weenies are known to say.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!
User avatar
Posts: 1358
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, USA
by chorlton » Mon Mar 12, 2012 10:02 am
Jim Manley said:


If you're not already aware, the R-Pi GPU actually boots directly from the SD card and a bootloader sets up and kicks off the ARM CPU, where things become more typical for any ARM development...

...There's no reason why you couldn't do it, but, keep in mind you have a maximum of 256 MB of RAM, and SD I/O is notoriously slow, especially if you're using cards below the upper levels of performance, like Class 10 (last I heard, no Class 10 cards have been found to work with the R-Pi, yet).


I'm fully expecting it to be slow, I'm even considering that I may need to use a USB disk for my working area. LFS mentions using 10Gb of working disk space. I'd hoped that once I had a working system on hard-disk, it would be relatively trivial to then transfer to an SD card for booting.

I've previously had a very frustrating experience trying to use buildroot on a Western digital MyBook (ARMv5?) so was going to try avoiding cross-compilation if possible, but that's twice cross-compilation has been mentioned, and I spotted another thread about it, so I will dig further into rasbeer's CLFS link.

Thanks for all the info!
Posts: 50
Joined: Mon Feb 06, 2012 1:57 pm
by rasbeer » Fri Jun 22, 2012 12:19 pm
Just wondering if anyone's gone further down the "[Cross] Linux From Scratch on Raspberry Pi" route in the last few months...
Posts: 242
Joined: Wed Mar 07, 2012 8:35 am
by Mogwai » Thu Jul 26, 2012 7:28 pm
Just started a site dedicated to Linux From Scratch on the Raspberry Pi:
http://www.intestinate.com/pilfs

Enjoy!
Posts: 16
Joined: Thu Jul 26, 2012 4:08 pm
Location: Montreal
by poulecaca » Tue Mar 18, 2014 10:00 am
There is also a young project https://github.com/repk/muslpi that automatically build a clfs for raspberry pi.

This will build a cross compilation toolchain as well as a musl libc clfs.
Posts: 1
Joined: Tue Mar 18, 2014 9:48 am