* [bug#48371] Add crust firmware for sunxi devices
@ 2021-05-11 22:15 Vagrant Cascadian
2021-05-13 13:00 ` Maxime Devos
0 siblings, 1 reply; 5+ messages in thread
From: Vagrant Cascadian @ 2021-05-11 22:15 UTC (permalink / raw)
To: 48371
[-- Attachment #1.1: Type: text/plain, Size: 217 bytes --]
The attached patches add crust System Control Processor firmware for
pinebook, pine64+ and pine64-lts. Crust manages various power management
aspects for these platforms, notably suspend states.
live well,
vagrant
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-Add-crust-pinebook-and-crust-pine64-plus.patch --]
[-- Type: text/x-diff, Size: 4662 bytes --]
From f79a6bec79bd00ab3ecb0f874494df597bfa1990 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagrant@debian.org>
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 | 71 ++++++++++++++++++++++++++++++++++++++
2 files changed, 72 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..a057cbe516 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -559,3 +559,74 @@ 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.3")
+ (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
+ "1ncn2ncmkj1cjk68zrgr5yk7b9x1xxcrcmk9jf188svjgk0cq2m5"))))
+ (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"
+ "HOST_COMPILE=aarch64-linux-gnu-"
+ "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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-gnu-u-boot-Add-crust-firmware-to-pinebook-pine64_plu.patch --]
[-- Type: text/x-diff, Size: 2886 bytes --]
From 6939b8555f4d2ed57b4993c501686d5ccdf47703 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagrant@debian.org>
Date: Tue, 11 May 2021 21:15:15 +0000
Subject: [PATCH 2/2] gnu: u-boot: Add crust firmware to pinebook, pine64_plus
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.
---
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
--- 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"))
-(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))))))
(define-public u-boot-pine64-plus
- (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu"))
+ (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu"
+ crust-pine64-plus))
(define-public u-boot-pine64-lts
- (make-u-boot-sunxi64-package "pine64-lts" "aarch64-linux-gnu"))
+ (make-u-boot-sunxi64-package "pine64-lts" "aarch64-linux-gnu"
+ crust-pine64-plus))
(define-public u-boot-pinebook
- (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
--
2.30.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#48371] Add crust firmware for sunxi devices
2021-05-11 22:15 [bug#48371] Add crust firmware for sunxi devices Vagrant Cascadian
@ 2021-05-13 13:00 ` Maxime Devos
2021-05-30 0:55 ` Vagrant Cascadian
0 siblings, 1 reply; 5+ messages in thread
From: Maxime Devos @ 2021-05-13 13:00 UTC (permalink / raw)
To: Vagrant Cascadian, 48371
[-- Attachment #1: Type: text/plain, Size: 663 bytes --]
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?
Greetings,
Maxime.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [bug#48371] Add crust firmware for sunxi devices
2021-05-13 13:00 ` Maxime Devos
@ 2021-05-30 0:55 ` Vagrant Cascadian
2021-05-30 1:30 ` Vagrant Cascadian
0 siblings, 1 reply; 5+ messages in thread
From: Vagrant Cascadian @ 2021-05-30 0:55 UTC (permalink / raw)
To: Maxime Devos, 48371
[-- Attachment #1: Type: text/plain, Size: 1202 bytes --]
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!
Although I couldn't get it to work, always ending in:
ERROR: In procedure %resolve-variable:
Unbound variable: nix-system->gnu-triplet
firmware.scm includes:
#:use-module (guix utils)
Which is where I think that is defined, but...
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!
There's a new crust version available, so I'll give that a quick test
before sending updated patches.
live well,
vagrant
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [bug#48371] Add crust firmware for sunxi devices
2021-05-30 0:55 ` Vagrant Cascadian
@ 2021-05-30 1:30 ` Vagrant Cascadian
2023-07-07 20:07 ` bug#48371: " Maxim Cournoyer
0 siblings, 1 reply; 5+ messages in thread
From: Vagrant Cascadian @ 2021-05-30 1:30 UTC (permalink / raw)
To: Maxime Devos, 48371
[-- Attachment #1.1: Type: text/plain, Size: 1154 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-Add-crust-pinebook-and-crust-pine64-plus.patch --]
[-- Type: text/x-diff, Size: 4605 bytes --]
From 75dff89f75481cea087890d28568017996e88da5 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagrant@debian.org>
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-gnu-u-boot-Add-crust-firmware-to-pinebook-pine64_plu.patch --]
[-- Type: text/x-diff, Size: 2886 bytes --]
From 719fc2874daa5fd5772c2c0d146e8d6fb9f1377b Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagrant@debian.org>
Date: Tue, 11 May 2021 21:15:15 +0000
Subject: [PATCH 2/2] gnu: u-boot: Add crust firmware to pinebook, pine64_plus
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.
---
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
--- 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"))
-(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))))))
(define-public u-boot-pine64-plus
- (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu"))
+ (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu"
+ crust-pine64-plus))
(define-public u-boot-pine64-lts
- (make-u-boot-sunxi64-package "pine64-lts" "aarch64-linux-gnu"))
+ (make-u-boot-sunxi64-package "pine64-lts" "aarch64-linux-gnu"
+ crust-pine64-plus))
(define-public u-boot-pinebook
- (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
--
2.30.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#48371: Add crust firmware for sunxi devices
2021-05-30 1:30 ` Vagrant Cascadian
@ 2023-07-07 20:07 ` Maxim Cournoyer
0 siblings, 0 replies; 5+ messages in thread
From: Maxim Cournoyer @ 2023-07-07 20:07 UTC (permalink / raw)
To: Vagrant Cascadian; +Cc: 48371-done, Maxime Devos
Hi Vagrant,
[...]
> live well,
> vagrant
>
> From 75dff89f75481cea087890d28568017996e88da5 Mon Sep 17 00:00:00 2001
> From: Vagrant Cascadian <vagrant@debian.org>
> 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.
I've updated the package description for 2023 and standardized the
installation prefixes to use /libexec for the main payload as well as
/bin for the tools (load), and made sure the 'load' binary could be
correctly cross-compiled. See 4f32e8d7cc35fa76933a5fc69e584dbc7033e9fc.
--
Thanks,
Maxim
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-07 20:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-11 22:15 [bug#48371] Add crust firmware for sunxi devices Vagrant Cascadian
2021-05-13 13:00 ` Maxime Devos
2021-05-30 0:55 ` Vagrant Cascadian
2021-05-30 1:30 ` Vagrant Cascadian
2023-07-07 20:07 ` bug#48371: " Maxim Cournoyer
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.