Skip to content

Instantly share code, notes, and snippets.

@probonopd
Last active March 8, 2023 09:15
Show Gist options
  • Save probonopd/d4f0a3c7105b8378bc10eebe7f2d7de9 to your computer and use it in GitHub Desktop.
Save probonopd/d4f0a3c7105b8378bc10eebe7f2d7de9 to your computer and use it in GitHub Desktop.

Linux on x96 2GB/16GB TV box

Power

CAUTION: When powering it via the VCC line on the internal serial connector, it probably needs 3.3V rather than 5V!

x96 2GB/16GB
Amlogic s905x (Codename: GXL)
Seems to be built on the p212 reference design
Reset pin is inside AV(!!!) socket
Mainboard says Q5X V2.1
---

It seems like the device can boot from internal memory, USB, and microSD.
My SanDisk U1 microSD card reads 80 MB/sec, much much more than USB. So use that.
But to dualboot from USB or microSD, need to run aml_autoscript.zip once from the original Android. 

---

Etcher can flash .img.xz directly - no unpacking needed!

---

Dual-boot Ubuntu Linux on x96
Amlogic

meson8b

https://forum.armbian.com/topic/2419-armbian-for-amlogic-s905-and-s905x/

Flash with Etcher to microSD

In the normal Android OS go to Update&Backup
Select aml_autoscript.zip, click Update
Device reboots directly into Ubuntu

Login: root
Initial password: 1234

Source:
https://www.youtube.com/watch?v=oIINJkV-des

sudo cp /media/me/BOOT/dtb-4.18.7-aml-s9xxx/meson-gxl-s905x-p212.dtb /media/me/BOOT/dtb.img 

WLAN does not work. 
Video is not accelerated. --> Maybe we need some proprietary drivers? LibreELEC better?

Install overlayroot to make it read-only

WORKING RELATIVELY WELL
Chomium launches in about 4 seconds


---

Image with 3.14.29 kernel from
https://forum.armbian.com/topic/2419-armbian-for-amlogic-s905-and-s905x/
link
https://mega.nz/#F!j9QSDQSQ!6WpasOlbZYIInfw6yo4phQ

copy p212 dtd

WLAN does not work. 
Video is not accelerated.

---

openSUSE Tumbleweed uses EFI and hence can boot on MANY ARM systems directly 
with auto-discovery of the hardware. But for this to work uBoot needs to
be installed to internal eMMC (which I did not do so far).
https://en.opensuse.org/HCL:AArch64_EFI
Default root password is "linux".

---

LibreELEC
Image for LePotato
It boots if reset button is pushed until we see the LibreELEC logo
This needs to be done just for the initial LibreELEC boot

https://kszaq.libreelec.tv/s905/8.2/device_trees/S905X/gxl_p212_2g.dtb does NOT work - box will be stuck at x96 boot screen

Similar devices

TODO

Bootloader

The bootloader (u-boot) is always started from EMMC /bootloader partition. If that one is non functional (empty), then it tries to load the bootloader from SD card, which needs to be prepared in a special way.

WARNING: This will render the device unbootable from the built-in memory! To empty the bootloader, dd if=/dev/zero of=/dev/bootloader or do it from u-boot via the serial console as described at https://docs.khadas.com/vim1/HowtoEraseEMMC.html#Serial-Mode-For-developers

More information:

In a nutshell:

fdisk so that there is only one partition on the SD card.
Pop the SD card into your PC, and make sure the disk is unmounted:

$ umount /dev/sdX1

Format the SD card as Fat32:

$ sudo mkfs.vfat /dev/sdX1

Run dd to write the u-boot blob into the first sector of SD card:

$ sudo dd if=u-boot.bin.sd.bin of=/dev/sdb conv=fsync,notrunc bs=1 count=444
$ sudo dd if=u-boot.bin.sd.bin of=/dev/sdb conv=fsync,notrunc bs=512 skip=1 seek=1

Eject the SD card from PC:

$ sudo eject /dev/sdX

BUT it seems that there is even a way to load u-boot from SD if there is already another u-boot installed on the machine. This is of course way safer to test things out. http://www.stane1983.com/index.php/2015/05/05/burning-img-file-to-amlogic-m8-devices-using-sdcard/ -- TO BE TRIED. Basically you need to add a aml_sdc_burn.ini file in addition to the above. If it is there, then it should boot u-boot from SD!

Amlogic USB update tool using WorldCup Device protocol

Amlogic USB update tool is a command line program, with Windows version and Linux version. The usage of this tool is like fastboot , which can upgrade partition mirrors in PC command line. In addition, command sets of this tools is more rich than fastboot protocol. Update tool use protocol called WorldCup Device to talk with Amlogic board. Lite version WorldCup device protocol is built in Amlogic SOC, so you can boot Amlogic SOC from USB cable using Update tool.

Wayland Mali OpenGL acceleration

Will this help only for 3D graphics or also for video playback, e.g., in Chomium and GNOME Videos?

Kernel and U-boot source are available from the official Amlogic website :

http://openlinux.amlogic.com/

Heavily changed 3.10/3.14 kernel for Android is available for up to GXM SoCs.

But since early 2017, a 4.9 port is also available for GXL and newer SoCs. New 4.9 kernel is used for "Linux" products, has support for Wayland Mali OpenGL acceleration.

Source: https://people.freedesktop.org/~narmstrong/lca2018-amlogic/#/section-8

OSMC

(NOTE: Please support the OSMC project by buying an officially supported box from them.)

The OSMC project has Vero 2 (S805) and Vero 3 = Vero 4K (S905x) boxes which are similar to other Amlogic based designs.

We can compare the dts of the OSMC boxes with the dts of stock boxes to find possible differences. FOr example, by comparing https://github.com/osmc/vero3-linux/blob/master/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts to https://github.com/osmc/vero3-linux/blob/master/arch/arm64/boot/dts/amlogic/vero3_2g_16g.dts we can see that the partitioning scheme is the same.

The diff is minimal:

$ diff Downloads/*dts
29c29
< 	model = "Amlogic";
---
> 	model = "Vero4K";
164d163
< 		logo_addr = "0x7d851000";
1025d1023
< 		sleep_time = <100>;
1100c1098
< 				min_state = <1000000>;
---
> 				min_state = <667000>;
1145c1143
< 					temperature = <70000>;
---
> 					temperature = <95000>;
1150c1148
< 					temperature = <80000>;
---
> 					temperature = <105000>;
1155c1153
< 					temperature = <85000>;
---
> 					temperature = <114000>;
1160c1158
< 					temperature = <260000>;
---
> 					temperature = <118000>;
1220a1219,1223
> 
> &meson_ir {
> 	status = "okay";
> };
> 

However, trying to flash a Vero 4K / 4K + image from https://osmc.tv/download/ boots but says it cannot install. Most likely it checks for the v4kflash=verify bootenv variable, according to https://github.com/osmc/osmc/blob/7d616de2e4609a7fb51b1dbc51825f62558d2549/installer/target/qt_target/qt_target_installer/utils.cpp#L185-L188

NOTE: The OSMC developer states that by renaming boot.img to recovery.img you can force it to boot from SD.

Controlling LEDs

The following has been tested as root in LibreELEC.

# Specific to Device Tree (which is stored as Flattened Device Tree Blob, dtb)

cat "/sys/class/leds/librecomputer:system-status	/trigger"
[none] nand-disk timer oneshot heartbeat gpio cpu0 cpu1 cpu2 cpu3 default-on emmc sd sdio rfkill0 rc-feedback 

# Blink
echo heartbeat > "/sys/class/leds/librecomputer:system-status/trigger"

# Stop blink (need to set LED off manually)
echo 

oneshot > "/sys/class/leds/librecomputer:system-status/trigger"
echo 255 > "/sys/class/leds/librecomputer:system-status/brightness"

# ON
echo 0 > "/sys/class/leds/librecomputer:system-status/brightness"

# OFF
echo 255 > "/sys/class/leds/librecomputer:system-status/brightness"

I have also sucessfully done this in Golang.

References

@niclimcy
Copy link

niclimcy commented May 2, 2022

Do you have any pictures on which pins are the uart pins? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment