Jump to content

Amlogic S905

From postmarketOS Wiki
Revision as of 17:58, 29 April 2023 by Exkc (talk | contribs) (Status)
Amlogic S905/
S905-H
Amlogic S905
Amlogic S905
Manufacturer Amlogic
Name S905/
S905-H
Architecture aarch64
CPU 4x 2 GHz Cortex-A53
GPU Mali-450
Year 2015
Process 28nm
Mainline yes
Community Page https://linux-meson.com/
Components
CPU
Works
UART
Works
Storage
Partial
USB
Works
Display
Works
GPU
Works
Pinctrl
Works
I²C
Works
SPI
No data
Audio
Works
Video
Partial
Thermal
Works
NPU
No data
Suspend
Broken
Ethernet
No data
SATA
No data

The Amlogic S905, also known as Meson GXBB in the Linux kernel, is a high-end media player SoC mainly used in Android set top boxes. It's capable of hardware decoding up to 4K@60fps, for multiple formats including H.264, AVS+, and 10-bit, and part of the S9 family of Amlogic chipsets.

There's also the Amlogic S905-H SoC, which merely just includes Dolby licenses.

Devices

Device Codename Chipset Mainline booting
Videostrong KII Pro videostrong-kii-pro Amlogic S905 Y Yes

Status

GPU and hardware acceleration

Works. Lima is used for hardware acceleration.

IR RX

Works. Be sure to include the right IR decoders into your kernel (e.g. NEC on Videostrong KII Pro (videostrong-kii-pro)), but otherwise doesn't require much configuration.

Audio

Works. Requires a device tree patch on the Videostrong KII Pro (videostrong-kii-pro), that adds the appropriate nodes (else the card is never pobed) which is slowly making its way upstream. HDMI audio works, but S/PDIF is untested.

Hardware decoding and encoding

The Amlogic S905(-H) supports hardware decoding up to 4K@60fps, but in the mainline kernel it's limited to 1080p. Downstream kernels relied on lengthy hacks to get it working up to 4K, and thus they were not included in the mainline kernel (to their defense Amlogic did successfully enable 4K playback on 3.x kernels).

Suspend

Note Does the S905(-H) have the ability to sleep?

DVB

Needs a demux driver.

HDMI

Works.

USB-A

Works.

OTG

Untested. Broken according to linux-meson.com

TODO TODO: Add more sections...


How to build uboot for s905

  • Create a working directory
$ mkdir u-boot-kii-pro
$ cd u-boot-kii-pro
  • Build U-Boot
$ git clone https://git.vitali64.duckdns.org/misc/u-boot-kii-pro.git -b wip/kii-pro u-boot
$ cd u-boot
$ make videostrong-kii-pro_defconfig
$ make # CROSS_COMPILE=...
$ cd ..

Building and bundling the FIP

  • Get the binaries required to build the FIP (BL2, BL31, ...) and meson-tools, and install ARM Trusted Firmware utilities
$ git clone https://github.com/LibreELEC/amlogic-boot-fip.git fip
$ git clone https://github.com/afaerber/meson-tools.git
# apk add arm-trusted-firmware-tools # if using an Alpine-based system
  • Build amlbootsig from meson-tools
$ cd meson-tools
$ make amlbootsig
$ cd ..
  • Build the FIP
$ cd fip/wetek-play2 # we use the WeTek Play2 binaries for building the FIP
$ cp ../../u-boot/u-boot.bin ./bl33.bin

$ ./blx_fix.sh \
           ./bl30.bin \
           ./zero_tmp \
           ./bl30_zero.bin \
           ./bl301.bin \
           ./bl301_zero.bin \
           ./bl30_new.bin \
           bl30

$ dd if=bl31.img of=bl31_noheader.bin bs=1 skip=496 count=16
$ dd if=bl31.img of=bl31_noheader.bin skip=1

$ fiptool create \
           --align 0x4000 \
           --scp-fw ./bl30_new.bin \
           --soc-fw ./bl31_noheader.bin \
           --nt-fw  ./bl33.bin \
                    ./fip.bin

$ sed -i 's/\x73\x02\x08\x91/\x1F\x20\x03\xD5/' ./bl2.bin
$ python3 ./acs_tool.py ./bl2.bin ./bl2_acs.bin ./acs.bin 0
$ ./blx_fix.sh \
           ./bl2_acs.bin \
           ./zero_tmp \
           ./bl2_zero.bin \
           ./bl21.bin \
           ./bl21_zero.bin \
           ./bl2_new.bin \
           bl2

$ cat ./bl2_new.bin ./fip.bin > ./boot_new.bin

$ ../../meson-tools/amlbootsig \
           --input  ./boot_new.bin
           --output ./u-boot.bin

$ dd if=./u-boot.bin of=./u-boot.bin.gxbb bs=512 conv=fsync
$ dd if=./u-boot.bin of=./u-boot.bin.gxbb bs=512 seek=9 skip=8 count=87 conv=fsync,notrunc
$ dd if=/dev/zero of=./u-boot.bin.gxbb bs=512 seek=8 count=1 conv=fsync,notrunc
$ dd if=bl1.bin.hardkernel of=./u-boot.bin.gxbb bs=512 seek=2 skip=2 count=1 conv=fsync,notrunc
$ ./aml_chksum u-boot.bin.gxbb
  • Write to an SD card
# DEV=mmcblk0 # replace with your SD card device
# dd if=u-boot.bin.gxbb of=/dev/$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
# dd if=u-boot.bin.gxbb of=/dev/$DEV conv=fsync,notrunc bs=1 count=444

How to boot

  • On the set-top box, boot postmarketOS and erase the eMMC THIS WILL WIPE EVERYTHING. BE SURE THAT YOU HAVE A BACKUP
# DEV=mmcblk1 # replace mmcblk1 with your eMMC device
# dd if=/dev/zero of=/dev/${DEV}
# dd if=/dev/zero of=/dev/${DEV}boot0
# dd if=/dev/zero of=/dev/${DEV}boot1
  • Power off
  • Insert the SD card where you wrote the U-Boot binary
  • Power on

See also