projects/guix·blob java-team · refs

509 lines · 21.0 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2020 Danny Milosavljevic <[email protected]>
3;;; Copyright © 2021 Stefan <[email protected]>
4;;; Copyright © 2022, 2023 Maxim Cournoyer <[email protected]>
5;;;
6;;; This file is part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (gnu packages raspberry-pi)
22 #:use-module (gnu bootloader)
23 #:use-module (gnu bootloader grub)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages admin)
26 #:use-module (gnu packages algebra)
27 #:use-module (gnu packages backup)
28 #:use-module (gnu packages base)
29 #:use-module (gnu packages bash)
30 #:use-module (gnu packages bootloaders)
31 #:use-module (gnu packages cross-base)
32 #:use-module (gnu packages curl)
33 #:use-module (gnu packages documentation)
34 #:use-module (gnu packages embedded)
35 #:use-module (gnu packages file)
36 #:use-module (gnu packages gcc)
37 #:use-module (gnu packages guile)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages qt)
41 #:use-module (gnu packages tls)
42 #:use-module (guix build-system cmake)
43 #:use-module (guix build-system copy)
44 #:use-module (guix build-system gnu)
45 #:use-module (guix build-system qt)
46 #:use-module (guix download)
47 #:use-module (guix git-download)
48 #:use-module ((guix licenses) #:prefix license:)
49 #:use-module (guix packages)
50 #:use-module (guix gexp)
51 #:use-module (guix store)
52 #:use-module (guix monads)
53 #:use-module (guix utils)
54 #:use-module (srfi srfi-1)
55 #:use-module (srfi srfi-2)
56 #:use-module (srfi srfi-26)
57 #:use-module (ice-9 match)
58 #:export (make-raspi-bcm28-dtbs
59 raspi-config-file
60 raspi-custom-txt))
61
62(define-public bcm2835
63 (package
64 (name "bcm2835")
65 (version "1.64")
66 (source (origin
67 (method url-fetch)
68 (uri (string-append
69 "http://www.airspayce.com/mikem/bcm2835/bcm2835-"
70 version ".tar.gz"))
71 (sha256
72 (base32
73 "06s81540iz4vsh0cm6jwah2x0hih79v42pfa4pgr8kcbv56158h6"))))
74 (build-system gnu-build-system)
75 (arguments
76 `(#:tests? #f)) ; Would need to be root
77 ;; doc/html docs would not be installed anyway.
78 ;(native-inputs
79 ; `(("doxygen" ,doxygen)))
80 (synopsis "C library for Broadcom BCM 2835 as used in Raspberry Pi")
81 (description "This package provides a C library for Broadcom BCM 2835 as
82used in the Raspberry Pi")
83 (home-page "https://www.airspayce.com/mikem/bcm2835/")
84 (supported-systems '("armhf-linux" "aarch64-linux"))
85 (license license:gpl3)))
86
87(define-public raspi-gpio
88 (let ((commit "6d0769ac04760b6e9f33b4aa1f11c682237bf368")
89 (revision "1"))
90 (package
91 (name "raspi-gpio")
92 (version (git-version "0.1" revision commit))
93 (source (origin
94 (method git-fetch)
95 (uri (git-reference
96 (url "https://github.com/RPi-Distro/raspi-gpio")
97 (commit commit)))
98 (file-name (git-file-name name version))
99 (sha256
100 (base32
101 "1fia1ma586hwhpda0jz86j6i55andq0wncbhzhzvhf7yc773cpi4"))))
102 (build-system gnu-build-system)
103 (synopsis "State dumper for BCM270x GPIOs")
104 (description "Tool to help debug / hack at the BCM283x GPIO. You can dump
105 the state of a GPIO (or all GPIOs). You can change a GPIO mode and pulls (and
106 level, if set as an output). Beware that this tool writes directly to the
107 BCM283x GPIO registers, ignoring anything else that may be using them (like
108 Linux drivers).")
109 (home-page "https://github.com/RPi-Distro/raspi-gpio")
110 (supported-systems '("armhf-linux" "aarch64-linux"))
111 (license license:bsd-3))))
112
113(define %rpi-open-firmware-version "0.1")
114(define %rpi-open-firmware-origin
115 (origin
116 (method git-fetch)
117 (uri (git-reference
118 (url "https://github.com/librerpi/rpi-open-firmware")
119 (commit "6be45466e0be437a1b0b3512a86f3d9627217006")))
120 (file-name "rpi-open-firmware-checkout")
121 (sha256
122 (base32 "1wyxvv62i3rjicg4hd94pzbgpadinnrgs27sk39md706mm0qixbh"))))
123
124(define-public raspi-arm-chainloader
125 (package
126 (name "raspi-arm-chainloader")
127 (version %rpi-open-firmware-version)
128 (source %rpi-open-firmware-origin)
129 (build-system gnu-build-system)
130 (arguments
131 `(#:tests? #f ; No tests exist
132 #:phases
133 (modify-phases %standard-phases
134 (delete 'configure)
135 (add-before 'build 'setenv
136 (lambda _
137 (setenv "CC" "arm-none-eabi-gcc")
138 (setenv "CXX" "arm-none-eabi-g++")
139 (setenv "AS" "arm-none-eabi-as")
140 (setenv "OBJCOPY" "arm-none-eabi-objcopy")
141 (setenv "BAREMETAL" "1")
142 #t))
143 (add-after 'setenv 'build-tlsf
144 (lambda _
145 (with-directory-excursion "tlsf"
146 ;; Note: Adding "-I../common -I../notc/include".
147 (invoke "make"
148 "CFLAGS=-mtune=arm1176jzf-s -march=armv6zk -mfpu=vfp -mfloat-abi=softfp -I../common -I../notc/include"))))
149 (add-after 'build-tlsf 'build-common
150 (lambda _
151 (with-directory-excursion "common"
152 (invoke "make"
153 ;; Note: Adding "-I.. -I../notc/include".
154 "ARMCFLAGS=-mtune=arm1176jzf-s -march=armv6zk -marm -I.. -I../notc/include"))))
155 (add-after 'build-common 'build-notc
156 (lambda _
157 (with-directory-excursion "notc"
158 (invoke "make"))))
159 (add-after 'build-notc 'chdir
160 (lambda _
161 (chdir "arm_chainloader")
162 (substitute* "Makefile"
163 (("-I[.][.]/")
164 "-I../common -I../common/include -I../notc/include -I../")
165 (("-ltlsf")
166 "-L../common -L../notc -L../tlsf -ltlsf"))
167 #t))
168 (replace 'install
169 (lambda* (#:key outputs #:allow-other-keys)
170 (let* ((out (assoc-ref outputs "out"))
171 (libexec (string-append out "/libexec")))
172 (mkdir-p libexec)
173 (install-file "build/arm_chainloader.elf" libexec)
174 (install-file "build/arm_chainloader.map" libexec)
175 (install-file "build/arm_chainloader.bin" libexec)
176 #t))))))
177 (native-inputs
178 `(("binutils" ,(cross-binutils "arm-none-eabi"))
179 ("gcc" ,(make-gcc-arm-none-eabi-6))))
180 (inputs
181 `())
182 (synopsis "Raspberry Pi ARM bootloader")
183 (description "This package provides a bootloader for the ARM part of a
184Raspberry Pi. Note: It does not work on Raspberry Pi 1.")
185 (home-page "https://github.com/librerpi/rpi-open-firmware/")
186 (license license:gpl2+)))
187
188(define (raspi-config-file name content)
189 "Make a configuration file like config.txt for the Raspberry Pi firmware.
190CONTENT can be a list of strings, which are concatenated with a newline
191character. Alternatively CONTENT can be a string with the full file content."
192 (plain-file
193 name
194 (if (list? content)
195 (string-join content "\n" 'suffix)
196 content)))
197
198(define-public %raspi-config-txt
199 ;; A config.txt file to start the ARM cores up in 64-bit mode if necessary
200 ;; and to include a dtb.txt, bootloader.txt, and a custom.txt, each with
201 ;; separated configurations for the Raspberry Pi firmware.
202 (raspi-config-file
203 "config.txt"
204 `("# See https://www.raspberrypi.org/documentation/configuration/config-txt/README.md for details."
205 ""
206 ,(string-append "arm_64bit=" (if (target-aarch64?) "1" "0"))
207 "include dtb.txt"
208 "include bootloader.txt"
209 "include custom.txt")))
210
211(define-public %raspi-bcm27-dtb-txt
212 ;; A dtb.txt file to be included by the config.txt to ensure that the
213 ;; downstream device tree files bcm27*.dtb will be used.
214 (raspi-config-file
215 "dtb.txt"
216 "upstream_kernel=0"))
217
218(define-public %raspi-bcm28-dtb-txt
219 ;; A dtb.txt file to be included by the config.txt to ensure that the
220 ;; upstream device tree files bcm28*.dtb will be used.
221 ;; This also implies the use of the dtoverlay=upstream.
222 (raspi-config-file
223 "dtb.txt"
224 "upstream_kernel=1"))
225
226(define-public %raspi-u-boot-bootloader-txt
227 ;; A bootloader.txt file to be included by the config.txt to load the
228 ;; U-Boot bootloader.
229 (raspi-config-file
230 "bootloader.txt"
231 '("dtoverlay=upstream"
232 "enable_uart=1"
233 "kernel=u-boot.bin")))
234
235(define (raspi-custom-txt content)
236 "Make a custom.txt file for the Raspberry Pi firmware.
237CONTENT can be a list of strings, which are concatenated with a newline
238character. Alternatively CONTENT can be a string with the full file content."
239 (raspi-config-file "custom.txt" content))
240
241(define (make-raspi-bcm28-dtbs linux)
242 "Make a package with the device-tree files for Raspberry Pi models from the
243kernel LINUX."
244 (package
245 (inherit linux)
246 (name "raspi-bcm28-dtbs")
247 (source #f)
248 (build-system copy-build-system)
249 (arguments
250 #~(list
251 #:phases #~(modify-phases %standard-phases (delete 'unpack))
252 #:install-plan
253 (list (list (search-input-directory %build-inputs
254 "lib/dtbs/broadcom/")
255 "." #:include-regexp '("/bcm....-rpi.*\\.dtb")))))
256 (inputs (list linux))
257 (synopsis "Device-tree files for a Raspberry Pi")
258 (description
259 (format #f "The device-tree files for Raspberry Pi models from ~a."
260 (package-name linux)))))
261
262(define-public grub-efi-bootloader-chain-raspi-64
263 ;; A bootloader capable to boot a Raspberry Pi over network via TFTP or from
264 ;; a local storage like a micro SD card. It neither installs firmware nor
265 ;; device-tree files for the Raspberry Pi. It just assumes them to be
266 ;; existing in boot/efi in the same way that some UEFI firmware with ACPI
267 ;; data is usually assumed to be existing on PCs. It creates firmware
268 ;; configuration files and a bootloader-chain with U-Boot to provide an EFI
269 ;; API for the final GRUB bootloader. It also serves as a blue-print to
270 ;; create a custom bootloader-chain with firmware and device-tree
271 ;; packages or files.
272 (efi-bootloader-chain grub-efi-netboot-removable-bootloader
273 #:packages (list u-boot-rpi-arm64-efi-bin)
274 #:files (list %raspi-config-txt
275 %raspi-bcm27-dtb-txt
276 %raspi-u-boot-bootloader-txt)))
277
278(define (make-raspi-defconfig arch defconfig sha256-as-base32)
279 "Make for the architecture ARCH a file-like object from the DEFCONFIG file
280with the hash SHA256-AS-BASE32. This object can be used as the #:defconfig
281argument of the function (modify-linux)."
282 (make-defconfig
283 (string-append
284 ;; This is from commit 7838840 on branch rpi-5.18.y,
285 ;; see https://github.com/raspberrypi/linux/tree/rpi-5.18.y/
286 ;; and https://github.com/raspberrypi/linux/commit/7838840b5606a2051b31da4c598466df7b1c3005
287 "https://raw.githubusercontent.com/raspberrypi/linux/7838840b5606a2051b31da4c598466df7b1c3005/arch/"
288 arch "/configs/" defconfig)
289 sha256-as-base32))
290
291(define-public %bcm2709-defconfig
292 (make-raspi-defconfig
293 "arm" "bcm2709_defconfig"
294 "1hcxmsr131f92ay3bfglrggds8ajy904yj3vw7c42i4c66256a79"))
295
296(define-public %bcm2711-defconfig
297 (make-raspi-defconfig
298 "arm" "bcm2711_defconfig"
299 "1n7g5yq0hdp8lh0x6bfxph2ff8yn8zisdj3qg0gbn83j4v8i1zbd"))
300
301(define-public %bcm2711-defconfig-64
302 (make-raspi-defconfig
303 "arm64" "bcm2711_defconfig"
304 "0k9q7qvw826v2hrp49xnxnw93pnnkicwx869chvlf7i57461n4i7"))
305
306(define-public %bcmrpi3-defconfig
307 (make-raspi-defconfig
308 "arm64" "bcmrpi3_defconfig"
309 "1bfnl4p0ddx3200dg91kmh2pln36w95y05x1asc312kixv0jgd81"))
310
311(define-public raspberrypi-userland
312 ;; There are no release nor tag; use the latest commit.
313 (let ((revision "0")
314 (commit "54fd97ae4066a10b6b02089bc769ceed328737e0"))
315 (package
316 (name "raspberrypi-userland")
317 (version (git-version "0.0.0" revision commit))
318 (source (origin
319 (method git-fetch)
320 (uri (git-reference
321 (url "https://github.com/raspberrypi/userland")
322 (commit commit)))
323 (file-name (git-file-name name version))
324 (sha256
325 (base32
326 "01853x2kx36vcm1wd0p20v72kw2p4xhnzp36jivh06mhma9b3h2v"))))
327 (build-system cmake-build-system)
328 (arguments
329 (list
330 #:tests? #f ;no test suite
331 #:configure-flags #~(list (string-append "-DVMCS_INSTALL_PREFIX="
332 #$output))
333 #:phases
334 #~(modify-phases %standard-phases
335 (add-after 'unpack 'patch-paths
336 (lambda _
337 (substitute* "interface/khronos/ext/egl_khr_image_client.c"
338 (("/opt/vc/lib/libvcsm.so")
339 (string-append #$output "/lib/libvcsm.so")))))
340 (add-after 'unpack 'disable-hello_pi
341 (lambda _
342 ;; Do not build hello_pi, which installs 32 MiB of binaries
343 ;; and source files to src/.
344 (substitute* "host_applications/linux/CMakeLists.txt"
345 ((".*add_subdirectory\\(apps/hello_pi).*")
346 ""))
347 (substitute* "makefiles/cmake/vmcs.cmake"
348 (("install.*host_applications/linux/apps/hello_pi" all)
349 (string-append "# " all))
350 ((".*DESTINATION \\$\\{VMCS_INSTALL_PREFIX}/src)" all)
351 (string-append "# " all))))))))
352 (native-inputs (list pkg-config))
353 (home-page "https://github.com/raspberrypi/userland/")
354 (supported-systems (list "armhf-linux" "aarch64-linux"))
355 (synopsis "Raspberry Pi GPU-related libraries")
356 (description "This package package contains libraries to interface to
357EGL, mmal, GLESv2, vcos, openmaxil, vchiq_arm, bcm_host, VFC and OpenVG. It
358also provides the @command{dtmerge}, @command{dtoverlay}, @command{dtparam},
359@command{raspivid} and @command{tvservice} commands, among others.")
360 (license license:bsd-3))))
361
362(define-public rpi-fbcp
363 ;; There are no release nor tag; use the latest commit.
364 (let ((revision "0")
365 (commit "af8d32246c23cb23e4030e6588668a14341f5ddc"))
366 (package
367 (name "rpi-fbcp")
368 (version (git-version "0.0.0" revision commit))
369 (source (origin
370 (method git-fetch)
371 (uri (git-reference
372 (url "https://github.com/tasanakorn/rpi-fbcp")
373 (commit commit)))
374 (file-name (git-file-name name version))
375 (sha256
376 (base32
377 "10wym2jckicxm5iwqgby6gbhkznyi1q8x41v0qahzv71x85xpsl5"))))
378 (build-system cmake-build-system)
379 (arguments
380 (list
381 #:tests? #f ;no test suite
382 #:phases
383 #~(modify-phases %standard-phases
384 (replace 'install
385 ;; There is no installation target.
386 (lambda _
387 (install-file "fbcp" (string-append #$output "/bin")))))))
388 (inputs (list raspberrypi-userland))
389 (home-page "https://github.com/tasanakorn/rpi-fbcp")
390 (synopsis "Mirror primary to secondary frame buffer on Raspberry Pi")
391 (description "The @command{fbcp} command provided by this package can be
392used to copy the primary frame buffer to the secondary frame buffer of a
393Raspberry Pi. It can for example mirror the primary HDMI output to a
394secondary LCD display connected to the Raspberry Pi board.")
395 (license license:expat))))
396
397(define-public rpi-imager
398 (package
399 (name "rpi-imager")
400 (version "1.8.5")
401 (source (origin
402 (method git-fetch)
403 (uri (git-reference
404 (url "https://github.com/raspberrypi/rpi-imager")
405 (commit (string-append "v" version))))
406 (file-name (git-file-name name version))
407 (modules '((guix build utils)
408 (ice-9 ftw)
409 (srfi srfi-26)))
410 (snippet '(begin
411 ;; Remove all but the following bundled libraries,
412 ;; which are not yet packaged in Guix.
413 (define keep '("." ".."
414 "drivelist"
415 "mountutils"
416 "sha256crypt"))
417 (with-directory-excursion "src/dependencies"
418 (for-each delete-file-recursively
419 (scandir "." (negate
420 (cut member <> keep)))))))
421 (sha256
422 (base32
423 "1jr4w9h0bvqpy4r1g22n7b07zpplmc318v4lcfvh70c0rhl2vfi6"))))
424 (build-system qt-build-system)
425 (arguments
426 (list
427 #:tests? #f ;no test suite
428 #:configure-flags #~(list "-DENABLE_TELEMETRY=OFF")
429 #:phases
430 #~(modify-phases %standard-phases
431 (add-after 'unpack 'chdir
432 (lambda _
433 (chdir "src")))
434 (add-after 'chdir 'customize-os-list.json
435 ;; The default operating system JSON list contains non-FSDG
436 ;; systems.
437 (lambda _
438 (let* ((datadir (string-append #$output
439 "/share/rpi-imager"))
440 (os-list.json (string-append datadir "/os-list.json")))
441 (mkdir-p datadir)
442 #$(with-extensions (list guile-json-4)
443 #~(begin
444 (use-modules (json))
445 (call-with-output-file os-list.json
446 ;; TODO: Register FSDG and RPi compatible OS
447 ;; images here.
448 (lambda (port)
449 (scm->json '() port)))))
450 (substitute* "config.h"
451 (("#define OSLIST_URL.*")
452 (string-append "#define OSLIST_URL \"file:///"
453 os-list.json "\"\n"))))))
454 (add-after 'chdir 'patch-cmake
455 (lambda _
456 (substitute* "CMakeLists.txt"
457 ;; lsblk expects to have access to /sys/dev/block,
458 ;; which doesn't exist in the build container;
459 ;; prevent the check to fail the build.
460 (("ret EQUAL \"1\"")
461 "FALSE")))))))
462 (inputs
463 (list gnutls
464 curl
465 libarchive
466 qtdeclarative-5
467 qtquickcontrols2-5
468 qtsvg-5
469 qttools-5
470 qtwayland-5
471 util-linux))
472 (home-page "https://github.com/raspberrypi/rpi-imager/")
473 (synopsis "Raspberry Pi Imaging Utility")
474 (description "rpi-imager is graphical utility to easily provision and
475flash a memory card with an operating system image suitable for the Raspberry
476Pi single board computer.")
477 (license license:asl2.0)))
478
479(define-public waveshare-dtoverlays
480 (let ((commit "6ea99d4afb4776fdb008708f3f30df1de6fc24e3")
481 (revision "0"))
482 (package
483 (name "waveshare-dtoverlays")
484 (version (git-version "0.0.0" revision commit))
485 (source (origin
486 (method git-fetch)
487 (uri (git-reference
488 (url "https://github.com/swkim01/waveshare-dtoverlays")
489 (commit commit)))
490 (file-name (git-file-name name version))
491 (modules '((guix build utils)))
492 ;; Delete pre-compiled device tree overlay binary files.
493 (snippet '(for-each delete-file (find-files "." "\\.dtbo$")))
494 (sha256
495 (base32
496 "1c30wnlinicwlivlri25wns6x8nx7asf5fh2zqxkzr9h1jsxbzwz"))))
497 (build-system gnu-build-system)
498 (arguments (list #:tests? #f ;no test suite
499 #:make-flags #~(list (string-append "PREFIX="
500 #$output))
501 #:phases #~(modify-phases %standard-phases
502 (delete 'configure))))
503 (native-inputs (list dtc))
504 (home-page "https://github.com/swkim01/waveshare-dtoverlays/")
505 (synopsis "Device tree overlays for WaveShare SpotPear TFT LCDs")
506 (description "This package contains device tree overlay binaries to
507support the WaveShare SpotPear @acronym{TFT, Thin-Film Transistor}
508@acronym{LCDs, Liquid Crystal Display} on the Raspberry Pi.")
509 (license license:gpl3+))))