Jump to navigation

Prosthetic Conscience

Jason McBrayer's weblog; occasional personal notes and commentary

Thu, 19 Jul 2012

Running Emacs on an Android tablet

One of the things I’ve always wanted in a portable computer is the ability to run Emacs. The main reason is that since 2005 or so, my whole life has been run in org-mode, and, slightly before that, in howm. So, of course, when I got a low-end Android tablet, an Archos 70, of course, I…didn’t install Emacs on it. As EmacsWiki implies, there’s no perfectly obvious way to do so. And, there’s MobileOrg-Android. When I first got my tablet, MobileOrg-Android was pretty bad. But it got better. Today, it’s got a great user interface, syncing is fast and generally reliable, and there’s an active core group of developers who are constantly adding features and contributing back to org-mode itself.

But…after quite a bit of trying, I still haven’t made the MobileOrg workflow work for me. I keep my org files in a Mercurial repository on my home machine, and carry a clone with me. I run org-mobile-push and org-mobile-pull from the home repository, which requires it to be up to date, which usually can be done without manual intervention, but not always. And both pushing and pulling can make changes, which have to be committed. And you really have to sync on the mobile device twice: once before you push/pull, and once after, if you want the desired effect of pushing all your changes and captures to the repository, and having them all reflected on your device. The MobileOrg workflow is based on the idea that your mobile device doesn’t have the horsepower to compute agendas on the fly. But is that true these days? I’ll return to that issue later.

After seeing that some people had successfully run an Ubuntu user environment in a chrooted loopback filesystem on a similar tablet, I decided to try to get my Emacs that way. It didn’t exactly work out right a way, and it took me quite a while to make time for the yak-shaving involved. Finally, I did, but with my preferred GNU/Linux distribution, Fedora.

Overview (the short version, aka tl;dr)

My sdcard is formatted ext3, and has the Fedora 13 rootfs unpacked into it. From a root prompt in ConnectBot, I bind-mount some required special filesystems under Fedora’s root, then chroot into it, and start sshd. Then I can ssh into localhost with ConnectBot and run Emacs (and other things).

Longer version

Don’t take this as a step-by-step instruction guide. What works and doesn’t work on my device is likely to be quite different from what works and doesn’t work on yours (unless yours is an Archos Gen8). This is really more to give you an idea of the kind of yak-shaving involved in getting this working.

First I rooted my tablet. I would have done this even if I weren’t planning on running Emacs. For reference, the tablet is an Archos 70, running the latest version of the stock (Froyo) firmware, with a rooted initramfs.

Then, I tried installing the Ubuntu loopback images mentioned above. This didn’t work for me, because the stock Archos kernel doesn’t include the loop device, and for some reason, even when I built custom kernels with the loop device enabled, I couldn’t get it to work.

Fortunately, my device has a microSD card slot, which is above and beyond the internal storage that the Archos firmware treats as an sdcard for the purposes of App2SD and so forth. I formatted a card as ext3, and tried to unpack the Ubuntu image onto it. This should have worked, but for some reason, my tablet didn’t like having so much data pushed onto it over USB, and I lost the enthusiasm I needed to work on it.

Later, I unpacked the Fedora 14 ARM root filesystem more successfully, and tried chrooting into it, only to find that my kernel was too old for the version of glibc in Fedora 14. This also tragically sapped my motivation, causing me to stop working on it again for a while.

When I got another round tuit, I started with the Fedora 13 ARM root filesystem, and it worked pretty straightforwardly. This is what I did:

# umount /mnt/storage/sdcard
# mount -o noatime,nodiratime /dev/block/mmcblk2p1 /mnt/storage/sdcard

The sdcard is mounted with the options nodev,noexec,fmode=0666, and several other options that would make running it as the root filesystem of a normal linux slightly inconvenient. Some of the other parameters could be reset with mount -o remount,blah,noblah, but there doesn’t seem to be a way to do that for fmode and dmode, so unmount and remount it is.

# cd /mnt/storage/sdcard/fedora
# mount –bind /dev dev
# mount –bind /dev/pts dev/pts
# mount –bind /proc proc
# mount –bind /sys sys

Now mount the various special filesystems that Fedora is going to need, that are provided by the kernel.

# chroot . /bin/bash -
# service sshd start

Now chroot into the Fedora environment, and start sshd. I’ve omitted some other stuff, like setting a (new?) password on the root account, and so forth. Technically, even starting sshd isn’t necessary. You can just chroot into Fedora and run what you want to. Having sshd running makes it easier to reconnect to the Fedora environment without having to go through the process of cd’ing and chrooting to the Fedora directory.

From here on out, it’s just installing stuff with yum. I’ve tried to avoid installing anything except what I particularly need.

# yum install -y emacs-nox git mercurial aspell aspell-en \
  diffutils patch man screen

What works

What doesn’t work well


I haven’t tried the next logical step, which would be to install Xvnc and its dependencies, and to run a local X session, to be displayed in an Android VNC client. I may not do so, because it looks like the keyboard situation in the main free Android VNC clients is not much better (if at all) than in the terminal, in terms of having the full set of keysyms available. And it is worse, in that in ConnectBot, Emacs’s screen gets resized to accommodate the soft keyboard, whereas in VNC, the soft keyboard sits on top of part of the display area, which is not resized.

On the whole I’m happy with this experiment. I don’t think it will replace my use of Jota for note taking, because of the text auto-completion and auto-correction issue. I’m not sure whether it will completely replace MobileOrg for me. I’m enjoying finding out.

[ Posted: 21:50] | [ Category: /computing/emacs] | Permalink | Comments: 2 ]


Powered by PyBlosxom