[DEV] Ubuntu 18.04 LTS Bionic (Linux for Tegra) for SHIELD Android TV

Search This thread

buddens93

New member
Feb 13, 2023
2
1
@yifanlu Thanks for this awesome project!

Unfortunatly i also got issues while mounting the root filesystem via usb on a 2017 (P2897) device.

Tried different usb devices with:
- DOS
- partition type Linux
- Filesystem: EXT4
- Bootable Flag: Yes

command: dd if=rootfs.img of=/dev/sdX1 bs=1MiB status=progress && sync
Guess the usb stick is well prepared.

I already flashed the boot.img on the device

What i recognized is that both usb ports goes down/disabled as soon the nvidia boot logo shows up. It seems that there is no power anymore on it. Both USB ports stays disabled and the cursor starts to blink and looking for the filesystem.

I've checked the port functionality by connecting a usb hub with leds and with some usb lamps.

Maybe that's the reason why any usb stick doesn't want to mount... because of the non working ports?
At this moment the Ports are not acting like Host-ports and doesn't provide electricity.

The question is now: Is it possible to re enable the usb ports as soon the boot script is executing?
Interesting - I have the same issue with the same model (P2897)

I couldn't get past the blinking cursor despite trying everything suggested here. I've used both Windows (MiniTool Partition Wizard & LinuxLive USB Creator) and Mac (Disk Utility & DD command) USB flashing methods. I can see the USB is prepared correctly (FAT32 MBR) with the first partition imaged with the roots.img, marked active. Both methods have the same result (infinite blinking cursor).

Has anyone got this running on a P2897 that could share their experience?
 
  • Like
Reactions: dilsere

dilsere

Member
May 18, 2009
9
1
New Jersey
Interesting - I have the same issue with the same model (P2897)

I couldn't get past the blinking cursor despite trying everything suggested here. I've used both Windows (MiniTool Partition Wizard & LinuxLive USB Creator) and Mac (Disk Utility & DD command) USB flashing methods. I can see the USB is prepared correctly (FAT32 MBR) with the first partition imaged with the roots.img, marked active. Both methods have the same result (infinite blinking cursor).

Has anyone got this running on a P2897 that could share their experience?
Have you found the solution yet? I'm also in the same boat.
 

dilsere

Member
May 18, 2009
9
1
New Jersey
I only have a 2015 shieldtv but I read the hardware are the same. Maybe I was wrong and there’s some kernel changes needed. I would diff the defconfig between the latest android release for both and see what the differences are. Then add those to the config.

EDIT: I downloaded the recovery image for 2017 and compared the kernel defconfig and it’s identical. That means the kernel isn’t the issue. My next guess would be the init script I wrote. Maybe the dev number is different on 2017?
This could be the reason for P2897 2017 16gb model is having the problem of usb ports shutting down as soon as the nvidia logo comes on. Maybe yifanlu can look into this?
 

dilsere

Member
May 18, 2009
9
1
New Jersey
Can you explain this USB port issue some more and provide evidence?
So, as soon as I run the code fastboot boot boot.img, what happens is that shield reboots and as soon as the NVIDIA logo comes on the screen, somehow the power to usb is shut down... so we are stuck on the infinite cursor loop. How do I know its shutting down the usb power at the nvdia logo is that my usb drive is basically ssd connected to shield though sata to usb cord. It spins the drive while its booting but as soon as it hits the NVIDIA log, it stops spinning the drive. I tried this with two different drives, and a usb thumb drive, same result... And, just so you know, I did flash the rootfs the way you mentioned. Flashed it to /dev/sdb1 and not to /dev/sdb using dd and and flagged it to boot using cfdisk.

Thnaks,
 

yifanlu

Senior Member
Aug 1, 2011
279
228
Because, everyone here on this thread have tried it on P2571 2015 and 2017 and P2897 2019 and seems to be working for them except for few of us who have P2897 2017 model with this kind of behavior is observed.
That doesn’t mean that the thing you observe is unique to one device. You would have to do the same test on a 2015 model and see if the results are different. You can work with someone who owns both models. I do not so I cannot be of help.
 

dilsere

Member
May 18, 2009
9
1
New Jersey
That doesn’t mean that the thing you observe is unique to one device. You would have to do the same test on a 2015 model and see if the results are different. You can work with someone who owns both models. I do not so I cannot be of help.
If your are not too busy, would you like to work on my shield if i send you mine? I will pay for the USPS shipping bothways!
 

dilsere

Member
May 18, 2009
9
1
New Jersey
Legit curious, what kind of things are you currently using it for? I use mine as a media device, so going to Linux probably wouldn't work for me, but still curious.
Currently I'm using it as a plex server for my movie and music collection. But, I was thinking if I could run ubuntu than I could run Nextcloud server on it for cloud service or run openmediavault on it for NAS.
 

Zacharybinx34

Senior Member
Mar 20, 2012
660
41
Currently I'm using it as a plex server for my movie and music collection. But, I was thinking if I could run ubuntu than I could run Nextcloud server on it for cloud service or run openmediavault on it for NAS.

Is the shield powerful enough to run as a NAS? I've heard with the android OS on it, it's no good.
 

dilsere

Member
May 18, 2009
9
1
New Jersey
Is the shield powerful enough to run as a NAS? I've heard with the android OS on it, it's no good.
Yifanlu has already mentioned the link with the benchmark on the 1st page of this thread. The power is decent enough for small home use... The power consumption is why I am interested in it. This thing will be running all day, all night consuming very little power compare to traditional NAS.
 
  • Like
Reactions: Zacharybinx34

srymurphy

New member
Jan 23, 2019
4
1
My NVIDIA shield TV 2017 16g version is also available.
I tried to recompile boot.img based on your code and added related printing in the init script. However, I found that the kernel did not output any output after loading.
Additionally, the USB interface was indeed unable to power up. I used a multimeter to check the USB interface.

"Repo init - u git://nv-tegra.nvidia.com/manifest/android/binary.git -B rel shield r open source - m tlk/t210. xml"
I tried to check the differences between kernel versions from this repository, but found that the code for nvidia is incomplete, and many tool repositories seem to no longer exist. May I ask if there are any
 
  • Like
Reactions: gffmac

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    My NVIDIA shield TV 2017 16g version is also available.
    I tried to recompile boot.img based on your code and added related printing in the init script. However, I found that the kernel did not output any output after loading.
    Additionally, the USB interface was indeed unable to power up. I used a multimeter to check the USB interface.

    "Repo init - u git://nv-tegra.nvidia.com/manifest/android/binary.git -B rel shield r open source - m tlk/t210. xml"
    I tried to check the differences between kernel versions from this repository, but found that the code for nvidia is incomplete, and many tool repositories seem to no longer exist. May I ask if there are any
  • 7
    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):

    Code:
    $ 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:

    Code:
    $ fastboot boot boot.img

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

    Code:
    $ 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).

    Code:
    $ 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!

    Code:
    $ 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.

    Code:
    $ 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
    1. Make sure you wait long enough (at least five minutes).
    2. 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.
    3. Try to mark the first partition as bootable.
    3
    I've updated the download to fix an issue I found with connecting to 5GHz wifi. Using the other nvram.txt fixed it. I also noticed that NVENC/NVDEC doesn't work properly and am unsure if it's a kernel issue or a L4T issue. I tried building with nvdec bootloader disabled and used L4T's ns firmware and it still didn't work.

    EDIT: Made another update to fix the NVENC/NVDEC issue. Additionally, the led lightbar control driver is added in. I also made the following systemd script to disable the lightbar at boot.

    Code:
    [Unit]
    Description=Disable the lightbar
    After=multi-user.target
    
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStartPre=-/bin/sh -c "/sbin/rmmod leds-cy8c && /sbin/modprobe leds-cy8c"
    ExecStart=/bin/sh -c "echo 0 > /sys/class/leds/led_lightbar/brightness"
    ExecStop=/bin/sh -c "echo 255 > /sys/class/leds/led_lightbar/brightness"
    
    [Install]
    WantedBy=multi-user.target
    2

    Manual Build​

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

    Prerequisite​


    Building the kernel​


    1. Install the toolchain.

    Code:
    $ wget -O toolchain.tar.xz https://developer.nvidia.com/embedded/dlc/l4t-gcc-7-3-1-toolchain-64-bit
    $ tar xpf toolchain.tar.xz
    $ sudo mv gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu /opt/l4t-toolchain

    2. Fetch the SHIELD TV Android kernel sources.

    Code:
    $ git clone --depth 1 https://nv-tegra.nvidia.com/r/linux-4.9.git -b rel-shield-r-9.0.2-opensource-4.9 linux-4.9
    $ git clone --depth 1 https://nv-tegra.nvidia.com/r/linux-nvidia.git -b rel-shield-r-9.0.2-opensource nvidia

    3. Fetch the Linux For Tegra NVGPU sources.

    Code:
    $ wget https://developer.nvidia.com/embedded/l4t/r32_release_v7.2/sources/t210/public_sources.tbz2
    $ tar xpf public_sources.tbz2
    $ tar xpf Linux_for_Tegra/source/public/kernel_src.tbz2
    $ mv kernel/nvgpu nvgpu

    You should have three directories: linux-4.9, nvidia, and nvgpu

    4. Patch the sources.

    Code:
    $ cat patches/kernel-4.9/*.patch | patch -p1 -dlinux-4.9
    $ cat patches/nvidia/*.patch | patch -p1 -dnvidia
    $ cat patches/nvgpu/*.patch | patch -p1 -dnvgpu

    5. Build the kernel and install the modules.

    Code:
    $ export CROSS_COMPILE=/opt/l4t-toolchain/bin/aarch64-linux-gnu-
    $ export ARCH=arm64
    $ mkdir -p Linux_for_Tegra/rootfs/
    $ pushd linux-4.9
    $ make shieldtv_defconfig
    $ make -j$(nproc) zImage
    $ make -j$(nproc) modules
    $ make modules_install INSTALL_MOD_PATH=../Linux_for_Tegra/rootfs/
    $ sudo chown -R root:root ../Linux_for_Tegra/rootfs/lib
    $ popd

    Building Root Filesystem​


    1. Extract jetson-210_linux_r32.7.2_aarch64.tbz2 and tegra_linux_sample-root-filesystem_r32.7.2_aarch64.tbz2.

    Code:
    $ tar xpf jetson-210_linux_r32.7.2_aarch64.tbz2
    $ pushd Linux_for_Tegra/rootfs/
    $ sudo tar xpf ../../tegra_linux_sample-root-filesystem_r32.7.2_aarch64.tbz2
    $ sudo touch etc/nv_boot_control.conf

    Note the use of sudo for the last two commands. This is required for file permissions to be correct. The touch at the end resolves a bug in NVIDIA's code that resulted in the installer not launching.

    2. Install the filesystem.

    Code:
    $ cd ..
    $ sudo ./apply_binaries.sh
    $ popd

    3. To enable Wifi and NVDEC, need to first convert vendor.img downlaoded from the SHIELD recovery image to an ext4 image.

    Code:
    $ simg2img nv-recovery-image-shield-atv-9.0.0/vendor.img vendor-raw.img

    4. Next mount the image.

    Code:
    $ mkdir vendor
    $ sudo mount -o loop vendor-raw.img vendor

    5. Copy the firmware over.

    Code:
    $ sudo cp vendor/firmware/bcmdhd_clm_foster.blob Linux_for_Tegra/rootfs/lib/firmware/brcm/bcmdhd.clm_blob
    $ sudo cp vendor/firmware/fw_bcmdhd.bin Linux_for_Tegra/rootfs/lib/firmware/brcm/fw_bcmdhd.bin
    $ sudo cp vendor/firmware/nvram_foster_e_4354.txt Linux_for_Tegra/rootfs/lib/firmware/brcm/nvram.txt
    $ sudo cp vendor/firmware/tegra21x/* Linux_for_Tegra/rootfs/lib/firmware/tegra21x/
    $ sudo cp vendor/firmware/tegra21x/vic04_ucode.bin Linux_for_Tegra/rootfs/lib/firmware/nvidia/tegra210/
    $ sudo umount vendor

    6. Create and mount a new ext4 image. Note that we will create 8GiB image which should be enough to hold the root filesystem. After you flash it to your device and boot successfully, you'll want to run resize2fs.

    Code:
    $ dd if=/dev/zero of=rootfs.img bs=1MiB count=8196
    $ mkfs.ext4 rootfs.img
    $ mkdir mount
    $ sudo mount -o loop rootfs.img mount

    7. Copy the filesystem to the disk image.

    Code:
    $ sudo mv Linux_for_Tegra/rootfs/* mount/
    $ sudo umount mount

    Building boot image​


    1. Extract the existing initramfs.

    Code:
    $ mkdir initramfs
    $ pushd initramfs
    $ cat Linux_for_Tegra/bootloader/l4t_initrd.img | gunzip -c | cpio -i

    2. Patch init.

    Code:
    $ cp patches/initramfs/init init

    3. Rebuild the image.

    Code:
    $ find ./ | cpio -H newc -o -R root:root | gzip -9 -c > ../initramfs.img

    4. Build boot.img

    Code:
    $ abootimg --create boot.img -f patches/bootimg.cfg -k linux-4.9/arch/arm64/boot/zImage -r initramfs.img
    1
    Is this a fully working ubuntu desktop OS experience or is this a Kernel for the shield?
    Full Ubuntu 18.04, it’s not just a kernel. I’ve been using it for the past week and haven’t run into any issues so far. You can try it out without modifying anything by flashing rootfs.img to a usb drive and booting the kernel from fastboot.
    1
    What's performance like? I was thinking of buying a new SBC but this could be just what I am looking for