Get gcc-arm-none-eabi, zephyr, ZMK, redox-neo-nrfmicro-13-zmk working.

This commit is contained in:
Stefan 2023-09-03 12:53:12 +02:00
parent 5557bf3001
commit 16b3f2b99c
5 changed files with 673 additions and 1944 deletions

File diff suppressed because it is too large Load diff

View file

@ -11,21 +11,19 @@
#:use-module (guix packages))
;; This is the common directory name for zephyr-modules to look for search-paths
;; to collect in the ZEPHYR_MODULES environment variable.
;; to collect in the ZEPHYR_MODULES environment variable. The build-system of
;; Zephyr searches for a file zephyr/module.yml in all paths listed in the
;; environment variable ZEPHYR_MODULES. If that file is missing a name
;; property, then the parent directory name is used as the module name. Having
;; two modules with the same name is treated as an error. As Guix needs a
;; common directory name for search-path-specification, we need this
;; intermediate directory as a pattern and to have unique module names.
;; Unfortunately search-path-specification is still not powerful enough, so
;; complete-zephyr-application needs the correct-ZEPHYR_MODULES build-phase.
(define-public %zephyr-module "zephyr-module")
;; This is the common directory prefix of zephyr-modules to collect for
;; search-paths in ZEPHYR_MODULES. The build-system of Zephyr searches for
;; a file zephyr/module.yml in all paths listed in the environment variable
;; ZEPHYR_MODULES. If that file is missing a name property, then the parent
;; directory name is used as the module name. Having two modules with the same
;; name is treated as an error. As Guix needs a common directory name for
;; search-path-specification, we need this intermediate directory prefix as a
;; pattern and to have unique module names.
(define-public %zephyr-module-tag "ZEPHYR-MODULE-TAG-")
(define-public zephyr
(let ((version "3.3.0"))
(let ((version "3.4.0"))
(package
(name "zephyr")
(version version)
@ -37,7 +35,7 @@
(commit (string-append "zephyr-v" version))))
(file-name (git-file-name name version))
(sha256 (base32
"05afpxlapqd7i9m03c8kj5ph9dbig94zhyb9mrwg41cm7725lw98"))))
"1gcry9fxv88js5nymi9akgrkghkwavggj3wqdgg2cz6brr5wg284"))))
(build-system copy-build-system)
(arguments
(list
@ -47,12 +45,15 @@
#~(modify-phases %standard-phases
(add-after 'unpack 'set-USER_CACHE_DIR-and-BUILD_VERSION
(lambda _
;; Avoid fetching the BUILD_VERSION from the git repository.
(substitute* "CMakeLists.txt"
(("if *\\(DEFINED BUILD_VERSION\\)")
(string-append
"if (NOT DEFINED BUILD_VERSION)\n"
" set(BUILD_VERSION " #$version ")\n"
"elseif (DEFINED BUILD_VERSION)")))
;; Avoid USER_CACHE_DIR to point to XDG_CACHE_HOME, HOME, or to
;; ZEPHYR_BASE inside the store. Instead use the build dir.
(with-output-to-file
"cmake/modules/user_cache.cmake"
(lambda ()
@ -65,9 +66,7 @@
(separator #f))
(search-path-specification
(variable "ZEPHYR_MODULES")
(files (list %zephyr-module))
(separator ";")
(file-pattern (string-append "^" %zephyr-module-tag)))))
(files (list %zephyr-module)))))
(home-page "https://zephyrproject.org")
(synopsis "Zephyr Project RTOS")
(description "The Zephyr Project is a scalable real-time operating system

View file

@ -49,6 +49,35 @@ boilerplate."
#:tests? #f
#:phases
#~(modify-phases %standard-phases
(add-after 'set-paths 'correct-ZEPHYR_MODULES
;; The search-path-specification is not powerful enough. Zephyr
;; modules contain a zephyr-module/<name>/zephyr directory
;; without a common pattern for <name> and the ZEPHYR_MODULES
;; environment variable needs to list the zephyr-module/<name>
;; directories separated by semicolons.
(lambda _
(use-modules (ice-9 regex))
(let ((zephyr-modules (getenv "ZEPHYR_MODULES")))
(when zephyr-modules
(setenv "ZEPHYR_MODULES"
(string-join
(map
(lambda (module)
(dirname
(car
(let ((length (string-length module)))
(find-files module
(lambda (name stat)
(string-match
"^/[^/]+/zephyr$"
(string-drop name length)))
#:directories? #t)))))
(string-split zephyr-modules #\:))
";"))
(format
#t
"environment variable `ZEPHYR_MODULES' set to `~a'~%"
(getenv "ZEPHYR_MODULES"))))))
(replace 'install
(lambda _
(let* ((source-prefix
@ -152,18 +181,28 @@ optional CONFIGURE-FLAGS. Use the public KEY file for firmware decryption."
(name (string-append "zephyr-mcuboot-" board))
(source
(file-append zephyr-module-mcuboot
(zephyr-module-installation-target zephyr-module-mcuboot)
"/boot/zephyr"))
(zephyr-module-installation-target zephyr-module-mcuboot)))
(arguments
(list
#:configure-flags
#~(append #$configure-flags
(list (string-append "-DBOARD=" #$board)))))
(inputs (append extra-inputs (list zephyr-module-mcuboot))))))
(list "-S../source/boot/zephyr"
(string-append "-DBOARD=" #$board)
(string-append "-DTINYCRYPT_DIR=PATH:"
#$zephyr-module-tinycrypt
"/zephyr-module/tinycrypt/lib")))))
(inputs (append extra-inputs (list python-cbor2
python-click
python-cryptography
python-intelhex
zephyr-module-mcuboot
zephyr-module-mbedtls
zephyr-module-zcbor))))))
(define-public zephyr-mcuboot-nrf52840dongle_nrf52840
(make-zephyr-mcuboot-for-arm "nrf52840dongle_nrf52840"
(list zephyr-module-hal-nordic)
(list zephyr-module-hal-nordic
zephyr-module-cmsis)
#:configure-flags
#~(list "-DMCUBOOT_USE_MBED_TLS=y"
"-DCONFIG_LOG=y")))

View file

@ -13,7 +13,7 @@ the ZEPHYR-MODULE package. It needs to match a certain pattern to collect
search-paths for zephyr-modules in the ZEPHYR_MOUDULES environment variable."
(string-append
;; Add the needed prefix to the module name.
"/" %zephyr-module "/" %zephyr-module-tag
"/" %zephyr-module "/"
;; Get the module name from the usually prefixed package name.
(regexp-substitute #f (string-match "^(zephyr-module-|)"
(package-name zephyr-module))
@ -59,10 +59,10 @@ Software Interface Standard.")
(define-public zephyr-module-hal-nordic
(let ((revision "1")
(commit "a1c3e0fbaafda091139b8744becd4853ada2f747"))
(commit "cf6e9fc5f7c2c98df26f2a4227a95df9a50823e7"))
(package/inherit zephyr-module-template
(name "zephyr-module-hal-nordic")
(version (git-version "3.0.0" revision commit))
(version (git-version "3.1.0" revision commit))
(source (origin
(method git-fetch)
(uri (git-reference
@ -71,7 +71,7 @@ Software Interface Standard.")
(file-name (git-file-name name version))
(sha256
(base32
"1y0sz6m0fpfwxrsqrn29vvd5dxmk9804s4gwpxc9rdd79adklbab"))))
"1zbnhf7r9sg67xjhbdh6fn4gvccc71pxqcmbfnsi6a75bhfv9y55"))))
(home-page "https://github.com/zephyrproject-rtos/hal_nordic")
(synopsis "Zephyr module for Nordic Semiconductor's SoCs and SiPs")
(description "Zephyr module providing the Hardware Abstraction Layer for
@ -113,10 +113,12 @@ Supported SoCs and SiPs:
(define-public zephyr-module-hal-stm32
(let ((revision "1")
(commit "c865374fc83d93416c0f380e6310368ff55d6ce2"))
(commit "d466dc8421ee0c6592bb5682aa93a671bc948107"))
(package/inherit zephyr-module-template
(name "zephyr-module-hal-stm32")
(version (git-version "1.16.0" revision commit))
;; Using highest version number listed in:
;; https://github.com/zephyrproject-rtos/hal_stm32/blob/main/stm32cube/common_ll/README.rst
(version (git-version "1.27.1" revision commit))
(source (origin
(method git-fetch)
(uri (git-reference
@ -133,7 +135,7 @@ dtsi files and libraries needed to build a Zephyr application running on STM32
silicon.")
(license license:bsd-3))))
(define-public zephyr-module-lvgl
(define-public zephyr-module-lvgl-8.2.0
(let ((revision "1")
(commit "70a7849726be8375e3d941153dc417823ea7f355"))
(package/inherit zephyr-module-template
@ -155,12 +157,28 @@ Graphics Library for an embedded GUI with graphical elements, visual effects
and a low memory footprint.")
(license license:apsl2))))
(define-public zephyr-module-lvgl
(let ((revision "2")
(commit "5da257f782a8f9c6e265bdc60ebc2a93fdee24de"))
(package/inherit zephyr-module-lvgl-8.2.0
(name "zephyr-module-lvgl")
(version (git-version "8.3.7" revision commit)) ; Taken from lvgl.h.
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/zephyrproject-rtos/lvgl")
(commit commit)))
(file-name (git-file-name name version))
(sha256
(base32
"14isczxi36dasks1w4hwdlbzpvja4wal458i0km0hi92bbxayg0a")))))))
(define-public zephyr-module-mbedtls
(let ((revision "1")
(commit "711fd5ea13a5e018cebe1ac1f79c22d897e8b34d"))
(commit "c38dc78d9a8dcbe43b898cc1171ab33ba3e6fc26"))
(package/inherit zephyr-module-template
(name "zephyr-module-mbedtls")
(version (git-version "3.3.0" revision commit))
(version (git-version "3.4.0" revision commit))
(source (origin
(method git-fetch)
(uri (git-reference
@ -169,7 +187,7 @@ and a low memory footprint.")
(file-name (git-file-name name version))
(sha256
(base32
"0lvvarwx735g2bc272n03gp8dsx0bn0i4cywmi6igrc6dyqwkabq"))))
"0661myy0wjz38nypbyfw51x10mzg57syb5c28irblgjm2w25wbi7"))))
(home-page "https://github.com/zephyrproject-rtos/mbedtls")
(synopsis "Zephyr module for Mbed TLS")
(description "Zephyr module providing Mbed TLS, a C library that
@ -180,7 +198,7 @@ embedded systems.")
(define-public zephyr-module-mcuboot
(let ((revision "1")
(commit "74c4d1c52fd51d07904b27a7aa9b2303e896a4e3"))
(commit "76d19b3b8885ea7ae25a6f4f5d8501f7ec646447"))
(package/inherit zephyr-module-template
(name "zephyr-module-mcuboot")
(version (git-version "1.11.0-dev" revision commit))
@ -192,7 +210,7 @@ embedded systems.")
(file-name (git-file-name name version))
(sha256
(base32
"14g95wjqxchv2vnpzld8in6ljlw6s2cj43nlyf6g8czyy5rx99qb"))))
"1frm9330bir1cz7h87qq26r74igy3pvrz3iqpvc7r6l7silj0fxf"))))
(home-page "https://github.com/zephyrproject-rtos/mcuboot")
(synopsis "Zephyr module for MCUboot")
(description "Zephyr module providing the secure bootloader MCUboot for
@ -219,5 +237,27 @@ bootloader that enables easy software upgrade.")
(home-page "https://github.com/zephyrproject-rtos/tinycrypt")
(synopsis "Zephyr module for the TinyCrypt library")
(description "Zephyr module providing the TinyCrypt library.")
(license (license:non-copyleft "file://README")))))
(license (license:non-copyleft "file://README.zephyr")))))
(define-public zephyr-module-zcbor
(let ((revision "1")
(commit "67fd8bb88d3136738661fa8bb5f9989103f4599e"))
(package/inherit zephyr-module-template
(name "zephyr-module-zcbor")
(version (git-version "0.7.0" revision commit))
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/zephyrproject-rtos/zcbor")
(commit commit)))
(file-name (git-file-name name version))
(sha256
(base32
"16138k7xlahf63dfvplm8c2m0kxs1g17gcx1fa31y4gcfbi3b0k7"))))
(home-page "https://github.com/zephyrproject-rtos/zcbor")
(synopsis "Zephyr module for the zcbor library")
(description "Zephyr module providing the zcbor low footprint CBOR
(Concise Binary Object Representation) library in the C language, tailored for
use in microcontrollers.")
(license license:apsl2))))

View file

@ -87,7 +87,7 @@ SNIPPET to modify the ZMK sources."
'()))))
(inputs (append extra-inputs
(list zephyr-module-cmsis
zephyr-module-lvgl
zephyr-module-lvgl-8.2.0
zephyr-module-tinycrypt
zmk-config)))
(home-page "https://zmk.dev")