summaryrefslogtreecommitdiff
path: root/gnu/packages/coreboot.scm
blob: b8355caf2170923d5f9fdb9bd82548e142ebc874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2025 Cayetano Santos <csantosb@inventati.org>
;;; Copyright © 2026 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
;;;
;;; 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 packages coreboot)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages pciutils)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system cargo)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system copy)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system go)
  #:use-module (guix build-system meson)
  #:use-module (guix build-system pyproject)
  #:use-module (guix build-system python)
  #:use-module (guix build-system qt)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (srfi srfi-26))

(define %coreboot-version "26.03")

(define %coreboot-origin
  (origin
    (method git-fetch)
    (uri (git-reference
           (url "https://review.coreboot.org/coreboot")
           (commit %coreboot-version)))
    (file-name (git-file-name "coreboot" %coreboot-version))
    (sha256
     (base32
      "0436rr0vibh35phvkxrc939njvrmnfq9xw87y1b0nlllglvq07kk"))))

(define-public bincfg
  (package
    (name "bincfg")
    (version %coreboot-version)
    (source %coreboot-origin)
    (build-system gnu-build-system)
    (arguments
     (list
      #:tests? #f ; no test suite
      #:make-flags
      #~(list
         (string-append "CC=" #$(cc-for-target)))
      #:phases
      #~(modify-phases %standard-phases
          (delete 'configure) ; no configure script
          (add-after 'unpack 'chdir
            (lambda _
              (chdir "util/bincfg")))
          (add-after 'build 'build-binaries
            (lambda* (#:key make-flags #:allow-other-keys)
              (for-each
               (lambda (target result)
                 (apply invoke "make" (string-append "gen-" target) make-flags)
                 (rename-file result
                              (string-append target ".bin")))
               (list
                ;; generate GbE for X200
                "gbe-ich9m"
                ;; generate GbE for X220/x230
                "gbe-82579LM"
                ;; generate IFD for X200
                "ifd-x200")
               (list
                "flashregion_3_gbe.bin"
                "flashregion_3_gbe.bin"
                "flashregion_0_fd.bin"))))
          ;; The Makefile has no install target.
          (replace 'install
            (lambda _
              (let ((bin (string-append #$output "/bin"))
                    (lib (string-append #$output "/lib/bincfg"))
                    (data (string-append #$output "/share/bincfg")))
                ;; Install the program
                (install-file "bincfg" bin)
                ;; And its data
                (for-each
                 (lambda (path)
                   (install-file path data))
                 (append (find-files "." ".*\\.set")
                         (find-files "." ".*\\.spec")))
                ;; And the files generated with the data
                (for-each
                 (lambda (path)
                   (install-file path lib))
                 (find-files "." ".*\\.bin"))))))))
    (native-inputs (list bison flex))
    (home-page "https://coreboot.org")
    (synopsis "Encoder/decoder for binary formats described in text files")
    (description "
The bincfg program comes with specifications files for the following binary
formats:
@itemize
@item Various DDR3 and DDR4 SPD
@item Configuration data for the Intel 82579LM Gigabit Ethernet PHY
@item Configuration data for the Intel Gigabit Ethernet controller present in
      the Intel ICH9-M chipset.
@item Intel Firmware Descriptor data for the Lenovo ThinkPad X200
@item Configuration data for the ITE IT8718F SuperIO
@end itemize
It also comes with example files generated by bincfg.")
    (license license:gpl3+)))

(define-public ifdtool
  (package
    (name "ifdtool")
    (version %coreboot-version)
    (source %coreboot-origin)
    (build-system gnu-build-system)
    (arguments
     (list
      #:make-flags
      #~(list (string-append "CC=" #$(cc-for-target))
              "INSTALL=install"
              (string-append "PREFIX=" #$output))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'chdir
            (lambda _
              (chdir "util/ifdtool")))
          (delete 'configure))           ; no configure script
      #:tests? #f))                    ; no test suite
    (home-page "https://doc.coreboot.org/util/ifdtool/")
    (synopsis "Intel Firmware Descriptor dumper")
    (description "This package provides @command{ifdtool}, a program to
dump Intel Firmware Descriptor data of an image file.")
    (license license:gpl2)))

(define-public intelmetool
  (package
    (name "intelmetool")
    (version %coreboot-version)
    (source %coreboot-origin)
    (build-system gnu-build-system)
    (arguments
     (list
      #:tests? #f                       ;no test suite
      #:make-flags
      #~(list (string-append "CC=" #$(cc-for-target))
              "INSTALL=install"
              (string-append "PREFIX=" #$output))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'chdir
            (lambda _
              (chdir "util/intelmetool")))
          (delete 'configure) ;no configure script
          (delete 'check))))
    (inputs (list pciutils zlib))
    (home-page
     "https://github.com/coreboot/coreboot/tree/main/util/intelmetool/")
    (synopsis "Intel Management Engine tools")
    (description "This package provides tools for working with Intel
Management Engine (ME).  You need to @code{sudo rmmod mei_me} and
@code{sudo rmmod mei} before using this tool.  Also pass
@code{iomem=relaxed} to the Linux kernel command line.")
    (license license:gpl2)

    ;; This is obviously an Intel thing, plus it requires <cpuid.h>.
    (supported-systems '("x86_64-linux" "i686-linux"))))

(define-public nvramtool
  (package
    (name "nvramtool")
    (version %coreboot-version)
    (source %coreboot-origin)
    (build-system gnu-build-system)
    (arguments
     (list
      #:tests? #f ; no test suite
      #:make-flags
      #~(list (string-append "CC=" #$(cc-for-target))
              "INSTALL=install"
              (string-append "PREFIX=" #$output))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'chdir
            (lambda _
              (chdir "util/nvramtool")))
          (delete 'configure)))) ; no configure script
    (home-page "https://coreboot.org")
    (synopsis "Command line tool that can edit Coreboot settings")
    (description "@command{nvramtool} can see and/or modify Coreboot settings
like the serial port speed, log level, etc.  It requires Coreboot to be compiled
with CONFIG_USE_OPTION_TABLE and some options require the iomem=relaxed kernel
command line to work.  Features:
@itemize
@item If Coreboot was compiled without CONFIG_STATIC_OPTION_TABLE, it can change
      its settings, which are applied after a reboot.
@item It can modify Coreboot images  default settings with
      @command{nvramtool -C coreboot.rom [...]}.
@item It has various options related to the file format used to store these
      settings.
@item It can also read/write the CMOS memory where the Coreboot settings can be
      located.
@end itemize")
    ;; Some files are "GPL-2.0-only or BSD-3-Clause", other are GPL-2.0-only
    ;; and anyway there is. There is also a license declaration in
    ;; cli/nvramtool.8 that applies to "This program" which uses the GPLv2.
    (license license:gpl2)))