[Shield Android TV Android Development] yifanlu:
This is a full featured port of NVIDIA L4T R32.7.2 (Ubuntu 18.04) for the SHIELD TV (2015, 2017). It has full hardware support including:

GPU acceleration

Wifi/Bluetooh

USB 3.0

HDMI with audio

microSD (supported models)

Power management

etc

Download​

Download Latest (R32.7.2, 07/09/22)

Details​

The main challenge in this port was getting the right kernel version to match with the on-device DTB. The DTB is structured in a way that Cboot must be able to parse (and modify it) and then Linux kernel must be able to parse it as well. There are various issue with previous documented methods of flashing a Jetson DTB. NVIDIA stopped distributing SHIELD TV (Foster) DTBs with L4T releases years ago so you would have to manually port a newer DTB or be stuck with an older kernel. Flashing an (years) older DTB is not an option because a newer Cboot will fail to parse it and you'll end up with a brick. Flashing a custom DTB is dangerous for this reason as well. Flashing an older Cboot is not possible due to signature requirements even on an unlocked device. So we are stuck with one option: build a L4T kernel around the device's Android DTB.

NVIDIA maintains two forks of Linux for Tegra X1. The L4T kernel and the Android (downstream) kernel are not 1-to-1 compatible. DTB property names can differ, ioctl structure sizes can differ, etc. I tried various ways to cleanly merge the two and ended up with the following working strategy:

Kernel 4.9 + NVIDIA drivers from Android fork

Build config from L4T release hand merged with options from the Android TV kernel

NVGPU drivers from L4T fork (due to lack of source for and need for compatibility with userland drivers)

Initramfs from L4T release

I also had to port some patches from one fork to the other (especially for NVGPU). The end result is a kernel that combines both forks and therefore is relatively stable and fully featured.

Booting​

The build is tested with the 9.0.0 and 9.1.0 release. It is recommended that you update to 9.0.0.

Note that once you update Cboot, you cannot downgrade to a lower version anymore! If you do not update, some things may not work properly due to the DTB differences noted above however, any relatively "modern" build may still work.

You need a USB drive with at least 8GB of free space. Flash rootfs.img to the first partition (replace sdX1 with your USB drive partition):

$ sudo dd if=rootfs.img of=/dev/sdX1 bs=1MiB

Make sure your SHIELD TV is unlocked and connected to fastboot.

Either boot the kernel directly:

$ fastboot boot boot.img

Or you may also flash the kernel if you want to:

$ fastboot flash boot boot.img
$ fastboot reboot

The initramfs will attempt to boot from the following devices (in order):

1. sda1: First partition of external USB on 16GB model

2. sdb1: First partition of external USB on 500GB model

3. mmcblk2p1: First partition of microSD on supported models

4. mmcblk0p29: Userdata partition of eMMC on 16GB model

5. sda32: Userdata partition of HDD on 500GB model

6. sda33: Partition 33 of HDD on 500GB model (partition table modification needed)

7. sda34: Partition 34 of HDD on 500GB model (partition table modification needed)

8. mmcblk0p19: System partition of eMMC on 16GB model (too small to hold rootfs unless partition table is modified)

After installation, you should resize the partition if your device is > 8GB (replace sdX1 with your installation device).

$ sudo e2fsck -f /dev/sdX1
$ sudo resize2fs /dev/sdX1

Flashing to internal eMMC​

If you wish to flash rootfs to your internal eMMC, you need to first install to a USB and boot into Ubuntu. Flashing from fastboot will NOT work due to some eMMC issues (I think Cboot does not respect the block remap).

The following will flash to the userdata partition and will WIPE any existing data on the device!

$ sudo dd if=rootfs.img of=/dev/mmcblk0p29 bs=1MiB
$ sudo e2fsck -f /dev/mmcblk0p29
$ sudo resize2fs /dev/mmcblk0p29

You can follow similar steps to flash to sda32 on a 500GB model. Follow the steps in the first section to flash boot.img.

Uninstalling​

As long as you didn't touch the other partitions, you can easily restore Android TV with the recovery images.

$ fastboot erase userdata
$ fastboot flash boot nv-recovery-image-shield-atv-9.0.0/boot.img

​

Troubleshooting​

The USB/microSD does not boot and is stuck at a blinking cursor

Make sure you wait long enough (at least five minutes).

Make sure your USB drive (or microSD) is formatted with MBR with a single partition. You should be writing to /dev/sdX1 (X is some letter) with a "1" at the end. Do not write to /dev/sdX.

Try to mark the first partition as bootable.