How to run Debian natively on the Motorola Xoom
by LIV2 on Jun.19, 2011, under Uncategorized
Hey all,
I’ve seen a lot of people running linux on their xoom and other android devices but chrooted under android and using a VNC client to make use of the chrooted install. quite messy and less than efficient IMHO, so I set out to install it natively on my Xoom
I’ve managed to get Debian installed on my Xoom with the only issues being no sound and no Bluetooth, this is due to the proprietary nature of the sound drivers for the Tegra, and the lack of documentation for the BCM4329 Bluetooth under linux. if anyone has any tips with these I’d love to hear them.
Anyway, since the Xoom is an android device with an unlockable bootloader from the factory this wasn’t too difficult. the only issues were with the TegraFB and Touchscreen drivers. Thankfully Lilstevie from GalaxyLinux helped me out with the touchscreen driver and Robert Morell from NVidia provided a patch to Chromium for the FB which is here http://codereview.chromium.org/6672056
(Todo: Add guide for using WIFI, upload prebuilt images)
(Update: Fixed the links)
(Update 14/2/12 Thanks to Thomas!)
Basically all you need to do is build a root fs and a kernel for your Debian install. this is actually quite easy. here’s how..
Contents:
Disclaimer
YOU DO THIS AT YOUR OWN RISK! I TAKE NO RESPONSIBILITY FOR ANY DAMAGES TO YOU, YOUR DEVICE,
YOUR COMPUTER, OR ANY OF YOUR PROPERTY OR SOMEONE ELSE’S PROPERTY
Requirements
- A Rooted Xoom with ClockWorkRecovery Installed
- Make sure you have a nandroid backup. you will need this to boot back into Android!
- A running install of Debian, Ubuntu might work too
- An SDCard with at least 4GB for the install, preferably separate from your main SDCard and an SDCard reader for your PC
- Android–SDK
- An Arm–linux toolchain to compile the kernel, if you’re lazy like me you can just use the one that comes with the Android NDK
- This Xorg Config
- These Kernel sources, based on the Tiamat-AOSP kernel
- Fastboot tool
- mkbootimg
Building the RootFS
Before we do anything we’ll need to get the Wifi Firmware off the default install of Android
To do this run the following commands
# adb pull /system/vendor/firmware/fw_bcm4329.bin
# adb pull /system/etc/wifi/bcm4329.cal
MAKE A BACKUP OF YOUR SDCARD AND YOUR XOOM USING CLOCKWORK RECOVERY BEFORE CONTINUING AND KEEP IT SOMEWHERE SAFE!
Now lets install the tools you’ll need to create the rootfs
# apt–get install binfmt–support qemu qemu–user–static debootstrap
Once that’s done, make a directory for the rootfs to sit in until it’s ready for the SDCard and start installing the debian base
# cd ~
# mkdir deb_arm
# mkdir deb_arm/boot
# sudo /usr/sbin/debootstrap ––foreign ––arch armel squeeze deb_arm/ \ http://ftp.au.debian.org/debian
Once that’s done you’ll need to copy across some qemu files so you can chroot into the deb_arm folder and finish the installation of the base system
# sudo cp /usr/bin/qemu–arm–static deb_arm/usr/bin
# sudo chroot deb_arm
# export LC_ALL=C
# export LANGUAGE=C
# export LANG=C
# cd /debootstrap
# ./debootstrap ––second–stage
once that’s done you’ll need to edit your apt sources, to do so run the following
# echo debandroid > /etc/hostname
# echo “deb http://ftp.debian.org/debian/ squeeze main contrib non–free” > /etc/apt/sources.list
# apt–get update
And then install any of the apps you’ll want to run on your xoom, I’d recommend at least xorg, gdm3 and gnome, so
# apt-get install xserver-xorg-video-fbdev xserver-xorg-input-evdev gdm3 gnome-session gnome-panel metacity gnome-terminal network-manager initramfs-tools wpasupplicant iceweasel network-manager-gnome
You may find that you get an error like the following
Errors were encountered while processing: bluez gnome–bluetooth gnome–user–share gnome–desktop–environment
If you do, it’s safe to ignore this for now. you can always complete the installation of any non–critical packages on the device. it seems to be something weird with the chroot or the qemu emulation of ARM (if anyone knows a way to fix this I’d be glad to hear it!)
Once that’s done, you’ll not only want to set your root password but you’ll want to add a standard user account too
# passwd root
# adduser liv2
# addgroup ––gid 3003 inet
# usermod –aG 3003 liv2
The addgroup and usermod are especially important, the android kernel doesn’t normally allow network access to non–root accounts. so we have to add the special group then give the user access to that group (or you could compile the kernel to not use the android paranoid network settings)
Clear up some space too
rm /var/cache/apt/archives/*.deb
Once that’s done, exit out of the chroot by hitting CTRL+D and copy the xorg config to deb_arm/etc/X11/ and copy in the wireless firmware you copied at the start
# mkdir ~/deb_arm/lib/firmware
# cp ~/fw_bcm4329.bin ~/deb_arm/lib/firmware
# cp ~/bcm4329.cal ~/deb_arm/lib/firmware
Building the Kernel
For this part, make sure you’ve extracted the kernel sources, and the android–ndk to somewhere, in my case they’ve been extracted in ~/Downloads
# cd ~/Downloads/Tiamat–AOSP–Tiamat–Xoom–798572c/
# export CROSS_COMPILE=~/Downloads/android–ndk–r5b/toolchains/arm–eabi–4.4.0/prebuilt/\
linux–x86/bin/arm–eabi–# export ARCH=arm
# export INSTALL_PATH=~/deb_arm/boot
# export INSTALL_MOD_PATH=~/deb_arm
# make tiamat_defconfig
# make menuconfig
Once you’ve got the menuconfig screen up, go to Device Drivers > Character Devices > and enable “Virtual Terminal”
go to Device Drivers > Graphics Support > Console Display Driver support > enable “Framebuffer Console Support”
once you’ve enabled that, exit out and save the changes
Build the kernel and prepare it for use
# make –j2
# sudo -E make modules_install
# sudo cp arch/arm/boot/zImage ~/deb_arm/boot
# cp System.map ~/deb_arm/boot/
# chroot ~/deb_arm
# mkinitramfs –o /boot/initrd.img.gz `ls /lib/modules`
mkinitramfs may show some warnings like “warning: can’t open /etc/mtab:” and “pkg: version ’2.6.36.4Tiamat_Xoom–v1.4.4–Full_Throttle’ has bad syntax: invalid character in version number” but it doesn’t seem to have caused any issues for me.
Preparing the SDCard
Plug your SDCard reader into your computer and insert the card, you’ll then need to partition and format it so make sure you’ve backed up the content of the card.
Partition it so you have two partitions, the first one being a FAT32 Partition for CWR and for anything you might want to use it for under Android.
Your second partition will need to be EXT3 and big enough to fit your debian install with some room to breathe (about 4GB in my case), you can check how much space you’ll need for this by running du -sh ~/deb_arm
Once you’ve partitioned it, format the first partition as FAT32 and the second partition as EXT3. once you’ve done that you should put the SDCard back in your Xoom and make a new nandroid backup just to be sure
# sudo mkfs.ext3 /dev/sdb2
# sudo mkfs.msdos /dev/sdb1
Putting it all together
First we’ll mount the SDCard on your PC and copy across the Root FS
# sudo mkdir /mnt/sdcard
# sudo mount /dev/sdb2 /mnt/sdcard
# sudo cp -arv ~/deb_arm/* /mnt/sdcard/
# umount /mnt/sdcard
Go to the folder you unpacked mkbootimg to and copy in the boot.img from your CWR backup.
Once you’ve done that, follow the below steps to create the new boot.img for Debian to use
# cd ~/Downloads/mkbootimg
# cp ~/deb_arm/boot/zImage .
# cp ~/deb_arm/boot/initrd.img.gz .
# mkdir out
# ./unpackbootimg –i boot.img –o out/
# ./mkbootimg ––kernel zImage ––ramdisk initrd.img.gz ––base “`cat out/boot.img–base`” \
––cmdline “root=/dev/mmcblk0p2 console=tty0″ –o newimg.img
Now reboot your Xoom into Fastboot mode and insert the SDCard, this can be done by holding power + volume up until the screen goes black, then power it back on and hold down the volume down key
# cp ~/Downloads/fastboot .
# ./fastboot flash boot newimg.img
# ./fastboot reboot
Your Xoom should now boot up into Debian, on the login screen select the accessibility options and enable on-screen keyboard to log in.
Alternatively, if you happen to have a USB-OTG adapter you can just use a keyboard and mouse to interact with the system.
Going Back to Android
To Roll back to Android, simply boot into Clockwork Recovery, go to Backup/Restore > Advanced Restore and restore boot.img only, reboot and you’ll be back in Android
Acknowledgements
Lopi from the IX Project was a great help, and so was everyone from #IX
Lilstevie from @GalaxyLinux provided the Touchscreen patches
Framebuffer Patch was originally provided by Robert Morell for the Chromium Project
RootFS instructions are based on info at the Debian Wiki
July 25th, 2011 on 2:25 pm
Few issues with the instructions:
1. Tiamat-AOSP patch is broken
2. # cd ~/Downloads/Tiamat–AOSP–Tiamat–Xoom–798572c/
# cp ~/Downloads/xoomkernel–gnu.patch .
Why do I copy the xoomkernel-gnu.patch file into Tiamat-AOSP-* ?
When I attempt to run the patch it fails.
3. There’s no make on my system so I manually have to get it via apt
4. There’s no gcc on my system, same as above
Do you have a complete set of steps to get this puppy built?
Thanks!
July 28th, 2011 on 10:20 am
I sorted this out with Root Doe, my links to the AOSP sources were incorrect, so it was impossible to build following this guide.
Hopefully I’ll have the time to run through this guide again myself soon so i can fix any other issues with the guide there may be.
August 25th, 2011 on 4:52 am
How is the battery life on the one you have now? Can it run BT5? :)
August 25th, 2011 on 4:53 am
Btw, Great work!~ 3LiT3 Br0
August 25th, 2011 on 12:40 pm
Not sure on the battery life, though I’m betting it’s not good.
Should be able to run any Linux Distro there is, as long as there are arm binaries for your distro you can build the rootfs and use it with this kernel.
September 9th, 2011 on 9:11 am
Once you’ve booted into Debian can you put the Xoom’s wireless card in monitor mode?
September 9th, 2011 on 10:54 am
Hi Ouroboros,
Unfortunately not, it’s pretty hard to get the damn thing to connect to a network, or even successfully scan in the first place. :(
September 9th, 2011 on 4:07 pm
Yayh ! Génial :)
For the sound and bluetooth issues, shouldn’t be possible to use existing kernel/drivers for Android ?
Do you think dual booting Android/Debian is technicaly possible ?
Like an Android rom checking a flag on boot to load the Debian system or Android system (with the same kernel).
September 10th, 2011 on 3:47 am
Have you tried to get a native copy of debian (or any other linux distro) using beagleboard?
http://elinux.org/BeagleBoardUbuntu
Seems interesting and worthy of investigation…
October 8th, 2011 on 7:57 am
getting a segmentation fault error on the last steps trying to unpack bootimg
January 16th, 2012 on 10:27 pm
hi ive just been given a xoom and reali want linux on it ive been trying for a week now and always get errors at some point atm its gnome any help would be great
January 16th, 2012 on 10:42 pm
Hey,
What errors have you been getting?
January 17th, 2012 on 12:09 am
ok so when installing apps i get
Errors were encountered while processing:
bluez
gnome-bluetooth
gnome-user-share
gnome-desktop-environment
gnome
mono-gac
mono-runtime
libmono-corlib2.0-cil
libglib2.0-cil
libgconf2.0-cil
libgmime2.4-cil
libart2.0-cil
libmono-cairo2.0-cil
libgtk2.0-cil
libglade2.0-cil
libgnome-vfs2.0-cil
libgnome2.24-cil
libgnomepanel2.24-cil
libmono-sharpzip2.84-cil
libmono-addins0.2-cil
libmono-addins-gui0.2-cil
libndesk-dbus1.0-cil
libndesk-dbus-glib1.0-cil
tomboy
libmono-i18n-west2.0-cil
libmono-posix2.0-cil
libmono-system2.0-cil
E: Sub-process /usr/bin/dpkg returned an error code (1)
January 17th, 2012 on 12:11 am
i have also tryed your boot.img from xda but get to large to be flashed
January 17th, 2012 on 4:42 am
hmm looks like i might have to wait fro win 8 arm and hope its still got desktop on it :(
February 14th, 2012 on 2:12 pm
A very important think you should mention (took me many hours to figure out what was going wrong) is:
sudo -E make modules_install
You need the -E flag to preserve the INSTALL_MOD_PATH since most people will have different environment variables when using sudo.
February 14th, 2012 on 2:14 pm
Thanks Thomas! I’ll add it to the article :)
February 20th, 2012 on 8:52 pm
Hey, any pointers on how to build a kernel from what is supplied here and nvidia’s latest? They dropped the ventana (aka the tegra platform for the Xoom) and I’d like to pull together full functionality in the sound and Bluetooth department but don’t know how. I copied and pasted some folders together, compiled it, but I get stuck when I make the initramfs when it can’t throws several “can’t find lib/modules/2.6.35…” errors which isn’t even the kernel version. Any resources to push me in the right direction?