Support for Amlogic SoC

  • Open
  • quality assurance status badge
Details
One participant
  • phodina
Owner
unassigned
Submitted by
phodina
Severity
normal
P
P
phodina wrote on 13 Dec 2022 20:27
C2ORkCSHJz-4jxwCauZznk4tZlP9KS4u_3Ywe4q2QrfJ7tvIswRWw4vX6OuzXDIHRriNNTQaCiYC67GgL30p8g80J9OcduCgaoZ8XNf-amE=@protonmail.com
Hi,

this patch set adds support for running on Amlogic SoC devices which can be found on multiple Android TV boxes.

Most of the open source work has been done by BayLibre (thanks guys) and they upstreamed lot of code already. [1]

The Android OS on the boxes from the manufacturer can currently be replaced with LibreELEC [2] or Armbian. [3]

However, there are still some patches pending and there's huge variety of the boards. The patches will be removed once more
and more of them get accepted into the upstream.

Therefore I put all the patches into one commit and added another variable that build Linux kernel - resource intensive task.
Is this the right approach? Or git repo with the patches applied is better approach?

The aim is to add tools to Guix to be able to prepare the image for the TV boxes and liberate the living rooms :-)

Of course there will still be some black magic behind the firmware (bl2.bin, acs.bin, bl30.bin, bl301.bin) - something
similar to Raspberry Pi. Nevertheless, that's not part of the patches and it comes with the device and we can just replace
the Android OS on top. Alternatively it can be downloaded and put together if somebody needs the whole image. [4]

[1] https://linux-meson.com/mainlining.html[2]https://libreelec.tv/[3] https://github.com/ophub/amlogic-s9xxx-armbian[4]https://u-boot.readthedocs.io/en/latest/board/amlogic/p212.html

----
Petr
Attachment: file
From 8f3a2983b5d4d1c196b2193a2089e0b15235d309 Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Tue, 13 Dec 2022 10:16:38 +0100
Subject: [PATCH 3/5] gnu: Add ampart.

* gnu/packages/firmware.scm (ampart): New variable.

Toggle diff (52 lines)
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 2826dfd131..764d4e2a88 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -7,7 +7,7 @@
;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020, 2021, 2022 Marius Bakke <marius@gnu.org>
-;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
+;;; Copyright © 2021, 2022 Petr Hodina <phodina@protonmail.com>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -76,6 +76,36 @@ (define-module (gnu packages firmware)
#:use-module (gnu packages web)
#:use-module (gnu packages xml))
+(define-public ampart
+ (package
+ (name "ampart")
+ (version "1.1")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://github.com/7Ji/ampart/archive/refs/tags/v" version
+ ".tar.gz"))
+ (sha256
+ (base32
+ "0b7j48iddcr9gld5dsmcqjxa97759xkgbda971cqdd29y3q5p9fb"))))
+ (build-system gnu-build-system)
+ (arguments (list
+ #:tests? #f ; no test suite
+ #:make-flags #~(list (string-append "CC=" #$(cc-for-target)))
+ #:phases
+ #~(modify-phases %standard-phases
+ (delete 'configure)
+ (replace 'install
+ (lambda _
+ (mkdir-p (string-append #$output "/bin"))
+ (install-file "ampart" (string-append #$output "/bin")))))))
+ (propagated-inputs (list zlib))
+ (home-page "https://github.com/superna9999/pyamlboot")
+ (synopsis "Partition tool for Amlogic's proprietary eMMC partition format")
+ (description "This packages provides partition tool for Amlogic's
+proprietary eMMC partition format.")
+ (license license:gpl3+)))
+
(define-public pyamlboot
(package
(name "pyamlboot")
--
2.38.1
From 9701fd468aa8b88e3505b8cfdca9fcaaa4031816 Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Tue, 13 Dec 2022 09:57:43 +0100
Subject: [PATCH 2/5] gnu: Add pyamlboot.

* gnu/packages/firmware.scm (pyamlboot): New variable.

Toggle diff (47 lines)
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index e9bb3ed450..2826dfd131 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -34,6 +34,7 @@ (define-module (gnu packages firmware)
#:use-module (guix git-download)
#:use-module (guix build-system gnu)
#:use-module (guix build-system meson)
+ #:use-module (guix build-system python)
#:use-module (gnu packages)
#:use-module (gnu packages admin)
#:use-module (gnu packages autotools)
@@ -67,6 +68,7 @@ (define-module (gnu packages firmware)
#:use-module (gnu packages polkit)
#:use-module (gnu packages protobuf)
#:use-module (gnu packages python)
+ #:use-module (gnu packages python-build)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages tls)
@@ -74,6 +76,24 @@ (define-module (gnu packages firmware)
#:use-module (gnu packages web)
#:use-module (gnu packages xml))
+(define-public pyamlboot
+ (package
+ (name "pyamlboot")
+ (version "1.0.0")
+ (source (origin
+ (method url-fetch)
+ (uri (pypi-uri "pyamlboot" version))
+ (sha256
+ (base32
+ "0ivm6h118y6fsk4xfan5nkdsbyds52qpr98zjfa1ilrswyyddj49"))))
+ (build-system python-build-system)
+ (propagated-inputs (list python-pyusb python-setuptools))
+ (home-page "https://github.com/superna9999/pyamlboot")
+ (synopsis "Amlogic SoC USB Boot utility")
+ (description "This package provides USB Boot utility to interact with the
+ MaskROM on Amlogic SoC.")
+ (license license:asl2.0)))
+
(define-public ath9k-htc-firmware
(package
(name "ath9k-htc-firmware")
--
2.38.1
From 988c3333e13dff9286d8e8a281059e88b77af9d1 Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Tue, 13 Dec 2022 10:38:11 +0100
Subject: [PATCH 4/5] gnu: Add gxlimg.

* gnu/packages/firmware.scm (gxlimg): New variable.

Toggle diff (36 lines)
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 764d4e2a88..d42340f061 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -338,6 +338,29 @@ (define-public fwupd
automatic, safe and reliable. It is used by tools such as GNOME Software.")
(license license:lgpl2.1+)))
+(define-public gxlimg
+(let ((commit "15be56b1f1e2a319227d599a0b7afb0673e9cb9b")
+ (revision "1"))
+ (package
+ (name "gxlimg")
+ (version "1.1")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/repk/gxlimg")
+ (commit commit)))
+ (sha256
+ (base32
+ "0h96834i27sfzn7nvmqk0rwzxk5axiq9mm6ql3yaz81qd8slpljv"))))
+ (build-system meson-build-system)
+ (inputs (list openssl))
+ (native-inputs (list pkg-config))
+ (home-page "https://github.com/repk/gxlimg")
+ (synopsis "Boot Image creation tool for amlogic s905x")
+ (description "@code{Gxlimg} is an amlogic s905x boot image creation
+tools.")
+ (license license:bsd-2))))
+
(define-public openfwwf-firmware
(package
(name "openfwwf-firmware")
--
2.38.1
From ba0d032d3f99e588bbf0428940b5f21f3fe0b59d Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Tue, 13 Dec 2022 10:58:39 +0100
Subject: [PATCH 5/5] gnu: Add u-boot-amlogic.

* gnu/packages/bootloaders.scm (u-boot-amlogic): New variable.

Toggle diff (21 lines)
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 8888c51736..bd9ae06ded 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -886,6 +886,14 @@ (define*-public (make-u-boot-package board triplet
uboot-files)
#t)))))))))
+(define %u-boot-amlogic-description-64-bit
+ "This is a common 64-bit build of U-Boot for all 64-bit capable Amlogic s905x
+variants.")
+
+(define-public u-boot-amlogic
+ (make-u-boot-package "p212" "aarch64-linux-gnu"
+ #:append-description %u-boot-amlogic-description-64-bit))
+
(define-public u-boot-malta
(make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
--
2.38.1
?