Difference between revisions of "Debian On SD"

From Pandora Wiki
Jump to: navigation, search
(Some cleanup, and final bits and pieces left to add to get to the 1.0.1 release.)
Line 3: Line 3:
This is split into three main sections - Building from Scratch, Maintenance and Upgrades, Common Things To Do.
This is split into three main sections - Building from Scratch, Maintenance and Upgrades, Common Things To Do. also see [[Extend Utils]]
* Building From Scratch lets you customise everything from the outset, and lets you create your very own tailor-made distribution, rather than a pre-created one.
* Building From Scratch lets you customise everything from the outset, and lets you create your very own tailor-made distribution, rather than a pre-created one.

Revision as of 21:01, 23 February 2011

Debian On SD


This is split into three main sections - Building from Scratch, Maintenance and Upgrades, Common Things To Do. also see Extend Utils

  • Building From Scratch lets you customise everything from the outset, and lets you create your very own tailor-made distribution, rather than a pre-created one.

It does require a bit of Linux knowledge before diving in.. so if unsure, ask!

  • Maintenance and Upgrades covers standard Debian maintenance if you're not usually a Debian user.

It'll also ( in the future ) cover how to upgrade your pre-built distribution with new drivers as the official OS gets updated.

  • Common/Fun Things To Do will give you ideas on what to try in your new Debian installation.

Remember, this is a full desktop OS you now have squeezed into your hands, and feel free to share your cool ideas!

If you don't want to build from scratch, you have two choices;

The latest minimal is available here: http://www.stuckiegamez.co.uk/apps/pandora/Debian/pandora-debian6.0-minimal.tar.gz
The latest full build is available here: http://www.stuckiegamez.co.uk/apps/pandora/Debian/pandora-squeeze-1.0.tar.bz2

Remember to untar with permissions ( include p in your arguments to tar ) on to your ext2 formatted SD card.

Building From Scratch

This isn't for the feint of heart.. if you don't understand something - stop! Ask or read up on it before continuing. While I haven't mangled my Pandora or PC in any way from doing this, it's still possible to make a mess, so be careful!

This is split into many parts.. it's advised to go through this in order.

  • Getting a Minimal Install from Scratch
  • Desktop Environment
  • Device Drivers and PNDs
  • Users and Permissions
  • Reboot and Troubleshooting

Getting a Minimal Install from Scratch

There are two options here:

  • Linux PC
  • On Pandora

Linux PC

On a Linux PC, run debootstrap to grab the version you want. We shall be using Squeeze today:
sudo debootstrap --arch armel --foreign squeeze /tmp/pandora-debian ftp://ftp.uk.debian.org/debian Grab a large SD card, and repartition it to have one large ext2 partition and format as normal.
Copy all the files from /tmp/pandora-debian over to your new SD card partition.
Put it in your Pandora.
sudo chroot /media/mmcblk0p1 -- assuming it's in your first slot.
/debootstrap/deboostrap --second-stage
... this takes a while...


Alternatively, you can run cdebootstrap on the Pandora itself... this bypasses the need of doing the second-stage madness.
Grab it from here: http://packages.debian.org/sid/cdebootstrap-static and select the armel package.
Download it to /tmp preferably, but your home folder will do, or anywhere you like. For now, I shall assume you downloaded it to /tmp
cd /tmp -- Again, if you downloaded elsewhere, change to that directory instead.
ar xv cdebootstrap*.deb -- We're using the archive tool to extract with verbosity our cdebootstrap package.
sudo tar -zxvf data.tar.gz -C / -- Now we're using tar to extract, with gzip support, again with verbosity, the file data.tar.gz, changing the Current directory to / so that it extracts systemwide on our NAND. We're running this command sudo so we have write permissions.
Now we just run cdebootstrap-static with a few parameters, and wait.
cdebootstrap-static --allow-unauthenticated -f minimal squeeze /media/mmcblk1p1 -- What we're doing here, is we're allowing "unauthenticated" packages to be installed. As we don't, or probably don't, have the gnupg keychain stuff configured, all packaged will be "unauthenticated" regardless of whether they are or not. We're telling it we also want a minimal install of the squeeze release, and to install to where we have the mount point of Partition 1 of the SD card in Slot 1 - which you should have already partitioned and formatted as ext2!
This takes a while... perhaps longer than doing the first stage on the PC and second-stage on Pandora.

Desktop Environment

Now you have Debian, the world is yours for the taking! Or something like that...

Debian comes with a wide variety of desktop environments and window managers; from XFCE as you use on Angstrom by default, to KDE, GNOME, LXDE, Fluxbox, Enlightenment, etc..
Now's the time to choose one of them to install.. be aware that the bigger they are, the longer they'll take to install and the more resources they will eat up while in use.. as a rough guide from heavy to light:

  • KDE
  • Enlightenment
  • XFCE
  • LXDE
  • Fluxbox

Having recently tested KDE myself, it doesn't quite seem to work properly, so I'd avoid that for the moment... especially as it takes about ten hours to install!

We shall install LXDE as it's a bit more light weight than XFCE and still provides a reasonable mainstream environment. While I do prefer Fluxbox overall, it's a bit of a paradigm shift to use from your standard desktop machine.

If you haven't already, chroot into your environment. You should already be root, so we'll get on with the installing.

apt-get install lxde

This may well take an age, so go do something else in the meantime.
You may also want a login manager.. your choices are amongst XDM, GDM, KDM and SLIM to name a few. KDM is perhaps a bit heavy, whereas GDM works fairly well even though it's rather heavy too. SLIM is what you use on Pandora anyway, and XDM is rather basic but usable all the same. GDM is automatically pulled in via LXDE anyway, so we may as well just use that for now.

Once it's done, we'll start tackling the Drivers.

Device Drivers and PNDs

We shall tackle these one at a time, as there's quite a few of them.

  • X Display Driver
  • SGX Drivers
  • Keymap
  • Nubs
  • Touchscreen
  • Wifi
  • Bluetooth
  • Kernel and Misc Bits and Pieces
  • PNDs

X Display Driver

Debian has a NEON-optimised omapfb driver. We shall use this, and pinch some configuration gubbins from Angstrom.

apt-get install xserver-xorg-video-omap3

We now need to create an xorg.conf .. though it'll be rather minimal as we only really want to overload what graphics device setup it has, so:
nano /etc/X11/xorg.conf

Section "Module"
	Load	"extmod"
	Load	"dbe"
	Disable	"glx"
	Disable	"dri"
	Load	"dri2"

Section "ServerLayout"
	Identifier	"DefaultLayout"
	Screen		"Screen0"

Section "Screen"
	Identifier		"Screen0"
	Device			"OMAPFB"
	Monitor			"Monitor0"
	DefaultDepth	16
	SubSection "Display"
		Depth	16
		Modes	"800x480"

Section "Monitor"
	Identifier		"Monitor0"

Section "Device"
	Identifier		"OMAPFB"
	Driver			"omapfb"
	Option			"fb"		"/dev/fb0"

Most of this is pinched from the Angstrom xorg.conf minus the fb Option at the bottom, as our framebuffer has a different device node.

That should be all you need for basic X though.

SGX Drivers

Most of this has been pinched from http://elinux.org/BeagleBoardDebian#SGX_Video_Acceleration - why rewrite the wheel?
This mostly works apart from a few caveats, so I shall repeat it here for future reference and to keep all information in one place, and I've uploaded the resulting tarballs for convenience.

You can either follow the above guide - substituting the BeagleBoard for the Pandora, or use the following preconfigured packages.
cd /tmp
wget -c http://www.stuckiegamez.co.uk/apps/pandora/Debian/GFX_4_00_00_01_libs.tar.gz ~20MB Libraries themselves
wget -c http://www.stuckiegamez.co.uk/apps/pandora/Debian/GFX_Linux_SDK.tar.gz ~220MB Demos and SDK gubbins

Technically, you don't really need that fat 220MB GFX_Linux_SDK tarball unless you really want it, or want to test the libraries are in place.
I'll cover installing both anyway...


tar -zxvf GFX_4_00_00_01_libs.tar.gz
chmod +x ./install-SGX.sh
rm /devmem2_0.0-0ubuntu1_armel.deb - this is particularly useless to us... and why it dumps it at root, I don't know!

That package contains ES2, ES3 and ES5 libraries.. we're only really interested in ES2 ( haven't tried if ES3 or ES5 would even work! ) so:
cd /usr/lib
ln -s ES2.0/* .

Not hugely clean, but it works. For the brave, you could try ES3 or ES5 but.. you're on your own!


cd /tmp
tar -zxvf OGLES.tar.gz
tar -zxvf OGLES2.tar.gz

You can't run anything yet ( well, you might since you've chrooted in via Angstrom ) so we'll leave them in /tmp for the moment - or move them elsewhere - such as /opt if you're worried about Debian wiping out /tmp on boot.


The keymap is fun and comes in two parts - the mapping extension, and an xmodmap script.
We shall steal them from Angstrom.. so open up another Terminal.
As of now, I shall prefix Angstrom commands with Angstrom and Debian commands with Debian so you know which Terminal to type them in.

Angstrom sudo cp /etc/keymap-extension-2.6.map /media/mmcblk0p1/etc - this does assume you've got your SD card mounted in slot one, and with one ext2 partition.. adjust as necessary.
Angstrom sudo cp /etc/skel/.pndXmodmap /media/mmcblk0p1/etc/skel - as above.
Debian nano /etc/skel/.profile
Add the following to the bottom

xmodmap ~/.pndXmodmap
whoami > /tmp/currentuser
killall -1 pndnotifyd &

Should probably copy more over but, this'll do for now.
Need to figure out why .xinitrc isn't even being looked at for some reason.... this works for now though.


The nubs just require some more config stuff to be copied over, and a few rc scripts to be setup right.
Angstrom sudo cp -R /etc/pandora /media/mmcblk0p1/etc
This also copies over configurations for the LCD backlight, some pmenu and mmenu stuff, and some PND configuration bits.

Angstrom sudo cp /etc/init.d/pandora-state /media/mmcblk0p1/etc/init.d - pandora-state restores nubs and backlight settings, as well as saves them on exit.

Configuration utils come in with the PND installation below.


Currently, there's a few issues with the touchscreen - it'll cause X to go mad and chew through 100% CPU as soon as you touch it.
However, it's still usable so we'll add in the libraries and configure it anyway.
Debian apt-get install libxcb-dri2-0 xserver-xorg-input-tslib libts-bin
Debian nano /etc/profile.d/tslib.sh


We'll do the rest of it on First Boot.
There's an evtouch library.. haven't looked at that yet but it may work better?


Wifi is fun... most of it will come in the kernel and modules/firmware pack when we get to it, but there's some ancillary scripts and things that lay in wait to catch you off guard!
Angstrom sudo cp /etc/init.d/wl1251-init /media/mmcblk0p1/etc/init.d
Angstrom sudo cp /lib/udev/rules.d/50-compat_firmware.rules /media/mmcblk0p1/lib/udev/rules.d
Angstrom sudo cp /lib/udev/rules.d/compat_firmware.sh /media/mmcblk0p1/lib/udev/rules.d

The wl1251-init script uses busybox. While you could edit the script and remove the dependency on busybox, it's probably better to just install busybox so that there are less changes to deal with - seeing as it's only about 600kB.
Debian apt-get install busybox

While we don't necessarily need Network Manager, it's a damn sight more easier to use than battering iwconfig et al from the Terminal:
Debian apt-get install network-manager-gnome
This'll take a long time as it pulls in quite a lot of stuff...


Don't really have any bluetooth devices to test.. though I could try tethering my phone by bluetooth...

Kernel and Misc Bits and Pieces

The kernel *should* be easy... grabbing a fresh set would've been advisable, but this doesn't seem to come with everything so we'll steal from our running system again.

Angstrom sudo cp -R /lib/modules/ /media/mmcblk0p1/lib/modules
Angstrom sudo cp -R /lib/firmware /media/mmcblk0p1/lib/firmare
Angstrom sudo cp /boot/uImage /media/mmcblk0p1/boot/uImage

That's essentially the kernel setup... we'll cover the boot script later.

RC Scripts

There's quite a number of RC scripts kicking about.. we'll nick most of them from Angstrom again and deal with them one state at a time.

sudo cp /etc/rc0.d/K05led-config /media/mmcblk0p1/etc/rc0.d/
sudo cp /etc/rc0.d/K31pandora-state /media/mmcblk0p1/etc/rc0.d/
sudo cp /etc/rc0.d/K40pndevmapperd-init /media/mmcblk0p1/etc/rc0.d/
sudo cp /etc/rc0.d/K40pndnotifyd-init /media/mmcblk0p1/etc/rc0.d/
sudo cp /etc/rc1.d/K05led-config /media/mmcblk0p1/etc/rc1.d/
sudo cp /etc/rc1.d/K31pandora-state /media/mmcblk0p1/etc/rc1.d/
sudo cp /etc/rc1.d/K40pndevmapperd-init /media/mmcblk0p1/etc/rc1.d/
sudo cp /etc/rc1.d/K40pndnotifyd-init /media/mmcblk0p1/etc/rc1.d/
sudo cp /etc/rc2.d/S05led-config /media/mmcblk0p1/etc/rc2.d/

oprun-init scripts live here too, but you're probably not going to want them!

sudo cp /etc/rc3.d/S05led-config /media/mmcblk0p1/etc/rc3.d/
sudo cp /etc/rc3.d/S30pndevmapperd-init /media/mmcblk0p1/etc/rc3.d/
sudo cp /etc/rc3.d/S30pndnotifyd-init /media/mmcblk0p1/etc/rc3.d/

oprun-init scripts live here too, but you're probably not going to want them!

sudo cp /etc/rc4.d/S05led-config /media/mmcblk0p1/etc/rc4.d/

oprun-init scripts live here too, but you're probably not going to want them!

sudo cp /etc/rc5.d/S05led-config /media/mmcblk0p1/etc/rc5.d/
sudo cp /etc/rc5.d/S30pndevmapperd-init /media/mmcblk0p1/etc/rc5.d/
sudo cp /etc/rc5.d/S30pndnotifyd-init /media/mmcblk0p1/etc/rc5.d/

oprun-init scripts live here too, but you're probably not going to want them!

sudo cp /etc/rc6.d/K05led-config /media/mmcblk0p1/etc/rc6.d/
sudo cp /etc/rc6.d/K31pandora-state /media/mmcblk0p1/etc/rc6.d/
sudo cp /etc/rc6.d/K40pndevmapperd-init /media/mmcblk0p1/etc/rc6.d/
sudo cp /etc/rc6.d/K40pndnotifyd-init /media/mmcblk0p1/etc/rc6.d/
sudo cp /etc/rcS.d/S39pandora-state /media/mmcblk0p1/etc/rcS.d/

You were expecting led-config again, weren't you!

Battery Monitor

You'll likely want to know how much battery power you have!
Debian apt-get install apmd

Misc Init Scripts and Things

There are a few random init scripts we need for things:
Angstrom sudo cp /etc/init.d/led-config /media/mmcblk0p1/etc/init.d - configure the LEDs properly.
Angstrom sudo cp /etc/init.d/usb-gadget /media/mmcblk0p1/etc/init.d - for initializing the usb gadget device - g_cdc for USB networking, for instance.
Angstrom sudo cp /usr/bin/usb-gadget /media/mmcblk0p1/usr/bin
Angstrom sudo cp /etc/profile.d/op_env.sh /media/mmcblk0p1/etc/profile.d - effectively just tells SDL to use tslib driver Angstrom sudo cp /etc/default/leds /media/mmcblk0p1/etc/default Angstrom sudo cp /etc/default/usb-gadget /media/mmcblk0p1/etc/default

And some more stuff to install in Debian:
Debian apt-get install libnotify-bin


There are some init scripts you need for the PNDs to work. These are:
Angstrom sudo cp /etc/init.d/pndevmapperd-init /media/mmcblk0p1/etc/init.d
Angstrom sudo cp /etc/init.d/pndnotifyd-init /media/mmcblk0p1/etc/init.d
Angstrom sudo cp /usr/bin/pnd* /media/mmcblk0p1/usr/bin - there are a few pnd binaries, these include pnd_info, pnd_run, pndevmapperd and pndnotifyd.
Angstrom sudo cp /usr/lib/libpnd.so.1.0.1 /media/mmcblk0p1/usr/lib - obviously nothing'll work without the pnd libraries!

There are a bunch of scripts and PNDs hiding in /usr/pandora.. we may as well grab them over as well.
Angstrom sudo cp -R /usr/pandora /media/mmcblk0p1/usr

We need to do a symlink to the library properly now..
Debian ln -s /usr/lib/libpnd.so.1.0.1 /usr/lib/libpnd.so.1 Debian rm -rf /usr/pandora/mmenu - these are just PNDs that call the programs installed in Angstrom from MiniMenu. We don't have these programs installed on Debian so, they're useless to us.

Users and Permissions

You may be wondering why Users haven't been done till the very end.. we've edited the /etc/skel setup which will be used to create your user details.

If you have already jumped the gun and created a user previously, all changes we've done to /etc/skel will need to be mirrored in your home folder!

Debian 'adduser <username> - obviously, replace <username> with what you want; for example adduser pandora.

One interesting thing I've noticed happens, is sometimes it'll happily create your user... then not give you full permissions to your own folder.. so let's beat it a bit.
Debian chown <username>:<username> /home/<username> - replacing <username> with your actual username; for example chown pandora:pandora /home/pandora

You'll probably want to use sudo, which will require you to be in the sudo group ( it's wheel on Angstrom. ) Actually, there's a few groups you'd want to be in, so we'll do that now.
Debian usermod -a -G sudo <username> - you know the drill now... example; usermod -a -G wheel pandora
Debian usermod -a -G adm <username>
Debian usermod -a -G audio <username>
Debian usermod -a -G video <username>
Debian usermod -a -G plugdev <username>
Debian usermod -a -G users <username>

Angstrom also uses a netdev group... not sure what creates that or what it's for... ignoring for now.

Finally, /tmp can sometimes go mad so we shall fix that just now too.
Debian chmod a+w /tmp

Reboot and Troubleshooting


We need either an autoboot.txt or a boot.txt now or we won't be able to boot up Debian.
There's no difference between either, other than autoboot will cause the Pandora to automatically boot from SD if it finds it, whereas boot requires holding the right shoulder button as usual.
Debian nano /autoboot.txt - again, you could use boot.txt instead and press the right shoulder button during boot.

setenv bootargs debug root=/dev/mmcblk0p1 rw rootdelay=2 console=ttyS0,115200n8 vram=6272K omapfb.vram=0:3000K
ext2load mmc 0:1 0x80300000 /boot/uImage
bootm 0x80300000

All that's really left now is to reboot and catch any issues that may crop up!

First Boot

First Boot should bring you up to GDM in all it's splendour. But Wait! The touchscreen! IT IS MADNESS!
If you've a USB keyboard, you can be one step ahead and do CTRL+ALT+F1 to jump to a terminal, but we're going to assume just the Pandora so we'll carry on and login.

Once LXDE has finished loading up, press FN+ALT+F2 and type "lxterminal"
sudo su
export TSLIB_TSDEVICE=/dev/input/event5
export TSLIB_CONFFILE=/etc/ts.conf

Touchscreen should behave itself now.


Potential clean-ups that should occur is packaging up the Pandora specific libraries and scripts into .deb files for maintenance purposes if nothing else. We can then either try and get them fed back into Debian, or provide our own Debian repo for Pandora.

Maintenance and Upgrades

Maintenance on Debian is very easy.. it's just a case of running sudo apt-get update && sudo apt-get upgrade from a console, or using Synaptic.

Common/Fun Things To Do

There's a wealth of power at your fingertips with Debian, so place your fun things to do here!