[Fire TV Original Android Development] zeroepoch:
This guide is intend to help you with "installing" Ubuntu 14.04 (12.04 also works) on the Amazon Fire TV 2 after [MENTION=3991724]rbox[/MENTION] recovery has been setup. Only headless mode is possible, similar to Ubuntu Server, but it still makes a nice little ARMv8 development box. Starting X.org or running systemd based Linux distributions will likely never be possible due to features missing from the Amazon kernel. Creative use of the framebuffer is possible if desired, maybe eventually a terminal emulator could be started. As long as you don't mount and modify mmcblk0pX there should be no possible way to mess up Android or brick the device. It's 100% reversible by just removing the SD card. You accept all responsibility for what you do with this work should something go wrong and the device becomes inoperable. With disclaimers and precursor knowledge out of the way let's get started.

To follow this guide you will need:

A micro SD card (2 GB+ recommended)

A Linux system

To login into Ubuntu you will need either:

A 1.8 V TTY USB serial device connected to the UART

A pair of USB serial devices and a null modem cable

I actually used a pair of Xbee's for testing the ttyUSB0 stuff, so hence a pair of FTDI chips would also work.

Preparing the SD Card

To get started you need to first partition the micro SD card:

Type = MBR

Part 1 = 100 MB, Fat32 (vfat)

Part 2 = Remainder, Ext4

Extract the attached zip file to the root of the first partition (extracted filename must be "ramdisk-recovery.cpio.lzma"). This is an alternative initramfs that simply uses busybox to clean up from the partial Android boot and prepare the filesystem for regular Linux. Extract an Ubuntu core root filesystem archive, ubuntu-core-14.04.4-core-arm64.tar.gz, to the root of the second partition as the root user (to preserve ownership/permissions). Make sure you sync or eject the device when done with this work so the data gets flushed to the SD card.

Now we need to make a few changes to the root filesystem to avoid usability issues and allow logins.

Replace /etc/fstab with the following contents to correct some mount options. This "disables" SELinux which fixes dpkg errors and some other login annoyances.

/dev/mmcblk1p2 / ext4 defaults,relatime 0 0
selinuxfs /sys/fs/selinux selinuxfs ro,relatime 0 0

Replace /etc/init/console.conf with the following contents to allow logins from the UART. Once the root password has been set (root is disabled by default) you can remove "-a root" if desired.

# console - getty
#
# This service maintains a getty on console from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]

stop on runlevel [!2345]

respawn
exec /sbin/getty -s -a root console

Create /etc/init/ttyUSB0.conf with the following contents to allow logins from an attached USB serial device. This should help people who don't want to take apart their device to solder wires onto the UART test points. SSH would of course be an alternative but it's not installed by default in Ubuntu core and this guide is about the building blocks not providing pre-made images (yet). Since udev doesn't work due to devtmpfs not being enabled in the kernel you will need to attach the USB serial device before booting for this to work. As before you can remove "-a root" later if desired once the root password is set. Also you should change the baud rate if needed.

start on (tty-device-added ttyUSB0)
stop on (runlevel [!2345] or tty-device-removed ttyUSB0)

respawn
exec /sbin/getty -L -a root 115200 ttyUSB0 vt102

Preparing the Fire TV

Until the search order for the initramfs file is changed by [MENTION=3991724]rbox[/MENTION] you will need to rename the initramfs on the system partition so it will continue to search for one on the SD card or USB stick. You need to connect to the device using adb either over USB or the network to execute the following commands.

adb$ su
adb# mount -o remount,rw /system
adb# mv /system/recovery/ramdisk-recovery.cpio.lzma /system/recovery/ramdisk-recovery.cpio.lzma.bak
adb# mount -o remount,ro /system

Right now this prevents "su" from working, which should be fixed by [MENTION=3991724]rbox[/MENTION] in due time. To get "su" working again you should extract the original recovery initramfs file to a USB stick and boot the device with that USB stick inserted instead of the previously created SD card. Then to restore "su" you can repeat the above steps just swapping the order of the files in the "mv" command.

Booting Ubuntu

After connecting your serial device of choice simply insert the SD card and power on the device. It's that easy! With luck you should get a shell prompt that is already logged in as root. It's a good idea to set the root password before going much further. The device isn't too useful without networking, so you can install more packages. To solve that connect an ethernet cable (since it's simpler) and type "dhclient eth0" to get online. At this point you can install openssh-server using apt-get or do anything else you'd normally do on an Ubuntu VM or headless Ubuntu system. I'm interested in hearing what people plan to do with a more-or-less high-end ARM development system.