Subject: [PATCH] OLIMEX-Teres-A64: Official Support

From: Jacob Hrbek <[email-masked]>
Date: Tue, 07 Mar 2023 04:18:36 +0000

This contribution uses experience gained from
https://github.com/armbian/build/pull/4807 to implement an official
GNU Guix support for the OLIMEX Teres-A64 system.

Signed-off-by: Jacob Hrbek <[email-masked]>
---
 gnu/system/images/olimex-teres-a64.scm | 79 ++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 gnu/system/images/olimex-teres-a64.scm

diff --git a/gnu/system/images/olimex-teres-a64.scm b/gnu/system/images/olimex-teres-a64.scm
new file mode 100644
index 0000000000..7398ee9314
--- /dev/null
+++ b/gnu/system/images/olimex-teres-a64.scm
@@ -0,0 +1,79 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2020 Mathieu Othacehe <[email-masked]>
+;;; Copyright © 2023 Jacob Hrbek <[email-masked]>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; This file provides an official GNU Guix support for the OLIMEX Teres-A64
+
+(define-module (gnu system images olimex-teres-a64)
+  #:use-module (gnu bootloader)
+  #:use-module (gnu bootloader u-boot)
+  #:use-module (gnu image)
+  #:use-module (gnu packages linux)
+  #:use-module (guix platforms arm)
+  #:use-module (gnu services)
+  #:use-module (gnu services base)
+  #:use-module (gnu system)
+  #:use-module (gnu system file-systems)
+  #:use-module (gnu system image)
+  #:use-module (srfi srfi-26)
+  #:export (olimex-teres-a64-barebones-os
+            olimex-teres-a64-image-type
+            olimex-teres-a64-barebones-raw-image))
+
+(define olimex-teres-a64-barebones-os
+  (operating-system
+    (host-name "olimex")
+    (timezone "UTC")
+    (locale "en_US.utf8")
+    (bootloader (bootloader-configuration
+                 (bootloader u-boot-teres_i-bootloader)
+                 (targets '("/dev/mmcblk0"))))
+    (initrd-modules '())
+    (kernel linux-libre-arm64-generic)
+    (file-systems (cons (file-system
+                          (device (file-system-label "my-root"))
+                          (mount-point "/")
+                          (type "ext4"))
+                        %base-file-systems))
+    (services (cons (service agetty-service-type
+                             (agetty-configuration
+                              (baud-rate "115200")
+                              (term "vt100")
+                              (tty "ttyS0")))
+                    %base-services))))
+
+(define olimex-teres-a64-image-type
+  (image-type
+   (name 'pinebook-pro-raw)
+   (constructor (lambda (os)
+                  (image
+                   (inherit
+		    ;; All AllWinner SoCs will try to find a boot image at sector 16 (8KB) of an SD card [https://u-boot.readthedocs.io/en/latest/board/allwinner/sunxi.html#installing-u-boot]
+                    (raw-with-offset-disk-image (* 1024 8))) ; 1024 (sector size for 1 kilobyte) * 8 = 8196 sectors which is 8 KB)
+                   (operating-system os)
+                   (platform aarch64-linux))))))
+
+(define olimex-teres-a64-barebones-raw-image
+  (image
+   (inherit
+    (os+platform->image olimex-teres-a64-barebones-os aarch64-linux
+                        #:type olimex-teres-a64-image-type))
+   (name 'olimex-teres-a64-barebones-raw-image)))
+
+;; Return the default image.
+olimex-teres-a64-raw-image
--
2.37.3