Board sticker: M8S PRO R4 S912 3G 32G DDR4 DQ

Contents: [Dobrica Pavlinušić's random unstructured stuff]
• Dobrica Pavlinušić's random unstructured stuff (Android info) 
• Dobrica Pavlinušić's random unstructured stuff (recovery sd) 
• Dobrica Pavlinušić's random unstructured stuff (amlogic info) 
• Dobrica Pavlinušić's random unstructured stuff (armbian) 
• Dobrica Pavlinušić's random unstructured stuff (ath10k wifi sdio firmware) 
• Dobrica Pavlinušić's random unstructured stuff (kernel source) 
• Dobrica Pavlinušić's random unstructured stuff (u‑boot source) 
• Dobrica Pavlinušić's random unstructured stuff (balbes150 updates) 
• Dobrica Pavlinušić's random unstructured stuff (gpiod) 
• Dobrica Pavlinušić's random unstructured stuff (button ‑ gpio 2) 
• Dobrica Pavlinušić's random unstructured stuff (led ‑ gpio 9) 
• Dobrica Pavlinušić's random unstructured stuff (u‑boot) 
• Dobrica Pavlinušić's random unstructured stuff (2020‑10 status for amlogic) 

It doesn't have button soldered, it works like power button in android
Serial port is marked on bottom of board (tx/rx are from cpu perspective)
probably: https://www.geekbuying.com/item/MECOOL‑M8S‑PRO‑S912‑KODI‑17‑0‑4K‑HDR10‑3GB‑DDR4‑32GB‑eMMC‑TV‑Box‑380737.html 
Android info
Android 7.1 bootlog from serial: m8s‑android‑bootlog.txt.gz 
U-Boot 2015.01-g9331ff1-dirty (Mar 15 2018 - 16:16:24)

DRAM:  3 GiB
...
        aml_dt soc: gxm platform: q20xrmii variant: 3g
        dtb 0 soc: gxm   plat: q20xrmii   vari: 2g
        dtb 1 soc: gxm   plat: q20xrmii   vari: 3g
      Find match dtb: 1
...
parts: 10
00:      logo   0000000002000000 1
01:  recovery   0000000002000000 1
02:       rsv   0000000000800000 1
03:       tee   0000000000800000 1
04:     crypt   0000000002000000 1
05:      misc   0000000002000000 1
06:      boot   0000000002000000 1
07:    system   0000000080000000 1
08:     cache   0000000020000000 2
09:      data   ffffffffffffffff 4

M8SPRO:/ # uname -a
Linux localhost 3.14.29 #46 SMP PREEMPT Thu Apr 12 19:43:12 CST 2018 armv8l

M8SPRO:/ # cat /proc/cmdline
rootfstype=ramfs init=/init console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0 ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 androidboot.selinux=permissive logo=osd1,loaded,0x3d800000,1080p60hz maxcpus=8 vout=1080p60hz,enable hdmimode=1080p60hz cvbsmode=576cvbs hdmitx= cvbsdrv=0 pq= androidboot.firstboot=0 jtag=apao androidboot.hardware=amlogic mac=D0:76:58:0E:63:A3 androidboot.mac=D0:76:58:0E:63:A3 androidboot.slot_suffix=_a buildvariant=userdebug

M8SPRO:/ # cat /proc/cpuinfo
Processor       : AArch64 Processor rev 4 (aarch64)
processor       : 0
processor       : 1
processor       : 2
processor       : 3
processor       : 4
processor       : 5
processor       : 6
processor       : 7
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 wp half thumb fastmult vfp edsp neon vfpv3 tlsi vfpv4 idiva idivt 
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

Hardware        : Amlogic
Serial          : 220a82006da41365fedf301742726826

M8SPRO:/ # free
                total        used        free      shared     buffers
Mem:       2876604416  2210639872   665964544           0    31326208
-/+ buffers/cache:     2179313664   697290752
Swap:       524283904           0   524283904

M8SPRO:/ # df
ilesystem        1K-blocks    Used Available Use% Mounted on
mpfs               1404592     504   1404088   1% /dev
tmpfs               1404592       0   1404592   0% /mnt
/dev/block/system   2031440  973788   1057652  48% /system
/dev/block/data    26969964 3050864  23919100  12% /data
/dev/block/cache     507848    2860    504988   1% /cache
/dev/block/tee         5115      45      5070   1% /tee
/dev/fuse          26969964 3050864  23919100  12% /mnt/runtime/default/emulated
/dev/fuse          26969964 3050864  23919100  12% /mnt/runtime/read/emulated
/dev/fuse          26969964 3050864  23919100  12% /mnt/runtime/write/emulated

recovery sd
https://www.cnx‑software.com/2016/11/19/how‑to‑create‑a‑bootable‑recovery‑sd‑card‑for‑amlogic‑tv‑boxes/ 
amlogic info
http://www.linux‑meson.com/doku.php 
armbian
https://forum.armbian.com/topic/12162‑single‑armbian‑image‑for‑rk‑aml‑aw‑aarch64‑armv8/ 
dpavlin@nuc:~/Downloads$ xzcat Armbian_20.09_Arm-64_bullseye_current_5.8.5.img.xz | dd iflag=fullblock oflag=direct conv=fsync status=progress bs=1M of=/dev/sdb
dpavlin@nuc:~/Downloads$ sudo mount /dev/sdb1 /mnt/sdb1/
dpavlin@nuc:~/Downloads$ cd /mnt/sdb1/

root@nuc:/mnt/sdb1# cp u-boot-s905x-s912 u-boot.ext

root@nuc:/mnt/sdb1# vi extlinux/extlinux.conf

root@nuc:/mnt/sdb1# grep -v '^#' extlinux/extlinux.conf
LABEL Armbian
LINUX /zImage
INITRD /uInitrd

FDT /dtb/amlogic/meson-gxm-q201.dtb
APPEND root=LABEL=ROOTFS rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0

Note that this board uses meson‑gxm‑q201.dtb which is internal rmii to make ethernet work!
issue reboot update from android shell to boot from sdcard
ath10k wifi sdio firmware
After booting, you will get error message about missing firmware:
[    7.861827] ath10k_sdio mmc2:0001:1: Failed to find firmware-N.bin (N between 2 and 6) from ath10k/QCA9377/hw1.0: -2
[    7.861838] ath10k_sdio mmc2:0001:1: could not fetch firmware files (-2)

Package firmware‑atheros is installed, so it's a bit puzzeling what file is missing, however, if we go to
https://github.com/kvalo/ath10k‑firmware.git 
we can find sdio firmware at https://github.com/kvalo/ath10k‑firmware/tree/master/QCA9377/hw1.0/untested 
dpavlin@m8s:~/ath10k-firmware$ git remote -v
origin  https://github.com/kvalo/ath10k-firmware.git (fetch)
origin  https://github.com/kvalo/ath10k-firmware.git (push)

dpavlin@m8s:~/ath10k-firmware$ sudo cp QCA9377/hw1.0/untested/firmware-sdio-5.bin_WLAN.TF.1.1.1-00061-QCATFSWPZ-1 /lib/firmware/ath10k/QCA9377/hw1.0/firmware-sdio-5.bin

After running nmtui and configuring wifi it's available but dies after a while under load.
kernel source
https://github.com/150balbes/Amlogic_s905‑kernel 
currently, I'm using
dpavlin@m8s:~/linux$ git remote -v
origin  https://github.com/xdarklight/linux (fetch)
origin  https://github.com/xdarklight/linux (push)
dpavlin@m8s:~/linux$ git branch
  master
  meson-mx-integration-5.11-20210124
  meson-mx-integration-5.13-20210503
* meson-mx-integration-5.13-20210523
dpavlin@m8s:~/linux$ cat mason-build.sh
# https://github.com/SLAzurin/armbian-aml-s8xx-kernel-build-steps

# https://github.com/xdarklight/linux

make -j 8 Image dtbs modules && sudo make modules_install dtbs_install install

Installing armbian kernel package doesn't work because /boot partition is vfat and not ext2/4
u‑boot source
https://github.com/150balbes/Amlogic_S905‑u‑boot 
balbes150 updates
installing linux image and headers does return error, but works
https://users.armbian.com/balbes150/ 
gpiod
sudo apt install gpiod

button ‑ gpio 2
root@arm-64:~# gpioget gpiochip0 2 # not pressed
1
root@arm-64:~# gpioget gpiochip0 2 # pressed
0

led ‑ gpio 9
root@arm-64:~# gpioset gpiochip0 9=0 # red

root@arm-64:~# gpioset gpiochip0 9=1 # blue (default)

u‑boot
old https://github.com/endlessm/u‑boot‑meson 
I wanted serial console which seems to be missing from armbian build above
wiki seems to suggest repository
https://gitlab.denx.de/u‑boot/custodians/u‑boot‑amlogic 
but we are going to use upstream u‑boot
dpavlin@m8s:~/u-boot-amlogic$ git remote -v
github  https://github.com/u-boot/u-boot (fetch)

dpavlin@m8s:~/u-boot-amlogic$ libretech-cc_defconfig
dpavlin@m8s:~/u-boot-amlogic$ make -j 8
dpavlin@m8s:~/u-boot-amlogic$ cp u-boot.bin /boot/

abort u‑boot with key press and boot new one with
fatload mmc 1 0x1000000 u-boot.bin
go 0x1000000

2020‑10 status for amlogic
U‑Boot: Porting and Maintaining a Bootloader for a Multimedia SoC Family ‑ Neil Armstrong, BayLibre SAS
https://youtu.be/u0‑swEMDFp0