Categories
Mobile Technology Toys UNIX

Installing Gentoo Prefix on HP TouchPad

The ill-fated HP TouchPad has, ironically, proven itself to be a gem of a machine for those with a computing/hacking background – with a fast processor, plenty of memory, and the most open architecture of any tablet so far (in that webOS Doctor can be hacked to alter partition layout and contents on restore), there are few limits to what it could be used for. Android (hopefully within a webOS card) is coming, and already Ubuntu & Debian can be run from a chroot() environment. The ARM build of Gentoo can be run in the same way – but that’s relatively trivial and not especially interesting (in that it doesn’t integrate with the OS – you have to specifically enter the chroot() environment in order to make any use of the software).

I would now always choose to run Ubuntu in a desktop environment – Canonical have done a great job of generalising the historically painful job of getting hardware and software reliably working together (try getting Bluetooth HID devices and WPA Wifi working on Linux from first principals if you want a reminder of just how obtuse software can be…), but I’d still opt for Gentoo for a server/command-line environment. This is what we have with the TouchPad – a great visual OS, but a minimalist installed get of command-line tools. This – with it’s ability to build optimised, efficient, and light-weight packages with only the necessary optional features present – is where Gentoo shines.

As a first step, decide whether to install Gentoo into a file (as per Gentoo-founder drobbin’s instructions for a chroot() install at funtoo.org or at the following link), or onto a dedicated ext3 partition – the benefits and drawbacks of each approach are described here. Personally, with Meta Doctor I created a 12GB partition to hold optware, gentoo, gentoo-chroot (for now…) and Ubuntu. I kept swap at 512MB and kept the defaults for other options. Using Meta Doctor can give you Preware pre-installed, which is handy.

With the device freshly partitioned, you’ll want to install Preware (if not already present) and after that Xecutah, Xserver, and Xterm. Launching Xterm from Xecutah gives us a console with full access to the machine. At this point, it may well be worth installing a replacement kernel to allow higher clock-speeds and the optware OpenSSH server so that you can remotely log-in and work from a faster machine with a larger display. In this case, ‘screen’ is invaluable in allowing sessions to be resumed after disconnection. Being able to ssh via Wifi from a laptop into a TouchPad on the inductive-charging stand, all without wires, still feels special 😉

Even if you don’t install OpenSSH, do install at least the optware Command-line installer – we’ll be needing this.

To get a gentoo prefix installation going, we’re going to need a compiler: From Xterm, run:

ipkg-opt update
ipkg-opt install gcc

… to give an initial toolchain. These can be removed once we’re done.

Following the instructions here, commence the Prefix installation process – namely:

export EPREFIX="/media/ext3fs/gentoo"
export PATH="$EPREFIX/usr/bin:$EPREFIX/bin:$EPREFIX/tmp/usr/bin:$EPREFIX/tmp/bin:$PATH"
export CFLAGS="-Os -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -pipe"
export LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--allow-shlib-undefined"

… noting that GCC currently doesn’t support hardware floating-point with NEON SIMD instructions. It might be worth saving this as a script in /media/ext3fs/gentoo.sh so that it can be sourced to set-up the initial environment quickly.

I found that the optware compiler included its own, old, libdl library which was overriding the system libdl yet didn’t work with the system C library – preventing any program from being able to use dlopen() and associated instructions. The fix is a bit of a hack – go into /media/ext3fs/opt/arm-none-linux-gnueabi/lib/ and backup the ‘libdl.so.2’ symlink as ‘libdl.so.2.old’; symlink ‘/lib/liddl-2.8.so’ into the current directory, and finally symlink ‘libdl-2.8.so’ to ‘libdl.so.2’. I also set LD_LIBRARY_PATH and LD_RUN_PATH to “/lib:/usr/lib” but I doubt this is necessary.

Proceed with:

wget http://overlays.gentoo.org/proj/alt/browser/trunk/prefix-overlay/scripts/bootstrap-prefix.sh?format=txt -O /media/ext3fs/bootstrap-prefix.sh && chmod 755 /media/ext3fs/bootstrap-prefix.sh
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo} tree
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp make
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp wget
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp sed
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp coreutils6
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp findutils5
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp tar
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp patch
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp grep
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp gawk
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp bash
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp zlib
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo}/tmp python
/media/ext3fs/bootstrap-prefix.sh ${EPREFIX:-/media/ext3fs/gentoo} portage

… which should all succeed, and result in a working pre-install environment in ‘/media/ext3fs/gentoo/tmp’.

Now commence the installation into the real prefix environment with:

hash -r
emerge --oneshot sed
emerge --oneshot --nodeps byacc
emerge --oneshot --nodeps bash
emerge --oneshot --nodeps xz-utils
emerge --oneshot wget
emerge --oneshot --nodeps baselayout-prefix
emerge --oneshot --nodeps m4
emerge --oneshot --nodeps flex
emerge --oneshot --nodeps bison
emerge --oneshot --nodeps binutils-config
emerge --oneshot --nodeps binutils
emerge --oneshot --nodeps gcc-config
emerge --oneshot --nodeps gcc

… on a TouchPad, this last step may take some time 🙂

Once complete, use ‘ipkg-opt’ to remove any unnecessary packages (such as their broken compiler…).

TBC!

2 replies on “Installing Gentoo Prefix on HP TouchPad”

Leave a Reply