From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id kA4nMOzqsmB8RQAAgWs5BA (envelope-from ) for ; Sun, 30 May 2021 03:31:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 8DlQK+zqsmBMBwAAbx9fmQ (envelope-from ) for ; Sun, 30 May 2021 01:31:24 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 14071206D8 for ; Sun, 30 May 2021 03:31:24 +0200 (CEST) Received: from localhost ([::1]:54806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnAIV-0003A4-1y for larch@yhetil.org; Sat, 29 May 2021 21:31:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnAIB-00039q-Jn for guix-patches@gnu.org; Sat, 29 May 2021 21:31:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46443) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnAIA-00021x-8x for guix-patches@gnu.org; Sat, 29 May 2021 21:31:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lnAIA-0003hP-3t for guix-patches@gnu.org; Sat, 29 May 2021 21:31:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48371] Add crust firmware for sunxi devices Resent-From: Vagrant Cascadian Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 30 May 2021 01:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48371 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Maxime Devos , 48371@debbugs.gnu.org Received: via spool by 48371-submit@debbugs.gnu.org id=B48371.162233824214197 (code B ref 48371); Sun, 30 May 2021 01:31:02 +0000 Received: (at 48371) by debbugs.gnu.org; 30 May 2021 01:30:42 +0000 Received: from localhost ([127.0.0.1]:57989 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnAHq-0003gu-C6 for submit@debbugs.gnu.org; Sat, 29 May 2021 21:30:42 -0400 Received: from cascadia.aikidev.net ([173.255.214.101]:40672) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnAHo-0003gh-JM for 48371@debbugs.gnu.org; Sat, 29 May 2021 21:30:41 -0400 Received: from localhost (unknown [IPv6:2600:3c01:e000:21:21:21:0:100b]) (Authenticated sender: vagrant@cascadia.debian.net) by cascadia.aikidev.net (Postfix) with ESMTPSA id 2A8041A904; Sat, 29 May 2021 18:30:31 -0700 (PDT) From: Vagrant Cascadian In-Reply-To: <87r1hpf3br.fsf@yucca> References: <87o8dgrk70.fsf@yucca> <334cfe187104a05a822dadd12436bc37dd1fcbb1.camel@telenet.be> <87r1hpf3br.fsf@yucca> Date: Sat, 29 May 2021 18:30:26 -0700 Message-ID: <87o8ctf1ot.fsf@yucca> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1622338284; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post; bh=D+wN+jKM/hWgRs3L6++m/OwTIRtQvHUg6EaYCa6uADc=; b=eZIsIjKNrIXEAwAugiLVzt4cg9jG5CdpLkJI0B4W4FWGycKcFDW0fVjOaO3Y/lJAL6tGsO xuDiP81oQON8EylgJE2YP9FNpTq/4jC9P3QrXuIWwH4GvFAFIkCUyyoyMh2pCxBVVNikYL ND1B2CNnoGBgTbcwkhN+mFwnx8Nj7W5dm8i3mAVC2cq0Khmg4dbm5d5hXAJ4/EQF8OWuIr PLtBDnnCIPYi2MmWaS6JilnvCsOgRd3kp3Q9VNxUAtPL6AGt6sH/1LZzGh+fqbKUPTITP/ ytESyBIQDs1SGlEimPckj9wrkaVHka9e0jdSjKUn8Wut0p72gdSg7DOwmCguOA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622338284; a=rsa-sha256; cv=none; b=pYiX52AjT5D/C++VtH90USj6s6adveW+v6PXjEQe3W7OzYHwA7B+/VGcfWNVUHZzkPdUZY zqd9WdfFJHlycQhoQKanHElr3SoYqcJF/wHmLu2+R1S5wkszMXUPPNdVCPf2cIq6/64TUn inzvqDRW/8RXI5qjaVF6aolqtHV9bTtEGmBL6lWVRLPq3ByCULDz2jFQGG/zXT6tkaJQ2b 2lYvxQY4zHgua6Kw8wNKvTdJC4/zmYkzjoR+eYlVo407/8JNDqvquv+wzTcWfC1TQz60fD M8KmIVgD+XmC6wwzWLxKOPvAcED9O/Go0kbA6gpIEdVZyDxR6dJhszZmY//I0g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -4.03 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 14071206D8 X-Spam-Score: -4.03 X-Migadu-Scanner: scn0.migadu.com X-TUID: oQnM8vP5qTHS --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain On 2021-05-29, Vagrant Cascadian wrote: > On 2021-05-13, Maxime Devos wrote: >> Vagrant Cascadian schreef op di 11-05-2021 om 15:15 [-0700]: >>> + #:make-flags (list >>> + "CROSS_COMPILE=or1k-elf-" >>> + "DEBUG=1" >>> + "HOSTCC=gcc" >>> + "HOSTAR=ar" >>> + "HOST_COMPILE=aarch64-linux-gnu-" >>> + "LEX=flex") >> >> IIUC, CROSS_COMPILE is the system Crust will run on, and HOST_COMPILE >> is the system where Crust is compiled. So shouldn't HOST_COMPILE be >> >> (string-append (nix-system->gnu-triplet (%current-system)) "-") >> >> such that Crust can be cross-compiled from non-aarch64 or non-linux systems? > > Good point! ... > Setting HOST_COMPILE to an empty value appears to work and it just uses > the defined HOSTCC and HOSTAR, so this is probably better anyways! Or dropping it entirely; it was only used to define HOSTCC and HOSTAR, which we set explicitly. > There's a new crust version available, so I'll give that a quick test > before sending updated patches. Updated patches attached. live well, vagrant --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-gnu-Add-crust-pinebook-and-crust-pine64-plus.patch Content-Transfer-Encoding: quoted-printable From=2075dff89f75481cea087890d28568017996e88da5 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. =2D-- 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 =2D-- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -315,6 +315,7 @@ or false to signal an error." ((string=3D? system "i686-mingw") "no-ld.so") ((string=3D? system "x86_64-mingw") "no-ld.so") ((string=3D? system "vc4-elf") "no-ld.so") + ((string=3D? system "or1k-elf") "no-ld.so") =20 (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 =2D-- 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 platfo= rm) + "_" "-"))) + (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=3Dor1k-elf-" + "DEBUG=3D1" + "HOSTCC=3Dgcc" + "HOSTAR=3Dar" + "LEX=3Dflex") + #:tests? #f)) ; no tests + ;; The firmware is cross-compiled using a "bare bones" compiler (no li= bc.) + ;; Use our own tool chain for that. + (native-inputs `(("cross-gcc" ,(cross-gcc "or1k-elf" #:xgcc gcc-9)) + ("cross-binutils" ,(cross-binutils "or1k-elf" binutil= s)) + ("bison" ,bison) + ("flex" ,flex))) + (home-page "https://github.com/crust-firmware/crust") + (synopsis "System control processor firmware for Allwinner sunxi board= s") + (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 8= 0% +or more compared to an idle device. On boards without a PMIC, Crust is al= so +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")) =2D-=20 2.30.2 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-gnu-u-boot-Add-crust-firmware-to-pinebook-pine64_plu.patch Content-Transfer-Encoding: quoted-printable From=20719fc2874daa5fd5772c2c0d146e8d6fb9f1377b Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian Date: Tue, 11 May 2021 21:15:15 +0000 Subject: [PATCH 2/2] gnu: u-boot: Add crust firmware to pinebook, pine64_pl= us and pine64-lts. * gnu/packages/bootloaders.scm (make-u-boot-sunxi64-package): Take argument for System Control Processor (SCP) firmware. [native-inputs]: Add SCP firmware. (u-boot-pine64-plus, u-boot-pine64-lts, u-boot-pinebook): Pass appropriate crust firmware as the SCP firmware. =2D-- gnu/packages/bootloaders.scm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm index 56bef57cb7..6f1bb5b8c9 100644 =2D-- a/gnu/packages/bootloaders.scm +++ b/gnu/packages/bootloaders.scm @@ -737,7 +737,7 @@ it fits within common partitioning schemes.") (define-public u-boot-am335x-evm (make-u-boot-package "am335x_evm" "arm-linux-gnueabihf")) =20 =2D(define-public (make-u-boot-sunxi64-package board triplet) +(define-public (make-u-boot-sunxi64-package board triplet scpfirmware) (let ((base (make-u-boot-package board triplet))) (package (inherit base) @@ -752,6 +752,9 @@ it fits within common partitioning schemes.") (assoc-ref (or native-inputs inputs) "firmware") "/bl31.bin"))) (setenv "BL31" bl31) + (setenv "SCP" (string-append + (assoc-ref inputs "scpfirmware") + "/scp.bin")) ;; This is necessary when we're using the bundled dtc. ;(setenv "PATH" (string-append (getenv "PATH") ":" ; "scripts/dtc")) @@ -759,16 +762,20 @@ it fits within common partitioning schemes.") #t)))))) (native-inputs `(("firmware" ,arm-trusted-firmware-sun50i-a64) + ("scpfirmware" ,scpfirmware) ,@(package-native-inputs base)))))) =20 (define-public u-boot-pine64-plus =2D (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu")) + (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu" + crust-pine64-plus)) =20 (define-public u-boot-pine64-lts =2D (make-u-boot-sunxi64-package "pine64-lts" "aarch64-linux-gnu")) + (make-u-boot-sunxi64-package "pine64-lts" "aarch64-linux-gnu" + crust-pine64-plus)) =20 (define-public u-boot-pinebook =2D (let ((base (make-u-boot-sunxi64-package "pinebook" "aarch64-linux-gnu= "))) + (let ((base (make-u-boot-sunxi64-package "pinebook" "aarch64-linux-gnu" + crust-pinebook))) (package (inherit base) (arguments =2D-=20 2.30.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRlgHNhO/zFx+LkXUXcUY/If5cWqgUCYLLqswAKCRDcUY/If5cW qjLFAQCKUtPihvbN7kkwzLn6tNfY9Jyzutg/2Qys87HBDC0C0QD+JtwgmgTodfoQ 5gHbPLx3PLrZelSoozwPt3XdNKJjdQs= =KBTG -----END PGP SIGNATURE----- --==-=-=--