Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - thursagan

Pages: [1]
1
TI-Nspire / Running GNU Emacs on the TI Nspire
« on: April 22, 2018, 07:14:23 pm »
Hi all,

I've been trying to run GNU Emacs on the TI Nspire CX for a while now. The reason being that Emacs has a powerful Calc Mode, which is described officially as "an advanced calculator and mathematical tool." That description is underplaying this mode's power as it really turns Emacs into a powerful CAS. I've even heard it called a poor man's Mathematica, which is an accurate perception.

Unfortunately, using this mode on my own TI Nspire has been nothing but a dream so far. I have tried many different approaches to get GNU Emacs to run on this calculator, but all approaches are leading to dead ends and wasted time. I will document my efforts thus far in order to present a clear picture of what I've tried and the obstacles I've run into.

Obviously, the first thing I realized is that I need to use tangrs' Linux port for the Nspire. It would probably be a nightmare to try and write my own port of Emacs to the Nspire's builtin OS. There's no reason to do that when Emacs already runs on Linux and Linux already runs on the Nspire.

So, first I thought about cross-compiling Emacs for Busybox since that seems to be the only supported distro by tangrs' Linux port. Of course, Busybox is too small to really be called a distro. This is actually part of the problem: Emacs has a lot of dependencies even when it is compiled without X support. None of the builds on the download page seems to have all of the dependencies that are usually required by Emacs. So without going into the C sources and hacking Emacs apart to remove unnecessary dependencies, it seems that Busybox is simply not a viable platform to run GNU Emacs on.

So I decided that I needed to run Emacs on a real distro, which would allow me to use a package manager to install Emacs, instead of putzing around with the compilation myself. According to the Hackspire wiki page for Linux, the have been reports of success with running Debian and Arch on the Nspire. I am more familiar with Debian so I decided to try and make a Debian rootfs for ARM which contained Emacs in the default install.

I first tried this with debootstrap. I created a minimal Debian chroot with these commands:

Code: [Select]
$ sudo debootstrap --arch=armhf --foreign --variant=allmybase stretch ~/debian
$ sudo cp /usr/bin/qemu-arm-static ~/debian/usr/bin
$ sudo chroot ~/debian qemu-arm-static /bin/bash

I am using a custom debootstrap variant called allmybase which is defined in /usr/share/debootstrap/scripts/stretch as:

Code: [Select]
work_out_debs () {
...
elif doing_variant allmybase; then
base="apt emacs25-nox ncdu"
fi
...
}

All I've got there is emacs25-nox (which means Emacs 25 compiled with no X support) and ncdu (for browsing the filesystem by size). Unfortunately, even with this fairly minimal setup, it was too big for my TI Nspire. In order to make more space, I had to remove many Lisp files from the Emacs installation as well as other non-critical files and utilities. After removing many such files with the aid of ncdu, I finally managed to shrink my rootfs down enough to fit on my calculator:

Code: [Select]
$ sudo du -sh ~/debian
81M /home/my_username/debian

However, I still had a few problems at this point. How was I supposed to install my rootfs onto my calculator? I saw on the wiki that tangrs says to use Buildroot, but I could not figure out how to use Buildroot in my context. Then I found a tutorial about running Debian on the TI Nspire, but the author of the blog post only tells how to do it with a USB drive. I want to install this Debian rootfs directly to my calculator. Finally, I found this post on Omnimaga which describes the same sort of thing, but for Arch Linux. Yet it also deals with installing to and booting from a USB drive so it is not what I wanted.

After doing some more searching, I figured that I needed to turn my rootfs at ~/debian into a bootable ext2 image. I found several different ways describing how to do this, but they all had various quirks and errors when I tried to use them. The first way that I found to do this was with debirf, but I could not figure out how to use it. Or, rather, how to apply it to my situation. I also found genext2fs and it seemed to almost actually work at first. I tried running it like so:

Code: [Select]
$ genext2fs -U -v -d ~/debian initrd.tns
But I would get this error:

Code: [Select]
genext2fs: too few blocks. Note: options have changed, see --help or the man page.
Finally, at this point I was wondering whether I should even use Debian. It seemed like making an ext2 image would be totally impossible and that I should just modify an existing Busybox image using fuse-ext2. I tried to do that with an xconfig build that I found on the download page, but then I remembered that this would be totally pointless since some of Emacs' dependencies were still missing from this build.

Now it seems that I must use my Debian rootfs, or else just give up. I am a bit embarrassed that I can't even figure out how to dump an ext2 image from a directory, but it really seems harder than what I've experienced on other Unix systems. Anyway, I hope that someone can take the time to read this and help me out. Thanks.

Pages: [1]