unmatched.scm 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (gnu system images unmatched)
  19. #:use-module (gnu bootloader)
  20. #:use-module (gnu bootloader u-boot)
  21. #:use-module (gnu image)
  22. #:use-module (gnu packages linux)
  23. #:use-module (gnu services)
  24. #:use-module (gnu services base)
  25. #:use-module (gnu services networking)
  26. #:use-module (gnu system)
  27. #:use-module (gnu system file-systems)
  28. #:use-module (gnu system image)
  29. #:use-module (guix platforms riscv)
  30. #:use-module (srfi srfi-26)
  31. #:export (unmatched-barebones-os
  32. unmatched-image-type
  33. unmatched-barebones-raw-image))
  34. (define unmatched-barebones-os
  35. (operating-system
  36. (host-name "unmatched")
  37. (timezone "Asia/Jerusalem")
  38. (locale "en_US.utf8")
  39. (bootloader (bootloader-configuration
  40. (bootloader u-boot-sifive-unmatched-bootloader)
  41. (targets '("/dev/vda"))))
  42. (initrd-modules '())
  43. (kernel linux-libre-riscv64-generic)
  44. (file-systems (cons (file-system
  45. (device (file-system-label "my-root"))
  46. (mount-point "/")
  47. (type "ext4"))
  48. %base-file-systems))
  49. (services
  50. (append (list (service agetty-service-type
  51. (agetty-configuration
  52. (extra-options '("-L")) ; no carrier detect
  53. (baud-rate "115200")
  54. (term "vt100")
  55. (tty "ttySIF0")))
  56. (service dhcp-client-service-type))
  57. %base-services))))
  58. (define unmatched-disk-image
  59. (image-without-os
  60. (format 'disk-image)
  61. (partition-table-type 'gpt)
  62. ;; https://source.denx.de/u-boot/u-boot/-/blob/master/doc/board/sifive/unmatched.rst
  63. ;; The boot process goes:
  64. ;; * zero-stage bootloader (ZSBL) in ROM and first-stage bootloader (FSBL)
  65. ;; together perform the SoC initialization and hand off to the next stage.
  66. ;; * BBL (Berkeley bootloader) takes the device-tree and brings up the rest
  67. ;; of the board, then boots the desired operating system.
  68. (partitions (list
  69. (partition
  70. ;; Special UUID for HiFive first-stage bootloader (FSBL).
  71. (size (* 1 (expt 2 20)))
  72. (label "spl")
  73. (offset (* 34 512))
  74. (file-system "unformatted")
  75. (uuid (uuid "5b193300-fc78-40cd-8002-e86c45580b47")))
  76. (partition
  77. ;; Specific offset for compatibility with the defaults for
  78. ;; u-boot SPL. Special UUID for HiFive BBL (Berkeley bootloader).
  79. (size (* 4 (expt 2 20)))
  80. (label "uboot")
  81. (offset (* 2082 512))
  82. (file-system "unformatted")
  83. (uuid (uuid "2e54b353-1271-4842-806f-e436d6af6985")))
  84. root-partition))))
  85. (define unmatched-image-type
  86. (image-type
  87. (name 'unmatched-raw)
  88. (constructor (cut image-with-os unmatched-disk-image <>))))
  89. (define unmatched-barebones-raw-image
  90. (image
  91. (inherit
  92. (os+platform->image unmatched-barebones-os riscv64-linux
  93. #:type unmatched-image-type))
  94. (name 'unmatched-barebones-raw-image)))
  95. ;; Return the default image.
  96. unmatched-barebones-raw-image