Open innovaker opened 3 years ago
For those wishing to dig deeper:
zmk-app
or zmk-module
to create new user applications or modules. Infrequent upstream updates can then be merged in.
setup.sh
)zmk-app
itself (for updating / merging) and thus the user's application also.For those out the loop, the general ideas for discoverability of modules has so far been:
west.yml
entries.I've released v2 of the modular PoC, which is (re-)based onto zmk's main
as of today (f3502dbcb5f017e0b62b9cf09cb0e81c26ce4589 which includes Zephyr v2.4.0).
I've updated the previous posts accordingly. If you've already tried v1 with Docker, you may have to remove the old containers before trying v2.
I have no intentions of making another release in the foreseeable future as it's quite an intensive process.
While testing this on Windows I found an issue with finding module root paths causing mixed styles of path separators, which seems to be fixed in https://github.com/zephyrproject-rtos/zephyr/pull/29243, but it isn't in a stable release of Zephyr yet.
For now I've manually added this fix to my local development workspace, but we should be aware of it when getting closer to a full implementation of this.
Some initial thoughts:
main
entrypoint, versus having their custom code just be in their module w/ init callbacks, etc. Thoughts on having our core library still add a main
unless a Kconfig option is set to disable that? In that scenario it's disabled, we would still export an entrypoint that the user main
could invoke.I think templates like this are really important, ideally they can be as minimalist as possible while still offering the full features. Something I don't love about the current templates for the user config repos is them being external to the core repo, so changes that need coordination are harder.
I would propose those templates actually be in the main repo, and creating new downstream copies can pull from the subdirectory of the core.
One idea that came up earlier today was some GH label conventions for repositories that we could then query on ussng their API to find/discover modules for users.
For the benefit of casual observers, there were some further discussions on Discord:
While making ZMK a "core library" is generally a great move, 95% of users are unlikely to ever want to have a custommain entrypoint, versus having their custom code just be in their module w/ init callbacks, etc. Thoughts on having our core library still add a main unless a Kconfig option is set to disable that? In that scenario it's disabled, we would still export an entrypoint that the user main could invoke.
This makes sense and I'm fine with it. I also tested the principle last night. It's serves the majority but facilitates the minority.
Doing that possibly removes need for a CMakeLists.txt by default in the "user application".
I doubt the bootstrapping code can be removed from the application but I'm not a cmake expert and welcome alternatives.
I would propose those templates actually be in the main repo, and creating new downstream copies can pull from the subdirectory of the core.
I wasn't aware that pulling from a subdirectory of a git repository was possible (unless you're talking about partial clone?)? That's partly why I went for an upstream module approach in the PoC.
Is there any possibility of decoupling the key processing engine as a separate module, independent of LED, key-scanning, sensors, display, power management and BLE/USB HID support? That way a key processing engine can be swapped in and out.
Any updates?
It's been almost 3 years. Has there been no updates or was this just not updated?
@Anutrix This is partially implemented in how currently user config repos work (where zmk
itself is used as a Zephyr module and they support custom boards, shields and custom code for them). Maybe you should note what exactly are you looking to accomplish and what issue are you running into with the current limitations.
I am looking for support on ESP32-S3 which is supported officially by Zephyr Project(https://docs.zephyrproject.org/latest/boards/xtensa/esp32s3_devkitm/doc/index.html; https://github.com/zephyrproject-rtos/zephyr/commits/main/boards/xtensa/esp32s3_devkitm has had most features added by now.) but not ZMK.
It seemed that Modular ZMK would make adding support for it easier before I can deep type into this repo.
Fellow developers, thank you for your patience. The modular proof-of-concept (PoC) is ready for evaluation.
Purpose
This is a (fully functional) proof of concept. Its purpose is to:
What's "a modular ZMK"?
west
tool.zmk-config
with a simple user "application".Motivations
I'm suggesting we consider a modular approach for ZMK because of several pressing issues, including:
zmk-config
.First steps
harmless
shield. Thanks to @mcrosson for letting me based it on thetidbit
.Local development
i.e. developers with an existing ZMK development environment setup on Windows, macOS, Linux or WSL2.
You may need to install v0.11.4 of the Zephyr SDK.
GitHub Actions (cloud)
Actions
tab.I understand my workflows, go ahead and enable them
.Actions
tab.Build
(on the left).Run workflow
(on the right) and run it on Branch:master-v2
Build
job to appear.harmless
shield (< 4 minutes).matrix
list in.github/workflows/build.yml
Docker
If you want to try developing in Docker containers ...
VS Code Remote Containers
Due to current shortcomings in VS Code, VS Code Remote Containers, Codespaces, Docker and the Zephyr build system, it's proving tricky to find an intuitive one-size-fits-all approach for containers. However, their potential benefits make them worthy of further exploration. Here's a guide to the known approaches at time of writing ...
Cloning straight from a repository into a container with VS Code
This approach is my personal preference. It's quick to setup, performant and I don't mind my files being inside volumes. It lets you clone a repository straight into a Docker container/volumes without touching the local system or needing any tools besides VS Code. I also use the WSL2 backend which makes it really fast.
Remote - Containers
extension installed.F1
and enter:> Remote-Containers: Clone
it'll give you a cloning option. Repository URL: https://github.com/innovaker/my-zmk-keyboardCreate a unique volume
Create a new volume ...
zmk-modular-v2
(it can be anything you like)zmk-workspace/my-zmk-keyboard
west update
will run as part of the container setup - it will take a while the first time.Open Workspace
.zmk
folder and give you access to the other VS Code workspace benefits.west build
Cloning to a local disk first, then opening it in VS Code, then reopening it in a container
Some people prefer this method as it makes more sense to them. But it's not as performant.
git clone -b master-v2 https://github.com/innovaker/my-zmk-keyboard
my-zmk-keyboard
folder in VS Code.Reopen in Container
.west update
will run as part of the container setup - it will take a while the first time.Open Workspace
.zmk
folder and give you access to the other VS Code workspace benefits.app
and run:west build
Note, I've configured it to mount
zephyr
and its dependencies into (shared) Docker volumes so that it doesn't take an eternity to runwest update
. These volumes are shared across containers and not junked when you delete a container.zmk
is currently stored within the container itself (so it will be lost/re-cloned if you rebuild the container) but it too can be mounted as a volume by a savvy user (I've left it commented out).Codespaces + nested branch
I've not personally tested Codespaces yet but my cursory understanding is that it's built around the mono-repository paradigm and doesn't support untracked flat structure workspaces??? In anticipation of that, I've' been exploring a nested version of
zmk-app
/my-zmk-keyboard
. I'm not keen on it personally but I made it as an experiment.The branch names are
nested-v2
if you want to try it but it's largely untested.Next steps
CMakeLists.txt
west build -p
(pristine build)west.yml
Going forward