help-guix
[Top][All Lists]
Advanced

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

Re: Guix on the MNT Reform


From: Fredrik Salomonsson
Subject: Re: Guix on the MNT Reform
Date: Mon, 06 Sep 2021 23:59:01 +0000

Christine Lemmer-Webber <cwebber@dustycloud.org> writes:

> Ooh!  This is a great email.  Thank you for your help.

Not sure how much of a help I am :).

> That seems right.  I don't understand the config system that's here to
> know what to do.
>
> I noticed that the source/README directory says the following:
>
> #+BEGIN_QUOTE
> - CONFIG_SYS_MALLOC_SIMPLE
>               Provides a simple and small malloc() and calloc() for those
>               boards which do not use the full malloc in SPL (which is
>               enabled with CONFIG_SYS_SPL_MALLOC_START).
> #+END_QUOTE
>
> Now note that by following their custom instructions, I had set a rule
> in the package definition above to copy =mntreform-config= to =.config=
>
> But I also just noticed something strange.
>
> The build directory is:
>
>   /tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0/source
>
> yet the error appears as:
>
>   
> /gnu/store/dj05znzsk7fq43zj5r719ll8ldgh9xxi-u-boot-mnt-reform2-2021.06-checkout/include/malloc.h
>
> I don't know how common this is, but this surprised me to see that it
> was pointing at something from the checkout rather than in the build
> directory.
>
> So, I changed where the copy config step was and put it in the source
> section.  Then, since the config step incorrectly identified this as not
> being a valid board (we're really doing the config step manually) I
> deleted it:
>
> #+BEGIN_SRC scheme
> (define-public u-boot-mnt-reform2
>   (let ((base (make-u-boot-package "mnt-reform2" "aarch64-linux-gnu"))
>         (commit "bdcdce7434b9db19aabd59181014f24d66af0db8"))
>     (package
>       (inherit base)
>       (version "2021.06")
>       (name "u-boot-mnt-reform2")
>       (source (origin
>                 (method git-fetch)
>                 (uri (git-reference
>                       (url 
> "https://source.mnt.re/reform/reform-boundary-uboot.git";)
>                       (commit commit)))
>                 (file-name (git-file-name name version))
>                 (sha256
>                  (base32
>                   "1pwmcaaxx5zvn26gznwz4rjki4w3wwfzdnipxfr7d8067fmwgjp3"))
>                 (snippet
>                  '(copy-file "mntreform-config" ".config"))))
>       (arguments
>         (substitute-keyword-arguments (package-arguments base)
>           ((#:phases phases)
>            `(modify-phases ,phases
>               (delete 'configure))))))))
> #+END_SRC
>
> Now things compile!

Nice find! I didn't notice the include coming from the checkout
directory so I was comparing the build output from running the

#+begin_src sh
CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm make -j$(nproc)
#+end_src

in the =https://source.mnt.re/reform/reform-boundary-uboot.git= repo to
the output I got from guix build.

> Now note that it looks like we need to do two steps, so this probably is
> not complete.  From the mkuboot.sh mentioned previously:
>
> #+BEGIN_SRC sh
> # build rescue u-boot first (loads kernel from eMMC)
> make -j$(nproc) flash.bin KCPPFLAGS='-DMNTREFORM_BOOT_EMMC'
> cp flash.bin flash-rescue.bin
>
> # build normal u-boot second (loads kernel from SD card)
> make -j$(nproc) flash.bin
> #+END_SRC
>
> So maybe we need to incorporate that before using this.

I'm not sure we need both to get this working. As if you look in the
=mkimage.sh= script it actually creates two images. One for the eMMC and
one for the SD card. To just get this booting using the SD card, what we
have should be enough. I'm currently trying to create an image from it
but hitting some build issues. This is what I have right now:

#+begin_src diff
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 6cad33b741..7d3f07e8ab 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -34,6 +34,7 @@
             u-boot-firefly-rk3399-bootloader
             u-boot-mx6cuboxi-bootloader
             u-boot-nintendo-nes-classic-edition-bootloader
+            u-boot-mnt-reform2-bootloader
             u-boot-novena-bootloader
             u-boot-pine64-plus-bootloader
             u-boot-pine64-lts-bootloader
@@ -209,6 +210,11 @@
    (inherit u-boot-imx-bootloader)
    (package u-boot-wandboard)))
 
+(define u-boot-mnt-reform2-bootloader
+  (bootloader
+    (inherit u-boot-imx-bootloader)
+    (package u-boot-mnt-reform2)))
+
 (define u-boot-novena-bootloader
   (bootloader
    (inherit u-boot-imx-bootloader)
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 5f7dfa0f8f..c365adc93a 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -980,6 +980,30 @@ to Novena upstream, does not load u-boot.img from the 
first partition.")
        `(("firmware" ,arm-trusted-firmware-rk3399)
          ,@(package-native-inputs base))))))
 
+(define-public u-boot-mnt-reform2
+  (let ((base (make-u-boot-package "mnt-reform2" "aarch64-linux-gnu"))
+        (commit "bdcdce7434b9db19aabd59181014f24d66af0db8"))
+    (package
+      (inherit base)
+      (version "2021.06")
+      (name "u-boot-mnt-reform2")
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url 
"https://source.mnt.re/reform/reform-boundary-uboot.git";)
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1pwmcaaxx5zvn26gznwz4rjki4w3wwfzdnipxfr7d8067fmwgjp3"))
+                (snippet
+                 '(copy-file "mntreform-config" ".config"))))
+      (arguments
+        (substitute-keyword-arguments (package-arguments base)
+          ((#:phases phases)
+           `(modify-phases ,phases
+              (delete 'configure))))))))
+
 (define-public vboot-utils
   (package
     (name "vboot-utils")
diff --git a/gnu/system/images/mnt-reform2.scm 
b/gnu/system/images/mnt-reform2.scm
new file mode 100644
index 0000000000..1d1df1383e
--- /dev/null
+++ b/gnu/system/images/mnt-reform2.scm
@@ -0,0 +1,66 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Fredrik Salomonsson <plattfot@posteo.net>
+;;;
+;;; 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/>.
+
+(define-module (gnu system images mnt-reform2)
+  #:use-module (gnu bootloader)
+  #:use-module (gnu bootloader u-boot)
+  #:use-module (gnu image)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu services)
+  #:use-module (gnu services base)
+  #:use-module (gnu services networking)
+  #:use-module (gnu system)
+  #:use-module (gnu system file-systems)
+  #:use-module (gnu system image)
+  #:use-module (srfi srfi-26)
+  #:export (mnt-reform2-barebones-os
+            mnt-reform2-image-type
+            mnt-reform2-barebones-raw-image))
+
+(define mnt-reform2-barebones-os
+  (operating-system
+    (host-name "sarimner")
+    (timezone "Canada/Pacific")
+    (locale "en_US.utf8")
+    (bootloader (bootloader-configuration
+                 (bootloader u-boot-mnt-reform2-bootloader)
+                 (targets '("/dev/mmcblk1"))))
+    (initrd-modules '("sdhci-esdhc-imx"))
+    (kernel linux-libre-arm64-generic)
+    (file-systems (cons (file-system
+                          (device (file-system-label "my-root"))
+                          (mount-point "/")
+                          (type "ext4"))
+                        %base-file-systems))
+    (services (append (list (service dhcp-client-service-type))
+                      %base-services))))
+
+(define mnt-reform2-image-type
+  (image-type
+   (name 'mnt-reform2-raw)
+   (constructor (cut image-with-os
+                     (arm64-disk-image (* 4 (expt 2 20))) ;4MiB
+                     <>))))
+
+(define mnt-reform2-barebones-raw-image
+  (image
+   (inherit
+    (os->image mnt-reform2-barebones-os #:type mnt-reform2-image-type))
+   (name 'mnt-reform2-barebones-raw-image)))
+
+mnt-reform2-barebones-raw-image
#+end_src

And I'm using this config to create the image:
#+begin_src scheme
(use-modules (gnu)
             (gnu bootloader u-boot)
             (gnu packages bootloaders)
             (gnu packages linux)
             (gnu packages)
             (gnu services nfs)
             (gnu services sddm)
             (gnu system locale)
             (gnu system nss)
             (ice-9 rdelim)
             (ice-9 format)
             (srfi srfi-1))
(use-service-modules desktop networking ssh base xorg)
(use-package-modules wm certs shells xdisorg display-managers)

(define plattfot
  (user-account
   (name "plattfot")
   (group "users")
   ;; Define a G-Expr to find the path of the zsh binary:
   ;; 
https://gitlab.com/rain1/guix-wiki/wikis/FAQ#how-do-i-make-my-login-shell-zsh
   ;;(shell #~(string-append #$zsh "/bin/zsh"))
   (supplementary-groups '("wheel" "netdev" "audio" "video"))
   (home-directory "/home/plattfot")))

(define fs-root
  (file-system
   (mount-point "/")
   (type "ext4")
   (device (file-system-label "my-root"))
   (needed-for-boot? #t)))

(operating-system
  (host-name "sarimner")
  (timezone "Canada/Pacific")
  (locale "en_US.utf8")
  (locale-definitions
   (list
    (locale-definition (name "en_US.utf8") (source "en_US") (charset "UTF-8"))
    (locale-definition (name "sv_SE.utf8") (source "sv_SE") (charset "UTF-8"))))
  (bootloader
   (bootloader-configuration
    (targets '("/dev/mmcblk1"))
    (bootloader u-boot-mnt-reform2-bootloader)))
  (initrd-modules '("sdhci-esdhc-imx"))
  ;; (kernel linux-libre-arm64-generic)
  (file-systems
   (cons*
    fs-root
    %base-file-systems))
  ;; (swap-devices '("/swapfile"))
  (users (cons plattfot %base-user-accounts))
  (keyboard-layout (keyboard-layout "eu"))
  ;; (packages (cons* sway waybar
  ;;                  rofi
  ;;                  nss-certs            ;for HTTPS access
  ;;                  %base-packages))
  ;; (services
  ;;  (cons* (service openssh-service-type
  ;;                  (openssh-configuration
  ;;                   (port-number 6060)
  ;;                   (password-authentication? #f)))
  ;;         (extra-special-file "/usr/bin/env" (file-append coreutils 
"/bin/env"))
  ;;         (remove (lambda (service)
  ;;                   (member (service-kind service)
  ;;                           (list
  ;;                            gdm-service-type
  ;;                            )))
  ;;                 %desktop-services)))

  ;; Allow resolution of '.local' host names with mDNS.
  ;; (name-service-switch %mdns-host-lookup-nss)
  )
#+end_src

I'm building the image with:
#+begin_src shell
guix environment guix
./pre-inst-env guix system image --image-type=mnt-reform2-raw  config.scm
#+end_src

I tried with the =linux-libre-arm64-generic= first but that couldn't
find the =sdhci-esdhc-imx= module. And now when I'm testing with just
the linux-libre kernel I'm running out of space on my =/tmp=. Is there
an easy way of telling the guix-daemon to use another path for building?
Or do I need to restart it and change its =TMPDIR=?

> However, I'm actually disturbed by looking at a few things in the
> "environment-variables" file spit out in the build file.  It says the
> following:
>
> #+BEGIN_SRC sh
> export TEMP=\
> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
> export TEMPDIR=\
> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
> export TMP=\
> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
> export TMPDIR=\
> "/tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-0"
> #+END_SRC
>
> But here's the weird thing.  This is in:
>
>   /tmp/guix-build-u-boot-mnt-reform2-2021.06.drv-4
>
> Now wait a minute.  Look at that last number.  What the hell is going on
> here?  Is this a bug in Guix?  Why is it pointing at -0 in the -4 build
> directory?

I stumbled upon this when checking how to change the build directory for
the guix-daemon [0]:

#+begin_quote
   When the daemon performs a build on behalf of the user, it creates a
build directory under ‘/tmp’ or under the directory specified by its
‘TMPDIR’ environment variable.  This directory is shared with the
container for the duration of the build, though within the container,
the build tree is always called ‘/tmp/guix-build-NAME.drv-0’.
#+end_quote

[0]
https://guix.gnu.org/manual/en/html_node/Invoking-guix_002ddaemon.html

So I don't think it's a bug.

-- 
s/Fred[re]+i[ck]+/Fredrik/g



reply via email to

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