guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

07/07: gnu: raspberry-pi: Add a bootloader-chain for the Raspberry Pi an


From: guix-commits
Subject: 07/07: gnu: raspberry-pi: Add a bootloader-chain for the Raspberry Pi and os examples.
Date: Thu, 1 Dec 2022 14:33:04 -0500 (EST)

apteryx pushed a commit to branch master
in repository guix.

commit c7793b82efd3383a9f7adf0dfa82d71ee032e41b
Author: Stefan <stefan-guix@vodafonemail.de>
AuthorDate: Thu Dec 1 13:46:38 2022 -0500

    gnu: raspberry-pi: Add a bootloader-chain for the Raspberry Pi and os 
examples.
    
    * gnu/packages/raspberry-pi.scm (grub-efi-bootloader-chain-raspi-64): New
    bootloader variable, capable to boot a Raspberry Pi over network or from a
    local storage.
    * gnu/system/examples/raspberry-pi-64.tmpl: New operating-system example.
    * gnu/system/examples/raspberry-pi-64-nfs-root.tmpl: New operating-system
    example for booting over network.
    * Makefile.am (EXAMPLES): Register the new files.
    
    Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
---
 Makefile.am                                       |  2 +
 gnu/packages/raspberry-pi.scm                     | 19 ++++++
 gnu/system/examples/raspberry-pi-64-nfs-root.tmpl | 75 +++++++++++++++++++++
 gnu/system/examples/raspberry-pi-64.tmpl          | 79 +++++++++++++++++++++++
 4 files changed, 175 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 75c9df573c..c0b2a3ee80 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -440,6 +440,8 @@ EXAMPLES =                                  \
   gnu/system/examples/desktop.tmpl             \
   gnu/system/examples/lightweight-desktop.tmpl \
   gnu/system/examples/docker-image.tmpl                \
+  gnu/system/examples/raspberry-pi-64.tmpl     \
+  gnu/system/examples/raspberry-pi-64-nfs-root.tmpl    \
   gnu/system/examples/vm-image.tmpl
 
 GOBJECTS = $(MODULES:%.scm=%.go) guix/config.go $(dist_noinst_DATA:%.scm=%.go)
diff --git a/gnu/packages/raspberry-pi.scm b/gnu/packages/raspberry-pi.scm
index 18a041b6af..21bc9a3bd8 100644
--- a/gnu/packages/raspberry-pi.scm
+++ b/gnu/packages/raspberry-pi.scm
@@ -18,11 +18,14 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages raspberry-pi)
+  #:use-module (gnu bootloader)
+  #:use-module (gnu bootloader grub)
   #:use-module (gnu packages)
   #:use-module (gnu packages admin)
   #:use-module (gnu packages algebra)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages bootloaders)
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages cross-base)
   #:use-module (gnu packages documentation)
@@ -316,6 +319,22 @@ kernel LINUX."
      (format #f "The device-tree files for Raspberry Pi models from ~a."
              (package-name linux)))))
 
+(define-public grub-efi-bootloader-chain-raspi-64
+  ;; A bootloader capable to boot a Raspberry Pi over network via TFTP or from
+  ;; a local storage like a micro SD card.  It neither installs firmware nor
+  ;; device-tree files for the Raspberry Pi.  It just assumes them to be
+  ;; existing in boot/efi in the same way that some UEFI firmware with ACPI
+  ;; data is usually assumed to be existing on PCs.  It creates firmware
+  ;; configuration files and a bootloader-chain with U-Boot to provide an EFI
+  ;; API for the final GRUB bootloader.  It also serves as a blue-print to
+  ;; create an a custom bootloader-chain with firmware and device-tree
+  ;; packages or files.
+  (efi-bootloader-chain grub-efi-netboot-removable-bootloader
+                        #:packages (list u-boot-rpi-arm64-efi-bin)
+                        #:files (list %raspi-config-txt
+                                      %raspi-bcm27-dtb-txt
+                                      %raspi-u-boot-bootloader-txt)))
+
 (define (make-raspi-defconfig arch defconfig sha256-as-base32)
   "Make for the architecture ARCH a file-like object from the DEFCONFIG file
 with the hash SHA256-AS-BASE32.  This object can be used as the #:defconfig
diff --git a/gnu/system/examples/raspberry-pi-64-nfs-root.tmpl 
b/gnu/system/examples/raspberry-pi-64-nfs-root.tmpl
new file mode 100644
index 0000000000..7bcac8ded0
--- /dev/null
+++ b/gnu/system/examples/raspberry-pi-64-nfs-root.tmpl
@@ -0,0 +1,75 @@
+;; This is an operating-system configuration template of a
+;; 64-bit minimal system for a Raspberry Pi with an NFS root file-system.
+
+;; It neither installs firmware nor device-tree files for the Raspberry Pi.
+;; It just assumes them to be existing in boot/efi in the same way that some
+;; UEFI firmware with ACPI data is usually assumed to be existing on PCs.
+
+;; It expects the boot/efi directory to be served via TFTP and the root
+;; file-system to be served via NFS. See the grub-efi-netboot-bootloader
+;; description in the manual for more details.
+
+(use-modules (gnu)
+             (gnu artwork)
+             (gnu system nss))
+(use-service-modules admin
+                     avahi
+                     networking
+                     ssh)
+(use-package-modules certs
+                     linux
+                     raspberry-pi
+                     ssh)
+
+(define %my-public-key
+  (local-file (string-append (getenv "HOME") "/.ssh/id_ecdsa.pub")))
+
+(define-public raspberry-pi-64-nfs-root
+  (operating-system
+    (host-name "raspberrypi-guix")
+    (timezone "Europe/Berlin")
+    (bootloader (bootloader-configuration
+                 (bootloader grub-efi-bootloader-chain-raspi-64)
+                 (targets (list "/boot/efi"))
+                 (theme (grub-theme
+                         (resolution '(1920 . 1080))
+                         (image (file-append
+                                 %artwork-repository
+                                 "/grub/GuixSD-fully-black-16-9.svg"))))))
+    (kernel-arguments '("ip=dhcp"))
+    (kernel (customize-linux #:linux linux-libre-arm64-generic
+                             #:extra-version "arm64-generic-netboot"
+                             #:configs '("CONFIG_NFS_SWAP=y"
+                                         "CONFIG_USB_USBNET=y"
+                                         "CONFIG_USB_LAN78XX=y"
+                                         "CONFIG_USB_NET_SMSC95XX=y")))
+    (initrd-modules '())
+    (file-systems (cons* (file-system
+                           (mount-point "/")
+                           (type "nfs")
+                           (device ":/export/raspberrypi/guix")
+                           (options "addr=10.20.30.40,vers=4.1"))
+                         %base-file-systems))
+    (swap-devices (list (swap-space
+                         (target "/run/swapfile"))))
+    (users (cons* (user-account
+                   (name "pi")
+                   (group "users")
+                   (supplementary-groups '("wheel" "netdev" "audio" "video"))
+                   (home-directory "/home/pi"))
+                  %base-user-accounts))
+    (packages (cons* nss-certs
+                     openssh
+                     %base-packages))
+    (services (cons* (service avahi-service-type)
+                     (service dhcp-client-service-type)
+                     (service ntp-service-type)
+                     (service openssh-service-type
+                              (openssh-configuration
+                               (x11-forwarding? #t)
+                               (authorized-keys
+                                `(("pi" ,%my-public-key)))))
+                     %base-services))
+    (name-service-switch %mdns-host-lookup-nss)))
+
+raspberry-pi-64-nfs-root
diff --git a/gnu/system/examples/raspberry-pi-64.tmpl 
b/gnu/system/examples/raspberry-pi-64.tmpl
new file mode 100644
index 0000000000..7d2638dd80
--- /dev/null
+++ b/gnu/system/examples/raspberry-pi-64.tmpl
@@ -0,0 +1,79 @@
+;; This is an operating-system configuration template of a
+;; 64-bit minimal system for a Raspberry Pi with local storage.
+
+;; It neither installs firmware nor device-tree files for the Raspberry Pi.
+;; It just assumes them to be existing in boot/efi in the same way that some
+;; UEFI firmware with ACPI data is usually assumed to be existing on PCs.
+
+;; It expects the boot-partition to be mounted as boot/efi in the same way
+;; as it is usually expeted on PCs with UEFI firmware.
+
+(use-modules (gnu)
+             (gnu artwork)
+             (gnu system nss))
+(use-service-modules admin
+                     avahi
+                     networking
+                     ssh)
+(use-package-modules certs
+                     linux
+                     raspberry-pi
+                     ssh)
+
+(define %my-public-key
+  (local-file (string-append (getenv "HOME") "/.ssh/id_ecdsa.pub")))
+
+(define-public raspberry-pi-64
+  (operating-system
+    (host-name "raspberrypi-guix")
+    (timezone "Europe/Berlin")
+    (bootloader (bootloader-configuration
+                 (bootloader grub-efi-bootloader-chain-raspi-64)
+                 (targets (list "/boot/efi"))
+                 (theme (grub-theme
+                         (resolution '(1920 . 1080))
+                         (image (file-append
+                                 %artwork-repository
+                                 "/grub/GuixSD-fully-black-16-9.svg"))))))
+    (kernel (customize-linux #:linux linux-libre-arm64-generic
+                             ;; It is possible to use a specific defconfig
+                             ;; file, for example the "bcmrpi3_defconfig" with
+                             ;; the variable shown below.  Unfortunately the
+                             ;; kernel built from the linux-libre sources with
+                             ;; this defconfig file does not boot.
+                             ;;#:extra-version "gnu-bcmrpi3"
+                             ;;#:defconfig %bcmrpi3-defconfig
+                             ))
+    (initrd-modules '())
+    (file-systems (cons* (file-system
+                           (mount-point "/")
+                           (type "ext4")
+                           (device (file-system-label "Guix")))
+                         (file-system
+                           (mount-point "/boot/efi")
+                           (type "vfat")
+                           (device (file-system-label "EFI")))
+                         %base-file-systems))
+    (swap-devices (list (swap-space
+                         (target "/run/swapfile"))))
+    (users (cons* (user-account
+                   (name "pi")
+                   (group "users")
+                   (supplementary-groups '("wheel" "netdev" "audio" "video"))
+                   (home-directory "/home/pi"))
+                  %base-user-accounts))
+    (packages (cons* nss-certs
+                     openssh
+                     %base-packages))
+    (services (cons* (service avahi-service-type)
+                     (service dhcp-client-service-type)
+                     (service ntp-service-type)
+                     (service openssh-service-type
+                              (openssh-configuration
+                               (x11-forwarding? #t)
+                               (authorized-keys
+                                `(("pi" ,%my-public-key)))))
+                     %base-services))
+    (name-service-switch %mdns-host-lookup-nss)))
+
+raspberry-pi-64



reply via email to

[Prev in Thread] Current Thread [Next in Thread]