Raspberry Pi is not a pc :) And neither does BBB or Olinuxino
May 14, 2013
OK so this is not a rant or maybe it is but here we go.
Raspberry PI is not your common PC (and this applies to all little ARM based boards popping up lately).
Try running a fullfleged linux distro on it and it will crawl to a slow moving beast, and by fullfleged Linux distro I do mean all those things like Raspbian, Archlinuxarm etc. These things are just normal distros recompiled for ARM.
What I mean by this is that they still use the exact same components as the X86 counterparts. Maybe Arch is more lightweight in the beginning but once you start adding stuff it get's bigger due to dependencies that no one really optimizes for an embedded system.
Here is an example which probably applyes to all of them:
- you want to install Midnight Commander for example
- you do apt-get or pacman ... install mc
- it starts pulling dependencies in as mc is compiled with all the options enabled
- so you probaly get slang, ncurses, Xlibs and some others depending on the distro
Bottom line: these libs take space on you SD card, and more so they eat precious memory *you just don't have!* ... nevermind the time it takes to read the libraries from the SD into the memory when starting up a program that actually needs them.
Bottom line 2: All these Linux distros are compiled against the huge thing called libc which is the C library used by most Linux programs. This in turn eats you precious memory and adds slowness to the system.
So given the things above how would you imagine they manage to get Linux running on all those devices like routers with 16 - 32 Mb of RAM and 4 Mb of storage, on those so called smart TV's?
Well long before the Pi was even tought of, people needed to be able to run the kernel and a very light user space on things so developers came up with some very cool projects:
First was uClibc http://www.uclibc.org/ which is a very small C libary that kind of emulates the good old libc used on bigger systems. Nowadays most POSIX compliant Linux software can be compiled against it ... yes even the huge thing called WebKit.
Second they needed userspace utils like bash so they decided to create busybox http://busybox.net/ which is a one binary to rule them all type of thing ... So you get lots of things like sh, ls, mount ... etc out of one single binary :) Cool right?
Once the two above were done they basically could build up a pretty functional but basic Linux distro that would need very low storage space ... think of about 4Mb with all bells and whistles :D
Of course in order to run your own cool special program on it you would need to create the root filesystem image from scratch, get your source to compile against uclibc, and integrate all of it.
So the uclibc and busybox guys decided they need something that would allow this to be done in a nicer way so they developed a set of scripts called Buildroot http://buildroot.uclibc.org/ . Now this is the real cool stuff :)
Buildroot makes use of bothe uclibc and busybox to allow *you* user to create your own little Linux distro. It allows you to add just the thing you need, select the init system you think you need, select the kernel you want. YOU are the master.
Now back to the Pi some guys are really at hard work creating custom Buildroot trees for Pi in special and here are two github repos I used so far:
I would recommend to start up with the first as it does not need to compile the whole toolchain it just uses a precompiled one from Linaro so it saves you some time.
I will not go into details on how to use buildroot to build your distro as it does require lots of experience and both of the links above have instructions on how to use them, but just to give you an idea both the systems running on the tank and on the geekbell I posted here are build in this way.
The tank sytem runs in about 25Mb of RAM and uses about 200Mb of storage whithout any clean up. It boots in under 30 seconds to SSH prompt. Now compare that to Raspbian ;)
But it all comes at a cost:
- there is no package manger - you need to add something new - recompile, reflash SD
- the init system (whatever of them you decide on) is very basic - so for some stuff you need to add your own init scripts
- wifi is a pain - there is no clever script to help you out configuring it it''s all done manually with wpa_supplicant or write your own clever script
- and probably more stuff I can't see because I'm used to it :)
So this is what Embedded Linux is all about and if you ask me this is what should be used on those boards in the end.
Just wanted to share another way to do it ... have fun hacking :)