From acf54bca225b63f5b06e335a55045421c47bbd09 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 5 Dec 2017 11:34:01 +0100 Subject: vm: Adapt qemu command to ARM. * gnu/build/vm.scm (load-in-linux-vm): New argument #:target-arm32. Use it to adapt command for qemu-system-arm. This implies to choose a machine ("virt"), use the correct console port "ttyAMA0", disable KVM use that is buggy on some ARM boards (Odroid XU4 for example) and use user mode network stack instead of NIC. Gather all those options in a new variable "arch-specific-flags". * gnu/system/vm.scm (expression->derivation-in-linux-vm): Pass to load-in-linux-vm "#:target-arm32?" argument. --- gnu/system/vm.scm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gnu/system') diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index d754ac76f09..b376337c8d5 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -175,6 +175,10 @@ made available under the /xchg CIFS share." #:memory-size #$memory-size #:make-disk-image? #$make-disk-image? #:single-file-output? #$single-file-output? + ;; FIXME: ‘target-arm32?’ may not operate on + ;; the right system/target values. Rewrite + ;; using ‘let-system’ when available. + #:target-arm32? #$(target-arm32?) #:disk-image-format #$disk-image-format #:disk-image-size size #:references-graphs graphs))))) -- cgit v1.3 From e22482038611a53a9d2b25df20363664cd91be2e Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 5 Dec 2017 12:59:15 +0100 Subject: bootloader: Factorize write-file-on-device. * gnu/bootloader/extlinux.scm (install-extlinux): Factorize bootloader writing in a new procedure write-file-on-device defined in (gnu build bootloader). * gnu/build/bootloader.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add new file. * gnu/system/vm.scm (qemu-img): Adapt to import and use (gnu build bootloader) module during derivation building. * gnu/scripts/system.scm (bootloader-installer-derivation): Ditto. --- gnu/bootloader/extlinux.scm | 10 +++------- gnu/build/bootloader.scm | 37 +++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + gnu/system/vm.scm | 6 ++++-- guix/scripts/system.scm | 6 ++++-- 5 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 gnu/build/bootloader.scm (limited to 'gnu/system') diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm index 9b6e2c7f2a2..f7820a37a48 100644 --- a/gnu/bootloader/extlinux.scm +++ b/gnu/bootloader/extlinux.scm @@ -20,6 +20,7 @@ (define-module (gnu bootloader extlinux) #:use-module (gnu bootloader) #:use-module (gnu system) + #:use-module (gnu build bootloader) #:use-module (gnu packages bootloaders) #:use-module (guix gexp) #:use-module (guix monads) @@ -95,13 +96,8 @@ TIMEOUT ~a~%" (find-files syslinux-dir "\\.c32$")) (unless (and (zero? (system* extlinux "--install" install-dir)) - (call-with-input-file (string-append syslinux-dir "/" #$mbr) - (lambda (input) - (let ((bv (get-bytevector-n input 440))) - (call-with-output-file device - (lambda (output) - (put-bytevector output bv)) - #:binary #t))))) + (write-file-on-device + (string-append syslinux-dir "/" #$mbr) 440 device 0)) (error "failed to install SYSLINUX"))))) (define install-extlinux-mbr diff --git a/gnu/build/bootloader.scm b/gnu/build/bootloader.scm new file mode 100644 index 00000000000..d00674dd40f --- /dev/null +++ b/gnu/build/bootloader.scm @@ -0,0 +1,37 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Mathieu Othacehe +;;; +;;; 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 . + +(define-module (gnu build bootloader) + #:use-module (ice-9 binary-ports) + #:export (write-file-on-device)) + + +;;; +;;; Writing utils. +;;; + +(define (write-file-on-device file size device offset) + "Write SIZE bytes from FILE to DEVICE starting at OFFSET." + (call-with-input-file file + (lambda (input) + (let ((bv (get-bytevector-n input size))) + (call-with-output-file device + (lambda (output) + (seek output offset SEEK_SET) + (put-bytevector output bv)) + #:binary #t))))) diff --git a/gnu/local.mk b/gnu/local.mk index f6b29a7155a..c87af5a17b8 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -489,6 +489,7 @@ GNU_SYSTEM_MODULES = \ %D%/system/vm.scm \ \ %D%/build/activation.scm \ + %D%/build/bootloader.scm \ %D%/build/cross-toolchain.scm \ %D%/build/file-systems.scm \ %D%/build/install.scm \ diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index b376337c8d5..6102d465b83 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -277,10 +277,12 @@ register INPUTS in the store database of the image so that Guix can be used in the image." (expression->derivation-in-linux-vm name - (with-imported-modules (source-module-closure '((gnu build vm) + (with-imported-modules (source-module-closure '((gnu build bootloader) + (gnu build vm) (guix build utils))) #~(begin - (use-modules (gnu build vm) + (use-modules (gnu build bootloader) + (gnu build vm) (guix build utils) (srfi srfi-26) (ice-9 binary-ports)) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index d0eacc573cb..cbf7e6cd035 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -674,9 +674,11 @@ any, are available. Raise an error if they're not." and TARGET arguments." (with-monad %store-monad (gexp->file "bootloader-installer" - (with-imported-modules '((guix build utils)) + (with-imported-modules '((gnu build bootloader) + (guix build utils)) #~(begin - (use-modules (guix build utils) + (use-modules (gnu build bootloader) + (guix build utils) (ice-9 binary-ports)) (#$installer #$bootloader #$device #$target)))))) -- cgit v1.3 From ceb3952764e49400d4419fea64a9201a32dad3de Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 12 Dec 2017 16:41:56 +0100 Subject: system: Add BeagleBone Black installer. * gnu/bootloader/u-boot.scm (u-boot-beaglebone-black-bootloader): New exported bootloader. * gnu/system/install.scm (beaglebone-black-installation-os): New exported variable. --- gnu/bootloader/u-boot.scm | 25 ++++++++++++++++++++++++- gnu/system/install.scm | 29 +++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) (limited to 'gnu/system') diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm index 963b0d7597e..397eb8181cf 100644 --- a/gnu/bootloader/u-boot.scm +++ b/gnu/bootloader/u-boot.scm @@ -21,18 +21,35 @@ #:use-module (gnu bootloader extlinux) #:use-module (gnu bootloader) #:use-module (gnu system) + #:use-module (gnu build bootloader) #:use-module (gnu packages bootloaders) #:use-module (guix gexp) #:use-module (guix monads) #:use-module (guix records) #:use-module (guix utils) - #:export (u-boot-bootloader)) + #:export (u-boot-bootloader + u-boot-beaglebone-black-bootloader)) (define install-u-boot #~(lambda (bootloader device mount-point) (if bootloader (error "Failed to install U-Boot")))) +(define install-beaglebone-black-u-boot + ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot + ;; This first stage bootloader called MLO (U-Boot SPL) is expected at + ;; 0x20000 by BBB ROM code. The second stage bootloader will be loaded by + ;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and + ;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the + ;; specified DEVICE. + #~(lambda (bootloader device mount-point) + (let ((mlo (string-append bootloader "/libexec/MLO")) + (u-boot (string-append bootloader "/libexec/u-boot.img"))) + (write-file-on-device mlo (* 256 512) + device (* 256 512)) + (write-file-on-device u-boot (* 1024 512) + device (* 768 512))))) + ;;; @@ -45,3 +62,9 @@ (name 'u-boot) (package #f) (installer install-u-boot))) + +(define u-boot-beaglebone-black-bootloader + (bootloader + (inherit u-boot-bootloader) + (package u-boot-beagle-bone-black) + (installer install-beaglebone-black-u-boot))) diff --git a/gnu/system/install.scm b/gnu/system/install.scm index c2f73f7e8fa..8864415d7cd 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm @@ -22,6 +22,7 @@ (define-module (gnu system install) #:use-module (gnu) + #:use-module (gnu bootloader u-boot) #:use-module (guix gexp) #:use-module (guix store) #:use-module (guix monads) @@ -42,7 +43,8 @@ #:use-module (gnu packages nvi) #:use-module (ice-9 match) #:use-module (srfi srfi-26) - #:export (installation-os)) + #:export (installation-os + beaglebone-black-installation-os)) ;;; Commentary: ;;; @@ -372,7 +374,30 @@ You have been warned. Thanks for being so brave.\x1b[0m nvi ;:wq! %base-packages)))) -;; Return it here so 'guix system' can consume it directly. +(define beaglebone-black-installation-os + (operating-system + (inherit installation-os) + (bootloader (bootloader-configuration + (bootloader u-boot-beaglebone-black-bootloader) + (target "/dev/sda"))) + (kernel linux-libre) + (initrd (lambda (fs . rest) + (apply base-initrd fs + ;; This module is required to mount the sd card. + #:extra-modules (list "omap_hsmmc") + rest))) + (services (append + ;; mingetty does not work on serial lines. + ;; Use agetty with board-specific serial parameters. + (list (agetty-service + (agetty-configuration + (extra-options '("-L")) + (baud-rate "115200") + (term "vt100") + (tty "ttyO0")))) + (operating-system-user-services installation-os))))) + +;; Return the default os here so 'guix system' can consume it directly. installation-os ;;; install.scm ends here -- cgit v1.3 From e0d96774dd48c29ccc4c90fea1f8f71850ab0879 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 9 Dec 2017 08:36:52 +0000 Subject: gnu: system: vm: Use loose cache for 9p file system. This improves the performance of the shared store for operations involving lots of files, e.g. searching through the store. * gnu/system/vm.scm (mapping->file-system): Add cache=loose to options. --- gnu/system/vm.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/system') diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 6102d465b83..c1305d3f9e0 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -554,7 +554,7 @@ of the GNU system as described by OS." (device (file-system->mount-tag source)) (type "9p") (flags (if writable? '() '(read-only))) - (options (string-append "trans=virtio")) + (options "trans=virtio,cache=loose") (check? #f) (create-mount-point? #t))))) -- cgit v1.3 From 2ca712bdbae5551a270c17522da20e8cb84a29cf Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Sat, 2 Dec 2017 20:17:45 -0500 Subject: vm: Pass the host's /dev/urandom to the guest at /dev/hwrng. * gnu/build/vm.scm (load-in-linux-vm): Use QEMU's virtio-rng-pci. * gnu/system/vm.scm (common-qemu-options): Likewise. --- gnu/build/vm.scm | 4 +++- gnu/system/vm.scm | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'gnu/system') diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 8f8ca609f2b..404f3240456 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès ;;; Copyright © 2016 Christopher Allan Webber -;;; Copyright © 2016 Leo Famulari +;;; Copyright © 2016, 2017 Leo Famulari ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2017 Marius Bakke ;;; @@ -139,6 +139,8 @@ the #:references-graphs parameter of 'derivation'." (unless (zero? (apply system* qemu "-nographic" "-no-reboot" "-m" (number->string memory-size) + "-object" "rng-random,filename=/dev/urandom,id=guixsd-vm-rng" + "-device" "virtio-rng-pci,rng=guixsd-vm-rng" "-virtfs" (string-append "local,id=store_dev,path=" (%store-directory) diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index c1305d3f9e0..53629daa909 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès ;;; Copyright © 2016 Christopher Allan Webber -;;; Copyright © 2016 Leo Famulari +;;; Copyright © 2016, 2017 Leo Famulari ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2017 Marius Bakke ;;; @@ -666,6 +666,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS." "-no-reboot" "-net nic,model=virtio" + "-object" "rng-random,filename=/dev/urandom,id=guixsd-vm-rng" + "-device" "virtio-rng-pci,rng=guixsd-vm-rng" #$@(map virtfs-option shared-fs) "-vga std" -- cgit v1.3 From 9f1e39d1fcca0525bc51dc0eedd11a902089bba4 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Mon, 18 Dec 2017 14:47:44 +0100 Subject: system: examples: Add a template for BeagleBone Black. * gnu/system/examples/beaglebone-black.tmpl: New file. * Makefile.am (EXAMPLES): Add it. * gnu/system/install.scm (/etc/configuration-files): Add it. --- Makefile.am | 1 + gnu/system/examples/beaglebone-black.tmpl | 54 +++++++++++++++++++++++++++++++ gnu/system/install.scm | 2 ++ 3 files changed, 57 insertions(+) create mode 100644 gnu/system/examples/beaglebone-black.tmpl (limited to 'gnu/system') diff --git a/Makefile.am b/Makefile.am index fe1e685f34a..a0e5ff16970 100644 --- a/Makefile.am +++ b/Makefile.am @@ -254,6 +254,7 @@ AUX_FILES = \ # Templates, examples. EXAMPLES = \ gnu/system/examples/bare-bones.tmpl \ + gnu/system/examples/beaglebone-black.tmpl \ gnu/system/examples/desktop.tmpl \ gnu/system/examples/lightweight-desktop.tmpl \ gnu/system/examples/vm-image.tmpl diff --git a/gnu/system/examples/beaglebone-black.tmpl b/gnu/system/examples/beaglebone-black.tmpl new file mode 100644 index 00000000000..609b801cabb --- /dev/null +++ b/gnu/system/examples/beaglebone-black.tmpl @@ -0,0 +1,54 @@ +;; This is an operating system configuration template +;; for a "bare bones" setup on BeagleBone Black board. + +(use-modules (gnu) (gnu bootloader u-boot)) +(use-service-modules networking) +(use-package-modules bootloaders screen ssh) + +(operating-system + (host-name "komputilo") + (timezone "Europe/Berlin") + (locale "en_US.utf8") + + ;; Assuming /dev/mmcblk1 is the eMMC, and "my-root" is + ;; the label of the target root file system. + (bootloader (bootloader-configuration + (bootloader u-boot-beaglebone-black-bootloader) + (target "/dev/mmcblk1"))) + (file-systems (cons (file-system + (device "my-root") + (title 'label) + (mount-point "/") + (type "ext4")) + %base-file-systems)) + + ;; This is where user accounts are specified. The "root" + ;; account is implicit, and is initially created with the + ;; empty password. + (users (cons (user-account + (name "alice") + (comment "Bob's sister") + (group "users") + + ;; Adding the account to the "wheel" group + ;; makes it a sudoer. Adding it to "audio" + ;; and "video" allows the user to play sound + ;; and access the webcam. + (supplementary-groups '("wheel" + "audio" "video")) + (home-directory "/home/alice")) + %base-user-accounts)) + + ;; Globally-installed packages. + (packages (cons* screen openssh %base-packages)) + + (services (cons* (dhcp-client-service) + ;; mingetty does not work on serial lines. + ;; Use agetty with board-specific serial parameters. + (agetty-service + (agetty-configuration + (extra-options '("-L")) + (baud-rate "115200") + (term "vt100") + (tty "ttyO0"))) + %base-services))) diff --git a/gnu/system/install.scm b/gnu/system/install.scm index 8864415d7cd..1cc3db1160b 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm @@ -156,9 +156,11 @@ the user's target storage device rather than on the RAM disk." (string-append #$output "/" target))) '(#$(file "bare-bones.tmpl") + #$(file "beaglebone-black.tmpl") #$(file "desktop.tmpl") #$(file "lightweight-desktop.tmpl")) '("bare-bones.scm" + "beaglebone-black.scm" "desktop.scm" "lightweight-desktop.scm")) #t)))) -- cgit v1.3