2011-05-31

Mount Xoom/Android filesystem while in debug mode under gentoo

Step 1: Create a local overlay if you don't have one.
(if you already have one, skip to step 2)
mkdir -p /usr/local/portage/myoverlay

in /etc/make.conf:
source /var/lib/layman/make.conf # should be there already from layman
PORTDIR_OVERLAY="/usr/local/portage/myoverlay $PORTDIR_OVERLAY"
... if you have layman installed or :
PORTDIR_OVERLAY="/usr/local/portage/myoverlay"


Step 2: Put this ebuild in your local overlay in sys-fs/mtpfs
cd /usr/local/portage/myoverlay
mkdir -p sys-fs/mtpfs
cd sys-fs/mtpfs

mtpfs-0.9.ebuild
# Copyright 1999-2009 Gentoo Foundation
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

DESCRIPTION="MTPFS is a Fuse filesystem based on libmtp"
HOMEPAGE="http://adebenham.com/mtpfs"
SRC_URI="http://adebenham.com/debian/mtpfs_${PV}.orig.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="debug"

DEPEND="sys-fs/fuse
      >=dev-libs/glib-2.18.4-r1
      media-libs/libmtp"
RDEPEND="${DEPEND}"

src_configure() {
   econf $(use_enable debug) || die 'econf failed'
}

src_compile() {
   emake || die 'emake failed'
}

src_unpack() {
    unpack ${A}
    mv ${P}.orig ${P}
}


src_install() {
   emake DESTDIR="${D}" install || die 'installation failed'
   dodoc AUTHORS INSTALL NEWS README ChangeLog
}

pkg_postinst() {
   einfo "To mount your MTP device, issue:"
   einfo " /usr/bin/mtpfs <mountpoint>"
   einfo
   einfo "To unmount your MTP device, issue:"
   einfo " /usr/bin/fusermount -u <mountpoint>"
} 
Step 3: Install it
ebuild mtpfs-0.9.ebuild digest
emerge mtpfs

Step 4: Mount and enjoy
Be sure your device is connected and in debug mode.
mkdir /mnt/xoom
mtpfs -o allow_other /mnt/xoom

Credits to thebytes, I merely improved what he was doing by fixing the ebuild from the original gentoo bugreport.

Customizing the Xoom kernel / modules to add hardware support

This tutorial will show you how to customize, compile and install a kernel on your rooted xoom.
My goal here is to be able to use extra hardware from the USB port.

For the sake of the example and to link back to forensics I gonna show you how to add support for a "more versatile" USB wifi dongle.

Prerequisites
- an OTG (On The Go) cable to be able to connect your device. I bought one of those on ebay and it worked perfectly.
- a working cross-compilation environment (first part of the article) and/or a chrooted gentoo on the xoom
- a good, working recovery rom (clockworkmod or eq.) where you can specify a .zip to flash.
- the guts to possibly make your xoom unbootable and recover from it with the recovery rom

Note
This is quite an advanced procedure, if you have no clue about what I am doing here, just don't do it.
Also, please understand I am not responsible for any damages caused by this, you have to understand the experimental of the procedure and acknowledge that stuff can go wrong.

let's go

Here, as a base, I used the Tiamat customized kernel but you can also use more stock ones or other alternatives.

First, install the compiled Tiamat kernel and boot image from the procedure described here.
Keep a copy of the boot image, you will need it further down the tutorial.

When everything is ok and you are able to run this custom kernel, we can customize it further.

From your PC with crossdev installed or from your chrooted xoom, go to your favorite folder to develop kernels (I use /usr/src) and checkout a kernel.

cd /usr/src
git clone https://github.com/Tiamat-AOSP/Tiamat-Xoom.git

It takes a whole bunch of time to copy the git tree, be patient.

Recover the configuration from your running kernel from the xoom running the kernel you want to customize. If you are doing this from within the chrooted environment it is easy :

cd /usr/src/Tiamat-Xoom
gunzip -c /proc/config.gz >.config

Make sure the config is squared out:
make oldconfig

Then fire up the configuration menu:
make menuconfig

If you are compiling if from a cross dev environment adb pull the file and adjust the cross compilation prefix :
General / Cross-compiler tool prefix (armv7a-hardfloat-linux-gnueabi-)

If you are compiling if from the chrooted xoom, remove completely the prefix as you are pure native.
General / Cross-compiler tool prefix ()

Now add the support for the hardware you want : here I add the support for rt2x00 matching the wifi device I want to support.
Networking Support/Wireless/Cfg80211 & Generic IEEE802.11 NEtworking stack 
Networking support/ RF switch subsystem support/Power off on suspend [x] # it is needed for the stack above
Device Drivers / Networking device support / wireless lan / Ralink driver support / rt2800 (USB) 
... / rtxx [x]
... / unknown [x]

Once you are done, build your kernel, from the crossdev, (adapt the j parameter for the number of cores you have of course) :
make -j8

From the xoom :
make -j2
make modules_install

Unzip the tiamat kernel zip update you downloaded earlier:
take a kernel update zip you used before as reference from tiamat and unzip it, for example:
mkdir custom_update
cd custom_update
unzip ../Tiamat_Xoom-2.6.36.4-v1.4.3_OC-1.6.zip

It create a structure where you need to overwrite some files :
First the kernel itself (adapt it along the lines of this)
cp /usr/src/Tiamat-Xoom/zImage kernel/

The modules :
rm system/lib/modules/*.ko
find /usr/src/Tiamat-Xoom/ -name *.ko -print -exec cp {} system/lib/modules/ \;

Ok, now repack deployment !
zip -r ../Custom_Tiamat.zip *

You just need to flash this and insmod / modprobe the modules from your android command line / chroot.

Enjoy !

2011-05-28

Hacker's Keyboard by Klaus Weidner review

Related to my other posts on running gentoo on Xoom.
If you don't have a physical bluetooth keyboard or an use keyboard with an OTG usb adapter, you can use Hacker's Keyboard.

It is really cool, you have all the keys you miss under Better Terminal Pro.
It has a tons of options so you can "dumb it down" no autocorrect, no suggestions etc ... so it doesn't bother you when you type the weird console commands.

Enjoy and thx to Klaus for this free app !

2011-05-27

LittleGreenBugs is live !

I am glad to present you a little project we started few days ago :

http://www.littlegreenbugs.com

Basically it is a centralized place where any Android Market applications can have their bugtool.

Spontaneously users can log bugs there and the developer will get notified.
Android developers of their respective application can "take ownership" on the site and have a free bugtool.

It uses google oauth so it is really easy to use, no sign in nor password required.


Feel free to send us some feedback !

Guillaume

NB: We are currently testing an API to integrate your applications directly with the tool, feel free to ask the access if you want to beta test it !

2011-05-07

Speedup compilation with a distcc cross compilation on gentoo

This is a shortened version of the gentoo tutorial on crossdev & distcc.
I made it work between my Xoom running a chrooted gentoo and my i7 desktop machine.

On your slave(s) :

emerge sys-devel/crossdev

in make.conf set PORTDIR_OVERLAY to a your local custom overlay if is not done already like :

PORTDIR_OVERLAY="/usr/local/portage"


Compile the toolchain for the Xoom architecture:
crossdev -s4 --target armv7a-hardfloat-linux-gnueabi
emerge distcc

configure /etc/conf.d/distccd to accept incoming requests from the xoom for example, I also changed the log-level so I can see in the syslog (/var/log/messages) which compilation units are sent to my desktop:
DISTCCD_OPTS="${DISTCCD_OPTS} --allow 192.168.1.0/24"
DISTCCD_OPTS="${DISTCCD_OPTS} --log-level notice"

Start the daemon :
/etc/init.d/distccd start

On the master (Xoom) :
Before starting be sure you have sys-devel/binutils-2.21 or better or you will hit this bug : http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=595649
emerge ">=sys-devel/binutils-2.21"
emerge distcc

in /etc/distcc/hosts:
add the ip of your pc machine ie. 192.168.1.200
remove 127.0.0.1 (No need to run the daemon locally)

in /etc/make.conf add distcc feature:
FEATURE="distcc -userfetch"
MAKEOPTS="-j18" # something like nb of cpu in your farm x2

Don't forget to regenerate your environment :
env-update

emerge something (that compiles in C or C++ ;) ) on your Xoom/master, tail /var/log/messages on the slave to see if the compilation occurs correctly

2011-05-06

Running Gentoo Linux (as a chroot) on the Motorola Xoom


Prerequisites

  • a rooted xoom
  • busybox installed
  • a terminal emulator (Better Terminal Pro works perfectly)
  • a large enough & preferably fast  microsd card. I used an 8Gigs class 6.
  • check if you have nothing important to backup on the card before starting
  • optional : a bluetooth keyboard

First step : prepare an sdcard


Plug your card with a reader / adapter on a standard linux.
It should appear like a /dev/mmcblk0

Wipe out the partition table and create one big linux fs:

fdisk /dev/mmcblk0


remove all partitions: d d d
re-add one, primary with the default linux type with the default size (all disk)
n then p then enter enter

Create an ext4 file system:
mkfs.ext4 /dev/mmcblk0p1

Mount the fs somewhere
mkdir -p /mnt/gentoo
mount /dev/mmcblk0p1 /mnt/gentoo
cd /mnt/gentoo

Second step : copy over the stage3 and portage

Browse to http://www.gentoo.org/main/en/mirrors2.xml and find a good mirror for you or if you have already a gentoo machine do :
emerge mirrorselect
mirrorselect -s 1 -o

You need to find a stage3 of armv7 arch with hardfp and undecompress it where you have mounted your sdcard :
cd /mnt/gentoo
wget http://mirror.ovh.net/gentoo-distfiles/releases/arm/autobuilds/current-stage3-armv7a_hardfp/stage3-armv7a_hardfp-20110503.tar.bz2
tar xjvf stage3*.tar.bz2
rm stage3*.tar.bz2

Then you need a portage snapshot and uncompress it in the right directory:
cd /mnt/gentoo/usr
wget http://mirror.ovh.net/gentoo-distfiles/releases/snapshots/current/portage-latest.tar.bz2
tar xjvf portage-latest.tar.bz2
rm portage-latest.tar.bz2


Third step : adjust some settings
in /mnt/gentoo/etc/make.conf adjust your mirrors and, very important disable the userfetch feature:

[...]
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
GENTOO_MIRRORS="http://mirror.ovh.net/gentoo-distfiles/"
FEATURES="-userfetch" # on android non-priviledged users like portage has no right to open a socket due to CONFIG_ANDROID_PARANOID_NETWORK in the kernel config
Note : you can also add MAKEOPTS="-j2" for parallel building

create /mnt/gentoo/root/.profile like this :

export TERM=xterm
env-update
cd

Unmount your card, put it in your Xoom and restart it.

Chroot in your gentoo
Here is a little script that you can put for example in /sdcard/gg.sh :

mkdir -p /sdcard/gentoo
mountpoint -q /sdcard/gentoo || mount -t ext4 -o noatime /dev/block/mmcblk0p1 /sdcard/gentoo
echo "nameserver `getprop dhcp.wlan0.dns1`" > /sdcard/gentoo/etc/resolv.conf
mountpoint -q /sdcard/gentoo/dev || mount -o bind /dev /sdcard/gentoo/dev
mountpoint -q /sdcard/gentoo/dev/pts || mount -o bind /dev/pts /sdcard/gentoo/dev/pts
mountpoint -q /sdcard/gentoo/sys || mount -o bind /sys /sdcard/gentoo/sys
mountpoint -q /sdcard/gentoo/proc || mount -t proc proc /sdcard/gentoo/proc
export HOME=/root
export TERMINFO=/etc/terminfo
chroot /sdcard/gentoo /bin/bash -l

then do from adb shell or your favorite terminal on the device :
su
source /sdcard/gg.sh

Enjoy your new gentoo environment !

Edit1:
- added a check to avoid remounts when you reexecute the script
- overrided the shell variable better terminal was putting


Edit2 2011-05-28: With the 3.1 update, the sdcard is mounted directly under /sdcard/external:
/dev/block/mmcblk0p1 /mnt/sdcard/external ext4 rw,relatime,barrier=1,data=ordered 0 0

So you can safely reuse it directly, here is the alternative script.

echo "nameserver `getprop dhcp.wlan0.dns1`" > /sdcard/external/etc/resolv.conf
mountpoint -q /sdcard/external/dev || mount -o bind /dev /sdcard/external/dev
mountpoint -q /sdcard/external/dev/pts || mount -o bind /dev/pts /sdcard/external/dev/pts
mountpoint -q /sdcard/external/sys || mount -o bind /sys /sdcard/external/sys
mountpoint -q /sdcard/external/proc || mount -t proc proc /sdcard/external/proc
export HOME=/root
export TERMINFO=/etc/terminfo
chroot /sdcard/external /bin/bash -l

2011-05-01

Android Pick. Repligo : A tablet compatible PDF reader

With the nice screen resolution of the xoom (1280x800) I was looking for a good pdf reader.
I bought Repligo and so far I am quite happy with it.

I appreciate :
- The night mode button is directly accessible in the main overlay menu
- The text reflow also
- The index with thumbnails at the bottom is handy and relatively fast
- Nice presentation of the search result (a list of extracts with matches instead of jumping in the doc)
- Navigation : Pincer zoom works, tap or swipe for the next/previous page

I would like to have :
- an automatic restore of the last view mode used when you reopen a specific document (ie. my current book night mode with reflow, a document normal mode without any reflow)
- Port it completely for Honeycomb (it is still with the backward compatible menu in the bar)
- It should skip blank pages in books
- A double page (left/right) for pocket books could be nice

So after reading around 700 pages on it, I recommend it.

My rating : 4/5