Debian On SD

From Pandora Wiki
Revision as of 12:07, 23 March 2011 by Stuckie (talk | contribs) (Updated to 1.0.2 process.. apologies to Xiloynaha for obliterating changes, I had too many of my own to try and sort out.)
Jump to: navigation, search

Debian On SD

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

This might be a bit iffy just now, I need to go through this and recheck some details.. use at your own risk...

  • 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:
The latest full build is available here:

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

Default User details are:
username: pandora
password: debian

Little Note to Wiki Editors

I change this a lot offline and then plaster the changes on during a new release.
If you're going to go changing this page, please contact me first so I don't accidentally obliterate your changes, or that you do changes to the style I've set out that I don't agree with!
This may well be against the "wiki spirit" .. but I spend days/weeks typing up these changes and testing them.. so a little consideration please :)


Release 1.0

  • First release
  • libts issues
  • libpnd issues
  • Overly fat with stuff
  • Wifi issues for some people

Release 1.0.1

  • First documented release
  • libts issues persist
  • Most libpnd issues fixed
  • Slimmed down to ~830mb
  • Made Wifi issues worse and accidentally stripped out more than needed

Release 1.0.2

  • Replaced libts with evdev... doesn't cause X choking.
  • libpnd should behave now, though the pnd services don't seem to get kicked till a terminal is opened, and even then they turn zombie.. eh?
  • Added full dev setup.. so it's fat.. it's 1.2gig extracted.
  • Replaced GDM with SLIM.

Release 1.1 Proposed

  • libts using OpenPandora patched version.
  • Pandora specifics wrapped as Debian archives.
  • Pandora specifics repo to deal with updates to drivers from mainline.

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, First Boot Scripts 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 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: 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.

Installing LXDE via the above command pulls in GDM by default.. if you use lxde-core instead, it removes a lot of the stuff that pulls in random things, and if you additionally use aptitude install --without-recommends lxde-core it should strip out even more. You will need to manually install less, zenity, and xterm for example. Zenity is especially needed for all the Pandora config scripts.

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 - 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 ~20MB Libraries themselves
wget -c ~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 ./
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/ /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.

After some fiddling, if you stick the following into .xsession it'll actually get called...

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

Of course, this is a bit hacky and hard-coded in that if you've chosen something other than lxde, you'll probably want to change that startlxde to something else!

1.0.2 does something really hacky and actually starts pndnotifyd and pndevmapperd as daemons directly.
It also starts up the xfce4-power-manager for a battery meter.

Should probably copy more over but, this'll do for now.


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.


Current 1.0.2 Release

1.0.2 uses evdev instead of libts for the touchscreen. This doesn't really require any configuration for the most part, but does need to be calibrated.
You'll need a full dev setup on the Pandora for this, as you'll need to compile the xinput_calibrator - however it's fairly trivial once all the libraries are installed.

libts for other releases

Debian apt-get install libxcb-dri2-0 xserver-xorg-input-tslib libts-bin
Debian nano /etc/profile.d/


We'll do the rest of it on First Boot.
This will be fixed properly when WiFi issues settle, so I can finalize a build system and re-do everything as packages - including libts with the OpenPandora-specific patches from the git.


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/ /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...


Debian's bluetooth setup seems to kick in and work without issue.
Probably need to get a clean way to toggle it on and off - as it defaults to being on.

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

Battery Monitor

You'll likely want to know how much battery power you have!
Debian apt-get install apmd
Debian apt-get install xfce4-power-manager
Somewhat cheeky perhaps, but it does work! see this post

If you add xfce4-power-manager & before exec startlxde in your .xsession, it'll start up automatically for you.

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/ /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/ /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, and clean up some stuff.
Debian ln -s /usr/lib/ /usr/lib/ 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.

RC Scripts

We also need to disable some things from running.. the first run script specifies the following:

update-rc.d -f samba remove
update-rc.d -f xinetd remove
update-rc.d -f avahi-daemon remove
update-rc.d -f apmd remove
update-rc.d -f usb-gadget remove
update-rc.d -f banner remove
update-rc.d -f portmap remove
update-rc.d -f mountnfs remove
update-rc.d -f blueprobe remove
update-rc.d -f dropbear remove
update-rc.d -f wl1251-init remove

We'll also need to add some bits to the rc.d script set:


ln -s ../init.d/led-config K05led-config
ln -s ../init.d/pandora-state K31pandora-state
ln -s ../init.d/pndevmapperd-init K40pndevmapperd-init
ln -s ../init.d/pndnotifyd-init K40pndnotify-init 


ln -s ../init.d/led-config K05led-config
ln -s ../init.d/pandora-state K31pandora-state
ln -s ../init.d/pndevmapperd-init K40pndevmapperd-init
ln -s ../init.d/pndnotifyd-init K40pndnotify-init 


ln -s ../init.d/led-config S05led-config


ln -s ../init.d/led-config S05led-config
ln -s ../init.d/pndevmapperd-init S30pndevmapperd-init
ln -s ../init.d/pndnotifyd-init S30pndnotify-init 


ln -s ../init.d/led-config S05led-config


ln -s ../init.d/led-config S05led-config
ln -s ../init.d/pndevmapperd-init S30pndevmapperd-init
ln -s ../init.d/pndnotifyd-init S30pndnotify-init 


ln -s ../init.d/led-config K05led-config
ln -s ../init.d/pandora-state K31pandora-state
ln -s ../init.d/pndevmapperd-init K40pndevmapperd-init
ln -s ../init.d/pndnotifyd-init K40pndnotify-init 


ln -s ../init.d/pandora-state S39pandora-state

We also need to fiddle with a few of the scripts - specifically led-config to add the dummy LSB information ( just rip it out of another script, and leave Required-Start, Required-Stop, Default-Start and Default-Stop empty, ) and pandora-state where you need to blank out the #adjust marker as it causes Debian to have fits.

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 -R <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 wheel group, which we are about to create:
Debian groupadd wheel
There's also few groups you'd want to be in, so we'll do that now.
Debian usermod -a -G wheel <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>
Debian usermod -a -G netdev <username>

Technically, you could've done all this in the one line with adduser, but I'd rather keep it all separate so that if we end up with extra groups, we all know how to add them.

There's a bunch of sudoers rules that are hidden as well that we need to steal ( I completely missed these twice - my thanks to sebt3 and DJWillis for pointing me to them! I thought the #includedir line was commented out due to the # ... *facepalm* )
Angstrom sudo cp /etc/sudoers.d/* /media/mmcblk0p1/etc/sudoers.d/

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

tslib calibration

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.

Finish up installing any left overs

While root ( that's what sudo su does ) we shall finish setting up anything that didn't take during our chroot session in Angstrom ( bluetooth usually )
apt-get -f install
exit - jump back to our user so we don't accidentally mess things up


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.

The following should probably be stuffed into deb files for easier maintainability:

  • libpnd
  • pandora specific scripts
  • SGX drivers
  • kernel
  • modules and firmware

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 ( see below on how to install! )

Common/Fun Things To Do

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


Networking should work effectively the same as on Angstrom, but here's a run down of what to do anyway:

  • Click the LXDE menu up.
  • Click System Tools -> Toggle Wifi
  • Click the Network Manager app between the process bar and the clock.
  • Click your network - or select "Connect to Hidden Wireless Network" if it's not there and fill out the details.
  • Fill out the keyring for your passwords to go into - so you only need to remember the one ;)
  • The Network Manager icon should spin and then give you a strength bar as normal once connected.


The 1.0.1 release did not include Synaptic.. it's back in 1.0.2
To get it back for the 1.0.1 release, it's simply a case of doing:
sudo apt-get update - if you haven't done so for a while ( as in, days, not hours )
sudo apt-get install synaptic
Then wait for a while as it downloads and installs.

You'll find Synaptic under System Tools once it's done.

My PND don't work, why?!

Generally, it'll be because of library differences.. I'm still trying to figure out the best way to deal with this, but you've got the Debian armel repository at your disposal, so you should be fine for a while!

1.0.2 has some library compatibility with Pandora Angstrom but it's not complete. The PNDs of Wesnoth and BattleJewels will work for example, whereas SuperTux and GravityForce do not.

Library compatibility was achieved by pulling packages manually from older revisions, symlinking some libraries and pulling stuff from experimental.. it was trial and error so, is a tad iffy.