From 75dff89f75481cea087890d28568017996e88da5 Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian Date: Tue, 11 May 2021 20:57:50 +0000 Subject: [PATCH 1/2] gnu: Add crust-pinebook and crust-pine64-plus. * gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add or1k-elf. gnu/packages/firmware.scm (make-crust-package, crust-pinebook, crust-pine64-plus): New variables. --- gnu/packages/bootstrap.scm | 1 + gnu/packages/firmware.scm | 70 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm index c598cedc0a..b23ac04586 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -315,6 +315,7 @@ or false to signal an error." ((string=? system "i686-mingw") "no-ld.so") ((string=? system "x86_64-mingw") "no-ld.so") ((string=? system "vc4-elf") "no-ld.so") + ((string=? system "or1k-elf") "no-ld.so") (else (error "dynamic linker name not known for this system" system)))) diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm index c9a68f5a93..4b6dbdb733 100644 --- a/gnu/packages/firmware.scm +++ b/gnu/packages/firmware.scm @@ -559,3 +559,73 @@ such as: `(("cross32-gcc" ,(cross-gcc "arm-none-eabi")) ("cross32-binutils", (cross-binutils "arm-none-eabi")) ,@(package-native-inputs base)))))) + +(define (make-crust-package platform) + (package + (name (string-append "crust-" + (string-replace-substring (string-downcase platform) + "_" "-"))) + (version "0.4") + (source + (origin + (method git-fetch) + (uri (git-reference + ;; There are only GitHub generated release snapshots. + (url "https://github.com/crust-firmware/crust") + (commit (string-append "v" version)))) + (file-name (git-file-name "crust" version)) + (sha256 + (base32 + "19xxp43b6dhdfssahspyl7y15dbby0kfbfqnmhc42vz1hkp7b4q6")))) + (build-system gnu-build-system) + (arguments + `(#:phases + (modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'defconfig + (lambda* (#:key outputs make-flags #:allow-other-keys) + (let ((config-name (string-append ,platform "_defconfig"))) + (apply invoke "make" `(,@make-flags ,config-name))))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out")) + (bin (find-files "." "(scp.bin|\\.config)"))) + (for-each + (lambda (file) + (install-file file out)) + bin)) + #t))) + #:make-flags (list + "CROSS_COMPILE=or1k-elf-" + "DEBUG=1" + "HOSTCC=gcc" + "HOSTAR=ar" + "LEX=flex") + #:tests? #f)) ; no tests + ;; The firmware is cross-compiled using a "bare bones" compiler (no libc.) + ;; Use our own tool chain for that. + (native-inputs `(("cross-gcc" ,(cross-gcc "or1k-elf" #:xgcc gcc-9)) + ("cross-binutils" ,(cross-binutils "or1k-elf" binutils)) + ("bison" ,bison) + ("flex" ,flex))) + (home-page "https://github.com/crust-firmware/crust") + (synopsis "System control processor firmware for Allwinner sunxi boards") + (description + "Crust improves battery life and thermal performance by implementing a +deep sleep state. During deep sleep, the CPU cores, the DRAM controller, and +most onboard peripherals are powered down, reducing power consumption by 80% +or more compared to an idle device. On boards without a PMIC, Crust is also +responsible for orderly power-off and power-on of the device. + +For this to work, Crust runs outside the main CPU and DRAM, on a dedicated +always-on microprocessor called a System Control Processor (SCP). Crust is +designed to run on a specific SCP implementation, Allwinner's AR100.") + ;; Most files are dual-licensed "BSD-3 OR GPL2", a few are GPL2 only. + (license (list license:bsd-3 + license:gpl2)))) + +(define-public crust-pinebook + (make-crust-package "pinebook")) + +(define-public crust-pine64-plus + (make-crust-package "pine64_plus")) -- 2.30.2