Manjaro Amlogic TV boxes

Amlogic TV boxes

From Manjaro
Revision as of 11:01, 23 June 2021 by Danboid (talk | contribs) (Add link to panfrost docs, formatting tweaks)


Amlogic TV boxes

General disclaimer and warning

It is possible to install and run Manjaro on several affordable Android TV boxes using Amlogic chipsets such as the S905, S922 and A311 series of processors. These TV boxes can be purchased for a fraction of the price of a similar spec single board computer whilst coming complete with a case, remote and cables but there are a few catches to be aware of.

The Android TV box market is awash with fakes and clones. It has been known for manufacturers to re-use the exact same model name yet use an entirely different chipset. For example, there are at least six versions of the X96 Air but they all have exactly the same case. The TV box manufacturers rarely if ever provide updates for their Android-based OS's and they provide zero support for users wanting to run alternate operating systems so achieving full support for every box is almost impossible.

Physical build quality is another frequent issue with TV boxes, in particular poor thermal designs are quite common. You may have to cut a hole or two in the case and place a USB powered fan over the SoC to perform CPU intensive tasks without throttling or overheating.


Identifying your box

Under Android, go to Settings -> System -> About phone

The device name given under About phone is often the best one to use to identify your box but you can also run:

user $ cat /proc/device-tree/amlogic-dt-id COPY TO CLIPBOARD


Under an Android terminal to show your boxes device tree ID.


Installation

Manjaro can be installed from and to micro SD card or USB disk. It is not currently possible to install Manjaro to eMMC on Amlogic TV boxes.

Configure extlinux.conf

After using a disk imaging tool such as dd to write one of the vim3 Manjaro ARM images to a disk, mount the disk and edit BOOT_MNJRO/extlinux/extlinux.conf. You must edit the line that begins with FDT /dtbs/amlogic/ to point to the dtb file that you wish to use to configure your device tree.

If there isn't a matching dtb file for your box within the dtbs folder and you can't find a suitable dtb on this wiki or in the Manjaro forums then you should try meson-sm1-sei610.dtb first:

FDT /dtbs/amlogic/meson-sm1-sei610.dtb

Booting from USB

If you are booting Manjaro from a USB disk or via a USB SATA adapter/enclosure, there is a good chance that you will be required to add a usb-storage.quirks kernel parameter to the APPEND statement in extlinux.conf like so:

APPEND root=PARTUUID=5418e4d8-02 rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 quiet splash plymouth.ignore-serial-consoles usb-storage.quirks=152d:1561:u

You must replace 152d:1561 with the correct USB vendor and product IDs for your USB device. You can find these identifiers by running lsusb when you have your disk or adapter connected to a Linux box. It is recommended you boot from USB without setting the USB storage quirks parameter where possible.


Enable multiboot mode

If this is your first time attempting to boot from an SD card or USB disk, you must enable multiboot mode. Insert your Manjaro micro SD card or attach the Manjaro USB disk then hold down the button in the AV port by inserting a paper clip, a pin or something similar and keep it depressed while powering the device on. Keep the button pressed until you see the boot screen of your box. After a few seconds it should reboot off your SD card or USB disk. You are only required to do this once unless you reflash your eMMC.


Reflashing Android with flash-tool.sh

In emergency situations, like when Manjaro stops booting due to your bootloader having been modified or corrupted, you may need to reflash the Android OS on your TV box eMMC. If you have got a suitable installation image for your box, they are usually a couple of gigabytes in size, and you have a USB A to A cable then you can perform the following steps to reflash your TV box under Linux.

Installing aml-flash-tool

Clone the aml-flash-tool repo:

user $ git clone https://github.com/osmc/aml-flash-tool.git COPY TO CLIPBOARD


Copy aml_image_v2_packer and the amlogic update program into your path:

user $ cp ./aml-flash-tool/tools/linux-x86/* ~/.local/bin COPY TO CLIPBOARD


You are now prepared to run flash-tool.sh

Reflashing with flash-tool.sh

Disconnect the power from your TV box and plug a USB A to USB A cable into your TV box. It varies which port to use but usually only one port will work for reflashing. Now insert a pin or similar into the AV hole, depress the button and keep it pressed as you connect the USB A to A cable to your other machine. You will know when your TV box is ready to be flashed with flash-tool.sh because you will see an Amlogic device listed when you run lsusb.

When you can see your TV box is connected, you can flash it using a command such as:

user $ ./flash-tool.sh --img=X96AIR_Q1000_20210127-2121.img --parts=all --wipe --soc=g12a COPY TO CLIPBOARD


Replacing X96AIR_Q1000_20210127-2121.img with the path to the image you wish to flash. You do not need to run flash-tool.sh as root.

External Amlogic TV box firmware download links

Download and flash these firmware files at your own risk! These sites and manufacturers are in no way connected to Manjaro and so the Manjaro developers will not provide any support for installing these.

Firmware for the X96 Air family of boxes

Turewell firmware for the T95 boxes


Rooting Android

Having root access under Android is useful because this lets you copy your dtb file(s). Whilst you cannot use Android dtbs with the Manjaro mainline kernels, you can decompile them to dts files and this info can be useful when customising dts/dtb files that work with your kernel, if you have the skills and time to dedicate towards developing or modifying device tree files.

Some TV boxes come pre-rooted whilst others include an app to easily enable root/sudo access. You can use the Android Root Checker app to test if you have root access. If your TV box doesn't offer any root support then you can use TWRP and Magisk to root it. Note this isn't a permanent root solution and you will be required to boot off a Magisk modified SD card to enable root access.

Download the latest X96 Max (u212) build of TWRP. This build of TWRP should boot on most Amlogic TV boxes, not just the X96 Max.

Format a micro SD card as FAT32 and copy the twrp image (twrp-3.5.2_9-0-u212.img) onto it and rename it to recovery.img. Insert the micro SD into your TV box then hold in the multiboot AV button in whilst inserting the power until you see the boot screen. Your TV box should then reboot into TWRP.

Swipe (drag the button with your USB mouse) to allow modifications. On the main TWRP menu, choose Backup. The only partition we want to backup is the Boot partition, which should already be selected. Deselect the Data partition if that is auto-selected then click Select Storage, choose the Micro SD card then swipe to backup the boot partition. It should only take a few seconds before you are given the option to reboot.

Next, install and run Magisk under Android. When installing Magisk, choose Recovery mode then select the Select and Patch a File method. You will then be asked to locate the backup of the boot partition we created with TWRP so navigate to SD card/TWRP/BACKUPS/1234567890/SOMEDATE/boot.emmc.win and double-click the boot partition image file then choose Let's go. Magisk will then patch the ramdisk within the boot image and create a new recovery image called magisk_patched-something.img that gets saved to your Android Downloads directory. Copy this new image file from Downloads onto a micro SD card and rename it recovery.img so that you can multiboot from it, rooted.


.dtb files

A DTB file is a Linux Device Tree Blob. Device Tree Compiler (dtc) converts between the human editable device tree source "dts" format and the compact device tree blob "dtb" representation usable by the Linux kernel.


Recommended .dtb files

This is a list of Amlogic TV boxes and the dtbs that offer the best support. Please provide a download link if the dtb is not packaged with the Manjaro vim or aml kernel.

X96 Air Q1000 - meson-sm1-sei610-qca9377-bt - Tested with linux-aml kernel 5.12. Working gigabit ethernet, WiFi, Bluetooth and HDMI audio. No support for onboard audio or LED display.

Useful device tree commands

Decompile dtb to dts:

user $ dtc -I dtb -O dts -o devicetree.dts devicetree.dtb COPY TO CLIPBOARD


Compile a dts to a dtb:

user $ dtc -O dtb -o devicetree.dtb devicetree.dts COPY TO CLIPBOARD


DTB extractor - Tool to split a kernel image with appended dtbs into separated kernel and dtb files.


Tips and tricks

Enable graphics acceleration

Edit /etc/X11/xorg.conf.d/01-panfrost.conf and change AccelMethod from none to glamor.

The Mali mesa driver, Panfrost, is optimised for use under Wayland so you should get better GPU performance using Wayland-based desktops.


CH340-fan-control

CH340-fan-control is a python script to control a USB fan.


Updating mesa graphics drivers

The Mali graphics driver is still under quite heavy development and you may find you get much improved GPU performance by installing a newer build of mesa. The easiest way to update mesa is via the archlinuxdroid repo.

Download and install the latest archlinuxdroid-repo package then update to the latest daily mesa build by installing mesa-devel-git.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.