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

@ -9,23 +9,21 @@
#:use-module (guix git-download) #:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)) #:use-module (guix packages))
;; This is the common directory name for zephyr-modules to look for search-paths ;; 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") (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 (define-public zephyr
(let ((version "3.3.0")) (let ((version "3.4.0"))
(package (package
(name "zephyr") (name "zephyr")
(version version) (version version)
@ -37,7 +35,7 @@
(commit (string-append "zephyr-v" version)))) (commit (string-append "zephyr-v" version))))
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (base32 (sha256 (base32
"05afpxlapqd7i9m03c8kj5ph9dbig94zhyb9mrwg41cm7725lw98")))) "1gcry9fxv88js5nymi9akgrkghkwavggj3wqdgg2cz6brr5wg284"))))
(build-system copy-build-system) (build-system copy-build-system)
(arguments (arguments
(list (list
@ -47,12 +45,15 @@
#~(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'set-USER_CACHE_DIR-and-BUILD_VERSION (add-after 'unpack 'set-USER_CACHE_DIR-and-BUILD_VERSION
(lambda _ (lambda _
;; Avoid fetching the BUILD_VERSION from the git repository.
(substitute* "CMakeLists.txt" (substitute* "CMakeLists.txt"
(("if *\\(DEFINED BUILD_VERSION\\)") (("if *\\(DEFINED BUILD_VERSION\\)")
(string-append (string-append
"if (NOT DEFINED BUILD_VERSION)\n" "if (NOT DEFINED BUILD_VERSION)\n"
" set(BUILD_VERSION " #$version ")\n" " set(BUILD_VERSION " #$version ")\n"
"elseif (DEFINED BUILD_VERSION)"))) "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 (with-output-to-file
"cmake/modules/user_cache.cmake" "cmake/modules/user_cache.cmake"
(lambda () (lambda ()
@ -65,9 +66,7 @@
(separator #f)) (separator #f))
(search-path-specification (search-path-specification
(variable "ZEPHYR_MODULES") (variable "ZEPHYR_MODULES")
(files (list %zephyr-module)) (files (list %zephyr-module)))))
(separator ";")
(file-pattern (string-append "^" %zephyr-module-tag)))))
(home-page "https://zephyrproject.org") (home-page "https://zephyrproject.org")
(synopsis "Zephyr Project RTOS") (synopsis "Zephyr Project RTOS")
(description "The Zephyr Project is a scalable real-time operating system (description "The Zephyr Project is a scalable real-time operating system

View file

@ -33,7 +33,7 @@ boilerplate."
(package-inputs zephyr-application) (package-inputs zephyr-application)
(prepend zephyr zephyr-build-tools))) (prepend zephyr zephyr-build-tools)))
(cross-compile-prefix (file-append toolchain "/bin/" target "-"))) (cross-compile-prefix (file-append toolchain "/bin/" target "-")))
(package-with-c-toolchain (package-with-c-toolchain
(package (package
(inherit zephyr-application) (inherit zephyr-application)
(build-system cmake-build-system) (build-system cmake-build-system)
@ -49,14 +49,43 @@ boilerplate."
#:tests? #f #:tests? #f
#:phases #:phases
#~(modify-phases %standard-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 (replace 'install
(lambda _ (lambda _
(let* ((source-prefix (let* ((source-prefix
#$(string-append directory-to-install-from "/" #$(string-append directory-to-install-from "/"
source-prefix)) source-prefix))
(target-prefix (target-prefix
#$(string-append directory-to-install-from "/" #$(string-append directory-to-install-from "/"
target-prefix)) target-prefix))
(source-prefix-length (string-length source-prefix)) (source-prefix-length (string-length source-prefix))
(primary-files-to-install (primary-files-to-install
(list (string-append source-prefix ".uf2"))) (list (string-append source-prefix ".uf2")))
@ -141,10 +170,10 @@ the console.")
#:key #:key
(configure-flags #~(list)) (configure-flags #~(list))
(key (file-append zephyr-module-mcuboot (key (file-append zephyr-module-mcuboot
(zephyr-module-installation-target (zephyr-module-installation-target
zephyr-module-mcuboot) zephyr-module-mcuboot)
"/main/root-rsa-2048.pem"))) "/main/root-rsa-2048.pem")))
"Make an MCUboot bootloader package for Zephyr targeting the Arm "Make an MCUboot bootloader package for Zephyr targeting the Arm
microcontroller BOARD. Add EXTRA-INPUTS to the build and use the list of microcontroller BOARD. Add EXTRA-INPUTS to the build and use the list of
optional CONFIGURE-FLAGS. Use the public KEY file for firmware decryption." optional CONFIGURE-FLAGS. Use the public KEY file for firmware decryption."
(make-zephyr-application-for-arm (make-zephyr-application-for-arm
@ -152,18 +181,28 @@ optional CONFIGURE-FLAGS. Use the public KEY file for firmware decryption."
(name (string-append "zephyr-mcuboot-" board)) (name (string-append "zephyr-mcuboot-" board))
(source (source
(file-append zephyr-module-mcuboot (file-append zephyr-module-mcuboot
(zephyr-module-installation-target zephyr-module-mcuboot) (zephyr-module-installation-target zephyr-module-mcuboot)))
"/boot/zephyr"))
(arguments (arguments
(list (list
#:configure-flags #:configure-flags
#~(append #$configure-flags #~(append #$configure-flags
(list (string-append "-DBOARD=" #$board))))) (list "-S../source/boot/zephyr"
(inputs (append extra-inputs (list zephyr-module-mcuboot)))))) (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 (define-public zephyr-mcuboot-nrf52840dongle_nrf52840
(make-zephyr-mcuboot-for-arm "nrf52840dongle_nrf52840" (make-zephyr-mcuboot-for-arm "nrf52840dongle_nrf52840"
(list zephyr-module-hal-nordic) (list zephyr-module-hal-nordic
zephyr-module-cmsis)
#:configure-flags #:configure-flags
#~(list "-DMCUBOOT_USE_MBED_TLS=y" #~(list "-DMCUBOOT_USE_MBED_TLS=y"
"-DCONFIG_LOG=y"))) "-DCONFIG_LOG=y")))
@ -174,23 +213,23 @@ optional CONFIGURE-FLAGS. Use the public KEY file for firmware decryption."
(version (package-version zephyr-module-mcuboot)) (version (package-version zephyr-module-mcuboot))
(source (file-append zephyr-module-mcuboot (source (file-append zephyr-module-mcuboot
(zephyr-module-installation-target (zephyr-module-installation-target
zephyr-module-mcuboot) zephyr-module-mcuboot)
"mcuboot/scripts")) "mcuboot/scripts"))
(build-system python-build-system) (build-system python-build-system)
(arguments (arguments
(list #:phases (list #:phases
#~(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'disable-broken-tests (add-after 'unpack 'disable-broken-tests
(lambda _ (lambda _
(substitute* "imgtool/keys/ecdsa_test.py" (substitute* "imgtool/keys/ecdsa_test.py"
;; This one is calling _unsupported, which raises an ;; This one is calling _unsupported, which raises an
;; ECDSAUsageError. ;; ECDSAUsageError.
(("def test_keygen") "def broken_test_keygen") (("def test_keygen") "def broken_test_keygen")
;; This one is failing with an AttributeError. ;; This one is failing with an AttributeError.
(("def test_emit_pub") "def broken_test_emit_pub"))))))) (("def test_emit_pub") "def broken_test_emit_pub")))))))
(propagated-inputs (list openssl-3.0 (propagated-inputs (list openssl-3.0
python-cbor2 python-cbor2
python-click python-click
python-cryptography python-cryptography
python-intelhex python-intelhex
python-pyyaml)) python-pyyaml))

View file

@ -9,18 +9,18 @@
(define-public (zephyr-module-installation-target zephyr-module) (define-public (zephyr-module-installation-target zephyr-module)
"Return the target directory for the install-plan of the copy-build-system for "Return the target directory for the install-plan of the copy-build-system for
the ZEPHYR-MODULE package. It needs to match a certain pattern to collect the ZEPHYR-MODULE package. It needs to match a certain pattern to collect
search-paths for zephyr-modules in the ZEPHYR_MOUDULES environment variable." search-paths for zephyr-modules in the ZEPHYR_MOUDULES environment variable."
(string-append (string-append
;; Add the needed prefix to the module name. ;; 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. ;; Get the module name from the usually prefixed package name.
(regexp-substitute #f (string-match "^(zephyr-module-|)" (regexp-substitute #f (string-match "^(zephyr-module-|)"
(package-name zephyr-module)) (package-name zephyr-module))
"" 'post))) "" 'post)))
(define-public zephyr-module-template (define-public zephyr-module-template
"Return a template package to inherit zephyr module packages from. It "Return a template package to inherit zephyr module packages from. It
provides the build-system and proper arguments." provides the build-system and proper arguments."
(package (package
(name "zephyr-module-template") (name "zephyr-module-template")
@ -29,7 +29,7 @@ provides the build-system and proper arguments."
(build-system copy-build-system) (build-system copy-build-system)
(arguments (arguments
(list #:install-plan (list #:install-plan
#~(list #~(list
(list "." #$(zephyr-module-installation-target this-package))))) (list "." #$(zephyr-module-installation-target this-package)))))
(home-page #f) (home-page #f)
(synopsis #f) (synopsis #f)
@ -59,10 +59,10 @@ Software Interface Standard.")
(define-public zephyr-module-hal-nordic (define-public zephyr-module-hal-nordic
(let ((revision "1") (let ((revision "1")
(commit "a1c3e0fbaafda091139b8744becd4853ada2f747")) (commit "cf6e9fc5f7c2c98df26f2a4227a95df9a50823e7"))
(package/inherit zephyr-module-template (package/inherit zephyr-module-template
(name "zephyr-module-hal-nordic") (name "zephyr-module-hal-nordic")
(version (git-version "3.0.0" revision commit)) (version (git-version "3.1.0" revision commit))
(source (origin (source (origin
(method git-fetch) (method git-fetch)
(uri (git-reference (uri (git-reference
@ -71,7 +71,7 @@ Software Interface Standard.")
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 (base32
"1y0sz6m0fpfwxrsqrn29vvd5dxmk9804s4gwpxc9rdd79adklbab")))) "1zbnhf7r9sg67xjhbdh6fn4gvccc71pxqcmbfnsi6a75bhfv9y55"))))
(home-page "https://github.com/zephyrproject-rtos/hal_nordic") (home-page "https://github.com/zephyrproject-rtos/hal_nordic")
(synopsis "Zephyr module for Nordic Semiconductor's SoCs and SiPs") (synopsis "Zephyr module for Nordic Semiconductor's SoCs and SiPs")
(description "Zephyr module providing the Hardware Abstraction Layer for (description "Zephyr module providing the Hardware Abstraction Layer for
@ -113,10 +113,12 @@ Supported SoCs and SiPs:
(define-public zephyr-module-hal-stm32 (define-public zephyr-module-hal-stm32
(let ((revision "1") (let ((revision "1")
(commit "c865374fc83d93416c0f380e6310368ff55d6ce2")) (commit "d466dc8421ee0c6592bb5682aa93a671bc948107"))
(package/inherit zephyr-module-template (package/inherit zephyr-module-template
(name "zephyr-module-hal-stm32") (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 (source (origin
(method git-fetch) (method git-fetch)
(uri (git-reference (uri (git-reference
@ -128,17 +130,17 @@ Supported SoCs and SiPs:
"0q0ckial6a3lvlag44zm65dklbbdnqpzr1vbh85dhwx7acpjd5ni")))) "0q0ckial6a3lvlag44zm65dklbbdnqpzr1vbh85dhwx7acpjd5ni"))))
(home-page "https://github.com/zephyrproject-rtos/hal_stm32") (home-page "https://github.com/zephyrproject-rtos/hal_stm32")
(synopsis "Zephyr module for STM32 microcontrollers") (synopsis "Zephyr module for STM32 microcontrollers")
(description "Zephyr module providing the required STM32cube packages, (description "Zephyr module providing the required STM32cube packages,
dtsi files and libraries needed to build a Zephyr application running on STM32 dtsi files and libraries needed to build a Zephyr application running on STM32
silicon.") silicon.")
(license license:bsd-3)))) (license license:bsd-3))))
(define-public zephyr-module-lvgl (define-public zephyr-module-lvgl-8.2.0
(let ((revision "1") (let ((revision "1")
(commit "70a7849726be8375e3d941153dc417823ea7f355")) (commit "70a7849726be8375e3d941153dc417823ea7f355"))
(package/inherit zephyr-module-template (package/inherit zephyr-module-template
(name "zephyr-module-lvgl") (name "zephyr-module-lvgl")
(version (git-version "8.2.0" revision commit)) ; Taken from lvgl.h. (version (git-version "8.2.0" revision commit)) ; Taken from lvgl.h.
(source (origin (source (origin
(method git-fetch) (method git-fetch)
(uri (git-reference (uri (git-reference
@ -155,12 +157,28 @@ Graphics Library for an embedded GUI with graphical elements, visual effects
and a low memory footprint.") and a low memory footprint.")
(license license:apsl2)))) (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 (define-public zephyr-module-mbedtls
(let ((revision "1") (let ((revision "1")
(commit "711fd5ea13a5e018cebe1ac1f79c22d897e8b34d")) (commit "c38dc78d9a8dcbe43b898cc1171ab33ba3e6fc26"))
(package/inherit zephyr-module-template (package/inherit zephyr-module-template
(name "zephyr-module-mbedtls") (name "zephyr-module-mbedtls")
(version (git-version "3.3.0" revision commit)) (version (git-version "3.4.0" revision commit))
(source (origin (source (origin
(method git-fetch) (method git-fetch)
(uri (git-reference (uri (git-reference
@ -169,7 +187,7 @@ and a low memory footprint.")
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 (base32
"0lvvarwx735g2bc272n03gp8dsx0bn0i4cywmi6igrc6dyqwkabq")))) "0661myy0wjz38nypbyfw51x10mzg57syb5c28irblgjm2w25wbi7"))))
(home-page "https://github.com/zephyrproject-rtos/mbedtls") (home-page "https://github.com/zephyrproject-rtos/mbedtls")
(synopsis "Zephyr module for Mbed TLS") (synopsis "Zephyr module for Mbed TLS")
(description "Zephyr module providing Mbed TLS, a C library that (description "Zephyr module providing Mbed TLS, a C library that
@ -180,7 +198,7 @@ embedded systems.")
(define-public zephyr-module-mcuboot (define-public zephyr-module-mcuboot
(let ((revision "1") (let ((revision "1")
(commit "74c4d1c52fd51d07904b27a7aa9b2303e896a4e3")) (commit "76d19b3b8885ea7ae25a6f4f5d8501f7ec646447"))
(package/inherit zephyr-module-template (package/inherit zephyr-module-template
(name "zephyr-module-mcuboot") (name "zephyr-module-mcuboot")
(version (git-version "1.11.0-dev" revision commit)) (version (git-version "1.11.0-dev" revision commit))
@ -192,7 +210,7 @@ embedded systems.")
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 (base32
"14g95wjqxchv2vnpzld8in6ljlw6s2cj43nlyf6g8czyy5rx99qb")))) "1frm9330bir1cz7h87qq26r74igy3pvrz3iqpvc7r6l7silj0fxf"))))
(home-page "https://github.com/zephyrproject-rtos/mcuboot") (home-page "https://github.com/zephyrproject-rtos/mcuboot")
(synopsis "Zephyr module for MCUboot") (synopsis "Zephyr module for MCUboot")
(description "Zephyr module providing the secure bootloader MCUboot for (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") (home-page "https://github.com/zephyrproject-rtos/tinycrypt")
(synopsis "Zephyr module for the TinyCrypt library") (synopsis "Zephyr module for the TinyCrypt library")
(description "Zephyr module providing 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

@ -35,11 +35,11 @@ ZMK_CONFIG environment varibale during a ZMK Firmware package build to its
configuration input. Add a file-like object like a file-union or a package configuration input. Add a file-like object like a file-union or a package
containing a zmk-config/config folder as build input to a ZMK Firmare packege.") containing a zmk-config/config folder as build input to a ZMK Firmare packege.")
(license license:expat))) (license license:expat)))
(define*-public (make-zmk board (define*-public (make-zmk board
#:key #:key
(shield "") (shield "")
(extra-inputs '()) (extra-inputs '())
(extra-name "") (extra-name "")
(patches '()) (patches '())
@ -53,8 +53,8 @@ SNIPPET to modify the ZMK sources."
(commit "9d714c0b69fee2098a010d29e534051aeca26386") (commit "9d714c0b69fee2098a010d29e534051aeca26386")
(underscore->hyphen (lambda (name) (underscore->hyphen (lambda (name)
(string-map (lambda (char) (string-map (lambda (char)
(if (char=? char #\_) (if (char=? char #\_)
#\- #\-
char)) char))
name))) name)))
(board-name (underscore->hyphen board)) (board-name (underscore->hyphen board))
@ -87,7 +87,7 @@ SNIPPET to modify the ZMK sources."
'())))) '()))))
(inputs (append extra-inputs (inputs (append extra-inputs
(list zephyr-module-cmsis (list zephyr-module-cmsis
zephyr-module-lvgl zephyr-module-lvgl-8.2.0
zephyr-module-tinycrypt zephyr-module-tinycrypt
zmk-config))) zmk-config)))
(home-page "https://zmk.dev") (home-page "https://zmk.dev")
@ -103,7 +103,7 @@ built on the Zephyr™ Project Real Time Operating System (RTOS).")
(define*-public (make-nrfmicro-13-zmk shield #:key zmk-config (extra-name "")) (define*-public (make-nrfmicro-13-zmk shield #:key zmk-config (extra-name ""))
"Make a ZMK firmware package for a keyboard consisting of the nrfmicro 1.3/1.4 "Make a ZMK firmware package for a keyboard consisting of the nrfmicro 1.3/1.4
board with a SHIELD PCB. Use the ZMK-CONFIG directory containing optional board with a SHIELD PCB. Use the ZMK-CONFIG directory containing optional
boards/ or dts/ directories, or .conf, .keypad, .overlay files prefixed with boards/ or dts/ directories, or .conf, .keypad, .overlay files prefixed with
shield or board names." shield or board names."
(make-zmk (make-zmk
@ -145,7 +145,7 @@ settings-reset firmware files."
(define (hid-modifier modifier) (define (hid-modifier modifier)
(define hid-modifier->zmk-macro (define hid-modifier->zmk-macro
'(( . LS) ( . LC) ( . LA) ( . LG) '(( . LS) ( . LC) ( . LA) ( . LG)
(R . RG) (R . RA) (R . RC) (R . RS))) (R . RG) (R . RA) (R . RC) (R . RS)))
(or (assoc-ref hid-modifier->zmk-macro modifier) modifier)) (or (assoc-ref hid-modifier->zmk-macro modifier) modifier))
@ -166,7 +166,7 @@ settings-reset firmware files."
;; Backlight, requires one parameter. ;; Backlight, requires one parameter.
( . &bl))) ( . &bl)))
(or (assoc-ref special-bindings->zmk-name key-label) key-label)) (or (assoc-ref special-bindings->zmk-name key-label) key-label))
(define-public (hid key-label) (define-public (hid key-label)
(define hid->zmk-name (define hid->zmk-name
'(( . ESC) ( . PSCRN) ( . SLCK) ( . PAUSE_BREAK) '(( . ESC) ( . PSCRN) ( . SLCK) ( . PAUSE_BREAK)
@ -187,12 +187,12 @@ settings-reset firmware files."
(÷ . KP_DIVIDE) (* . KP_MULTIPLY) ( . KP_MINUS) (+ . KP_PLUS) (÷ . KP_DIVIDE) (* . KP_MULTIPLY) ( . KP_MINUS) (+ . KP_PLUS)
(P1 . KP_N1) (P2 . KP_N2) (P3 . KP_N3) (P4 . KP_N4) (P5 . KP_N5) (P1 . KP_N1) (P2 . KP_N2) (P3 . KP_N3) (P4 . KP_N4) (P5 . KP_N5)
(P6 . KP_N6) (P7 . KP_N7) (P8 . KP_N8) (P9 . KP_N9) (P0 . KP_N0) (P6 . KP_N6) (P7 . KP_N7) (P8 . KP_N8) (P9 . KP_N9) (P0 . KP_N0)
(P. . KP_DOT) (P, . KP_COMMA) ( . ENTER) (P. . KP_DOT) (P, . KP_COMMA) ( . ENTER)
( . C_AC_CUT) ( . C_AC_COPY) ( . C_AC_PASTE) ( . C_AC_CUT) ( . C_AC_COPY) ( . C_AC_PASTE)
( . C_AC_UNDO) ( . C_AC_REDO) ( . C_AC_UNDO) ( . C_AC_REDO)
( . C_AL_KEYBOARD_LAYOUT))) ( . C_AL_KEYBOARD_LAYOUT)))
(special-bindings (or (assoc-ref hid->zmk-name key-label) key-label))) (special-bindings (or (assoc-ref hid->zmk-name key-label) key-label)))
(define-public (de key-label) (define-public (de key-label)
(define de->hid (define de->hid
'((ß . -) (´ . =) '((ß . -) (´ . =)
@ -201,14 +201,14 @@ settings-reset firmware files."
(< . \) (Y . Z) (- . /) (< . \) (Y . Z) (- . /)
(P+ . +) (P, . P.) (P. . P,))) (P+ . +) (P, . P.) (P. . P,)))
(hid (or (assoc-ref de->hid key-label) key-label))) (hid (or (assoc-ref de->hid key-label) key-label)))
(define-public (neo key-label) (define-public (neo key-label)
(define neo->de (define neo->de
'((T1 . ^) '((T1 . ^)
(X . Q) (V . W) (L . E) (C . R) (W . T) (X . Q) (V . W) (L . E) (C . R) (W . T)
(M3 . ) (U . A) (I . S) (A . D) (E . F) (O . G) (M3 . ) (U . A) (I . S) (A . D) (E . F) (O . G)
(M4 . <) (Ü . Y) (Ö . X) (Ä . C) (P . V) (Z . B) (M4 . <) (Ü . Y) (Ö . X) (Ä . C) (P . V) (Z . B)
(- . ß) (T2 . ´) (- . ß) (T2 . ´)
(K . Z) (H . U) (G . I) (F . O) (Q . P) ( . Ü) (T3 . +) (K . Z) (H . U) (G . I) (F . O) (Q . P) ( . Ü) (T3 . +)
(S . H) (N . J) (R . K) (T . L) (D . Ö) (Y . Ä) (RM3 . ) (S . H) (N . J) (R . K) (T . L) (D . Ö) (Y . Ä) (RM3 . )
(B . N) (J . -) (RM4 . R) (B . N) (J . -) (RM4 . R)
@ -269,7 +269,7 @@ respresentation of ZMK."
(modified-key->zmk unmodified-key)) (modified-key->zmk unmodified-key))
(key-label (key-label
(key-label->zmk key-label)))) (key-label->zmk key-label))))
(define (behavior->zmk behavior strings-of-layers-and-modified-keys) (define (behavior->zmk behavior strings-of-layers-and-modified-keys)
"Join a BEHAVIOR symbol like '&mt with STRINGS-OF-LAYERS-AND-MODIFIED-KEYS "Join a BEHAVIOR symbol like '&mt with STRINGS-OF-LAYERS-AND-MODIFIED-KEYS
as parameters like '(\"LALT\" \"ESC\") into the \"&mt LALT ESC\" respresentation as parameters like '(\"LALT\" \"ESC\") into the \"&mt LALT ESC\" respresentation
@ -304,12 +304,12 @@ ZMK behavior for a keymap layer."
(string-join (map (lambda (zmk-behavior) (string-join (map (lambda (zmk-behavior)
(string-pad-right (string-pad-right
zmk-behavior zmk-behavior
(max 12 (string-length zmk-behavior)))) (max 12 (string-length zmk-behavior))))
(map key-binding->zmk key-bindings)))) (map key-binding->zmk key-bindings))))
(string-append " " name "_layer {" (string-append " " name "_layer {"
"\n bindings = <" "\n bindings = <"
(string-join (map keys->zmk (drop-right rows 1)) (string-join (map keys->zmk (drop-right rows 1))
"\n " 'prefix) "\n " 'prefix)
"\n >;" "\n >;"
(if (null? (last rows)) (if (null? (last rows))
@ -429,29 +429,29 @@ resolved by flashing this settings reset firmware to both controllers.")))
(zmk-keymap (zmk-keymap
#:layers #:layers
`(("default" ,neo `(("default" ,neo
( N1 N2 N3 N4 N5 N6 N7 N8 N9 N0 ) ( N1 N2 N3 N4 N5 N6 N7 N8 N9 N0 )
( X V L C W T2 K H G F Q ) ( X V L C W T2 K H G F Q )
( M3 U I A E O T3 S N R T D ,M3Y) ( M3 U I A E O T3 S N R T D ,M3Y)
(,- Ü Ö Ä P Z R R B M · J ,R) (,- Ü Ö Ä P Z R R B M · J ,R)
( T1 ,l0 M4 RM4 R ,l1 ,l0 ,- R ) ( T1 ,l0 M4 RM4 R ,l1 ,l0 ,- R )
()) ())
("cursor" ,neo ("cursor" ,neo
( F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 ) ( F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 )
( ) ( )
( ) ( )
(,- R R ) (,- R R )
( ,l1 R ,l1 ,- R ) ( ,l1 R ,l1 ,- R )
()) ())
("keypad" ,neo ("keypad" ,neo
( F11 F12 F13 F14 F15 P ÷ * ) ( F11 F12 F13 F14 F15 P ÷ * )
( P7 P8 P9 P+ ) ( P7 P8 P9 P+ )
( M3 P4 P5 P6 P= M3 ) ( M3 P4 P5 P6 P= M3 )
(,- R R P1 P2 P3 R ) (,- R R P1 P2 P3 R )
( ,l2 M4 RM4 R P0 P, ,. R ) ( ,l2 M4 RM4 R P0 P, ,. R )
()) ())
("zmk" ,neo ("zmk" ,neo
( ,1 ,2 ,3 ,4 ,5 ) ( ,1 ,2 ,3 ,4 ,5 )
( ) ( )
( , , , ) ( , , , )
( ) ( )
( ,l3 ,l3 ) ( ,l3 ,l3 )