Installing/Running Gentoo on the Nokia N810
This document is very out of date, and will not be updated. I've destroyed two n810's (though both destructions had nothing to do with Gentoo :) and won't be purchasing any more of them. Please see slonopotamus's EXCELLENT work which has taken this project past points I would never have achieved with functioning hardware ... http://slonopotamus.org/gentoo-on-n8x0
This is a work in progress.
For laughs and historical value,
original attempt documented at: www.ivories.org/blog
Questions/comments are welcome. Email fauxmight@n.c
(see domain name in your browser :)
Current todo list: 2008.12.15
- Change this site to proper blog: nanoblogger, polarblog, or tidlywiki. Suggestions?
- Put initfs back in the loop (get bootmenu keyboard working with linux-omap kernel)
- Proper handling of hardware clock (retutime from Maemo initfs)
- Do a CHOST change ala http://www.gentoo.org/doc/en/change-chost.xml
to arm-softfloat-linux-gnueabi ... THEN, build catalyst, and a (now) softfloat/eabi stage3 (this will make it reasonable
for others that want gentoo-n810 to build from scratch)
Mon Dec 15 09:34:28 CST 2008
BETTER (read "working") KEYBOARD, FUNCTIONAL WIRELESS, AND A NEW KERNEL
Today's update is credited to the fine folks at #maemo. I *may* have figured these bits out eventually (as in months down the road), but they got me going a good bit quicker on these parts with a couple of pointers. Hats off to you gentlemen.
First off, I've switched from the Maemo kernel to the Linux-OMAP kernel
with the N8x0 patches and the
stlc45xx open source WLAN module.
This allows us freedom from the 2.6.21 kernel -- no more patching for old-ABI/EABI problems,
and along with this change, we get a proper FN key (yea for digits).
Ok, so that's what you'll get, now howto:
- Download kernel sources from www.kernel.org. I used 2.6.27.
- Download linux omap patches. I won't direct link the patches. They're at www.muru.com. I used the 2.6.27 patches (surprise!)
- Download the N8x0 patches. I used the 2008-08-14 patches.
- Untar the kernel and the N8x0 patches.
- Apply the linux-omap patch (bzcat /PATH/TO/linux-2.6.XX-omapX |patch -p1)
- Apply the N8x0 patches one at a time.
- I then built in scratchbox. You may wish to set up some other cross-compiling environment.
- "make n800_defconfig" [That's correct. There's no "n810_defconfig." It's ok.]
- Modify .config by hand if desired. Then run "make oldconfig" if you did.
- "make"
- Now exit scratchbox and copy arch/arm/boot/zImage to somewhere accessible. And flash it to the N810 with "flasher -k /PATH/TO/zImage -f"
You shouldn't *need* any of the modules but if you make modules intentionally and don't know how to get them where they need to go, write me, I'll walk you through it. If you want to skip some work, here's my kernel. As usual, I make no promises that it won't run away with your teenage daughter, step on your petunias, or melt your N810 into dead, blue cacodemon eye-goo. Interestingly this new kernel completely ignores the initfs partition though it does not overwrite it. (There was some experimentation not worth describing here that validates that claim.)
Next up, stlc45xx, the open source WLAN module:
- Download the stlc45xx sources. I used version 0.1.3.
- I built these, too, in scratchbox. Go to the untarred directory and run "make KERNEL_SRC_DIR=/PATH/TO/KERNELSOURCE/USED/ABOVE"
- Exit scratchbox and copy the stlc45xx.ko kernel module to /lib/modules/YOUR-KERNEL-VERSION/ on the Gentoo partition on the n810.
Here's my stlc45xx.ko built against the kernel described above. Same lack of guarantee as always. There are several ways you could go about getting this onto your N810 at this point. I had a 2G removable miniSD card I was moving between devices, mounting, unounting and copying. You could set up USB networking (described in the stlc45xx README). You could also flash your kernel back and forth and copy things to the Gentoo partition from Maemo. That's up to you.
3826.arm
You need one more thing to make this work: the 3826.arm firmware file from your maemo install.
Even though this is a pain in the neck to go back and find, I really can't post it here for download.
I'm fairly confident that it's not freely (as in speechly) redistributable.
You'll need to access the original initfs partition of Maemo, and copy usr/lib/hotplug/firmware/3826.arm to /lib/firmware on the Gentoo partition.
In a running Maemo install, the 3826.arm file is softlinked in several places, notably /lib/firmware.
modules.dep
Handmake a modules.dep file. There's probably a "righter" way to do this. Please enlighten me.
"echo /lib/modules/`uname -r`/stlc45xx.ko > /lib/modules/`uname -r`/modules.dep"
Modprobe it and play!
You should now be able to successfully insert the kernel module and set things up with ifconfig, iwconfig, wpa_supplicant and so forth.
I'm not gonna give you my samples on this one for what should be obvious reasons, but drop me a line if you need some help.
I got full WPA support for CCMP (AES) encryption on a hidden SSID and also WPA2-PEAP-MSCHAPv2 radius to work with wpa_supplicant.
I did have to emerge wpa_supplicant and wireless tools from my Gentoo chroot inside Maemo.
Next orders of business
- Better power management. Batteries die quick and hard, and my e2fs is now a bit f*ckd and needs to be fsckd.
- retu handling. Right now, harware clock is always at 0 unix time (December something-or-other 1969).
- Rebuild packages for EABI and softfloat. I'm holding off here, because I'll probably set up good portage cross-compiling first. I'm trying to decide between attacking this from the qemu approach or from the cross-dev approach. Either way, I will likely have a arm-softfloat-linux-guneabi stage3 built for you all "soon". I need to fix up my side and then get catalyst going, emulated or otherwise.
- I also need to figure out how this kernel is deciding it's boot order. I have a 'CONFIG_CMDLINE="root=/dev/mmcblk0p1 console=tty0 rootdelay=2"' in my kernel config, but if I've got an external miniSD card in the slot at boot time, I get a kernel panic, and it can't find root fs or init.
Sat Dec 13 16:34:55 CDT 2008
This is a complete restart of the Gentoo on n810 project that I originally started here. It's much simpler than all that, so here we go:
Starting from Diablo Maemo install:
Partition and format AT LEAST the 2G internal MMC and 1 external MMC. (You'll need the second 2G for swap space).
I did all my beginning compiling ON the n810. Cross-compiling WITH portage was just a little too much to swallow at one time,
but if you want to go for that, here's some instructions from gentoo.
I used a cfdisk and an mke2fs I compiled in scratchbox. You can use what you like, but here's my binaries if you want them. Oh, I needed the tune2fs that's there, also because I wanted to set auto-fsck to never. (-i 0 and -c 0) Portage tree is giant set of files and default ext2 for a 2G filesystem didn't have enough inodes, so when I mke2fs'd, I invoked it with "-i 4096". That allowed a sufficient number of files on a 2G stick for portage tree. In general, these methods work. I really, really recommend getting a larger SD card to do this kind of foolishness, but it CAN work like this.
Okay, now if you're using the Maemo kernel, as opposed to the linux-omap patches, (I'm trying these right now, but don't have info to report yet) you'll NEED to patch the kernel and flash it. You'll keep your Maemo file-system intact, and Maemo will still be happy with the modified kernel. The trouble is Gentoo ARM stages are old-ABI, and the Maemo (Diablo) kernel is 2.6.21. This kernel does NOT properly handle non-EABI binaries without patching. You can:
- Patch the Maemo sources in scratchbox (I did)
- Get linux-omap kernel working (I will ... eventually)
- Wait for Maemo to get a post-2.6.25 (upstream) kernel
If you decide to go for method 1, some info is here on Debian's bug page. Basically, the kernel *THINKS* it's handling non-EABI binaries correctly, and in many cases it does. However, in several instances - notably any use of the 'find' command, it barfs, and badly. The patch is included in that bug page noted above. It's really not a Debian bug; it's a kernel issue. Unfortunately, since the Maemo kernel is already so heavily patched, I found I had to hand-edit the kernel sources while referring to this patch. At the end, though I flashed that kernel back onto the n810 (flasher -k /path/to/your/scratchbox/compiled/kernel) and it worked (for certain definitions of "worked"). Here's someinformation on Maemo kernel hacking.
If you're daring (and you trust I'm not trying to blow up your device, which I will make no promise is or is not the case), you can just use my kernel config. It has some other very small modifications to it: ext2/ext3/nfsv3-client support are all built in rather than modules, and I've got my frame-buffer console (CONFIG_FRAMEBUFFER_CONSOLE=y) so I can see things load (also there's a Maemo bit that normally overrides the frame buffer that I turned OFF: CONFIG_FB_OMAP_MANUAL_UPDATE). I *think* those are the only mods, but again, will not promise.
You'll next need the bootmenu installer from the Deblet Project.
I used this installer, and after it completed,
I ran the "Install Bootmenu" from the Utilities folder. (I think... The 810 I did this on has a fracture screen and is almost completely black.
Touch screen works, but display is pretty much gone. Everything that I *can* do from ssh, I do.
I have a second n810, but that's my voip phone ... and my only phone, at the moment ... but I've got a number throught
ipkall, which is awesome; I digress.)
Once I had bootmenu installed, I made a /etc/bootmenu.d directory and then placed this entry
into the bootmenu.d subdir. If you put your gentoo files in some place other than the first partition on the internal SD card, you'll have to modify that .item file.
Ok, now you've got things set up, but you don't have the gentoo files yet, so let's do that:
get the tarball for stage3 armv4l and one for a latest portage snapshot.
I put those on an nfs shared mount, but I think you'll have the space for them on the ext2 fs.
You WILL need to delete them ASAP if you do that. There will not be enough space to build gcc later on.
- Mount your gentoo device (likely /dev/mmcblk0p1) to /mnt/gentoo.
- mount -o bind /dev /mnt/gentoo/dev
- mount -o bind /proc /mnt/gentoo/proc
- Then "tar xvfjp" the stage, and "tar xvfj [the snapshot] -C usr" the portage snapshot.
- Copy your /etc/resolv.conf to /mnt/gentoo/etc.
- chroot /mnt/gentoo /bin/bash
- env-update
- source /etc/profile
- sync portage (emerge --sync)
- edit /etc/locale.gen and run locale-gen if you want to
- set the timezone (cp /usr/share/zoneinfo/YOUR_TIMEZONE_FILE) /etc/localtime) -Note: this was still broken for me on reboot - I need to learn more about /dev/retu
- Modify your make.conf. Mine is here. I use ~arm keyword. You might not wish to do that.
- Modify fstab. Here's mine.
- Emerge a syslog (syslog-ng), logrotate, a cron manager (vixie-cron) if you want them
- Set up networking/hostname if you care to. I don't have this working, yet.
- Set a root password.
- umount /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
Back in Maemo (outside the gentoo chroot), run refresh_bootmenu.d and say "yes" to adding the gentoo item. Let it reboot. Tinker in a native gentoo on your n810. This is a VERY primitive system, I know, and it needs alot of work to be useable. We'll get there :)
Things I plan to do and/or need to learn more about:
- /dev/retu (time was totally broken on my initial reboot - 1969)
- linux-omap kernel patches - this will move away from using the maemo kernel, and I consider that a good thing. It'll also have an IN KERNEL keyboard driver fr the N810 allowing access to the number keys. (I'll need the extra n810 specific patches from the linux-omap project to do that.)
- stlc45xx moduleThis will get open source WLAN driver working.
- Cross-compiling with portage. This could significantly help out on compile times.
- Recompiling all packages with tailored CHOST and CFLAGS ... this is in progress.
I whipped this "howto" up very quickly after talking with some folks at #maemo.
It seemed there was more interest in the project than I expected.
If there are errors or ommissions, I will try to fix it up.
Feel free to send me any questions/comments: fauxmight@n.c (see domain in address bar).
I'm also *occasionally* on #maemo on freenode (either christendoc or fauxmight).