Skip to content

Conversation

petejohanson
Copy link
Contributor

@petejohanson petejohanson commented Sep 4, 2025

Opening this as a draft for now, as there is still work to be done here, along extensive testing, but at this point I want a place where progress, testing results, etc can be tracked.

This is considered beta level at this point, so basic support questions will not be answered on this PR/branch. I welcome testing by anyone willing to, given this level of readiness. TIA.

Prelim Blog Post

@nmunnich prepared an update post, which I am working to round out and finalize: https://deploy-preview-3060--zmk.netlify.app/blog/2025-xx-xx-zephyr-4-1

Testing steps

Local dev

  1. If not building w/ VSCode docker integration, install https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.16.9
  2. gh pr checkout 3060
  3. west update
  4. Use new build directory to build ZMK as usual.

GitHub Actions

Make two edits in the branch of your config repo:

  1. Update .github/workflowr/build.yaml to contain:

    on: [push, pull_request, workflow_dispatch]
    
    jobs:
      build:
        uses: petejohanson/zmk/.github/workflows/build-user-config.yml@core/move-to-zephyr-4-1
    
  2. Update config/west.yaml according to the https://zmk.dev/docs/features/beta-testing/ instructions to test this PR.

Outstanding Items

  • Bring in blog post from docs(blog): Add Zephyr 4.1 upgrade post petejohanson/zmk#48
  • Finish updating existing (nRF52 & RP2040) boards to support newer bootloader approach with retained mem + bootmode APIs from Zephyr
  • Ensure blog post covers HWMv2 upgrades, bootloader changes, nRF52840 DCDC and NFC pin DTS changes, LVGL API changes, LED strip changes, input support for keyboard matrixes (testing only), and anything else discovered during testing
  • Add note to blog post about RP2040 board upgrades: Need to enable CONFIG_CLOCK_CONTROL, adjust DTS include path, boot mode retention.
  • Fix up display screens, including nice!view custom status screen + widgets
  • Integrate split BLE API change code and test thoroughly.
  • Test, test, more testing.
  • Document CMake v3 requirements for some edge cases (nRF5340 where libmetal gets used)

PR check-list

  • Branch has a clean commit history
  • Additional tests are included, if changing behaviors/core code that is testable.
  • Proper Copyright + License headers added to applicable files (Generally, we stick to "The ZMK Contributors" for copyrights to help avoid churn when files get edited)
  • Pre-commit used to check formatting of files, commit messages, etc.
  • Includes any necessary documentation changes.

@petejohanson petejohanson self-assigned this Sep 4, 2025
@petejohanson petejohanson force-pushed the core/move-to-zephyr-4-1 branch from 56ada2e to bfa1389 Compare September 4, 2025 19:45
vbatt: vbatt {
compatible = "zmk,battery-voltage-divider";
io-channels = <&adc 2>;
output-ohms = <2000000>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was deleting this intentional? I noticed this while editing all the boards using zmk,battery-voltage-divider for one of my two approaches for implementing fuel gauge API support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because this board is moved over to using multiple versions, so the specific settings on that come from the version specific overlays. The prop is still set, it's just coming from somewhere else.

@petejohanson petejohanson force-pushed the core/move-to-zephyr-4-1 branch 7 times, most recently from ddd566a to 9eaec16 Compare September 5, 2025 14:34
@petejohanson petejohanson force-pushed the core/move-to-zephyr-4-1 branch from 551b4f8 to 3f59fba Compare September 6, 2025 20:43
@galaxyeden
Copy link

Great to see this making progress, thanks for all your hard work on ZMK! I wanted to move to zephyr,input to get my own board ready for Zephyr 4.2 and I ran into a few issues and notes:

  • There is a maximum of eight rows by default, users may need to select INPUT_KBD_MATRIX_16_BIT_ROW – I did
  • The Zephyr documentation for gpio-kbd-matrix assumes the matrix is active low. In my previous testing, I found this provided a small but noticeable improvement over the active high ZMK-documented configuration, so my keyboard was already set up this way, but it may confuse some users looking at the Zephyr documentation and not understanding the difference, especially newbies
  • gpio-kbd-matrix only supports scanning "columns" and listening on "rows" – this may also confuse some, especially if this doesn't match their physical layout
  • Initially, I could only get five rows to work, @petejohanson suggested it was likely running out of hardware interrupts set on the falling (or rising, for active high) edge of the pin, as gpio-kbd-matrix sets. I'm on an nRF5340 with 8 interrupts available, which is comparable to most common ZMK users' hardware – so anyone with more than (hardware interrupts - defined buttons - other defined interrupt pins) is likely to encounter this. This can be fixed by emulating this behavior in software with port-based interrupts, more below.
  • In physical_layouts.c there is a use of the ZMK_KSCAN_EVENT_QUEUE_SIZE that applies to the zephyr,input scan driver as well. I renamed this Kconfig symbol (for aesthetics) and removed the if ZMK_KSCAN conditional in my fork to resolve this, and it works as expected.

To emulate the falling edge interrupts in software, each GPIO port needs a sense-edge-mask defined. I set this to < 0xffffffff > for both ports and that resolved the issue and my nRF5340-based board is working as expected with zephyr,input.

On the very good news side, I've seen dramatically better power consumption – about 25% lower at idle than before total (≈240uA to ≈180uA), about 40% lower with keys held forcing scanning (at the same 1ms scan interval, my initial, much better results were due to the 5ms default scan interval), and similar – hard to tell but slightly higher if anything – during my "average" typing – with the amount of time spent idle for most users, I expect this to be a significant, though variable, overall power savings if it holds true across multiple SoCs and matrix configurations.

@petejohanson petejohanson force-pushed the core/move-to-zephyr-4-1 branch from 3338b5a to 4a86543 Compare October 2, 2025 05:36
Move to Zephyr v4.1.0, with various build/compilation fixes needed for
basic use.
Add ability to assign a keyboard `input` device to a physical layout,
or use a chosen `zmk,matrix-input`.
Pass NULL user_data to input callbacks.
Handle additional read callback invocation once all matching
characteristic have been read.
Be sure we don't get back any uninitialized data by initializing
the channel data to 0 before calling into the sensor API.
Input callbacks now have a user_data parameter, adjust accordingly.
Small fixes and remove commented dead code left after the split
refactor.
Minor changes to snapshots based on newer Zephyr version.
petejohanson and others added 15 commits October 6, 2025 12:30
Migrate Adv360 Pro left/right to HWMv2.
Refactor the MoErgo Glove80 left/right to HWMv2.
Migrate Mikoto to HWMv2, with non-exact matching, tweaks to I2C
selection to imply it for the 7.2.0 revision for the fuel gauge.
Move Tofu65 2.0 to HMWv2, with ID of just `tofu65`.
Remove dz60rgb, it's no longer readily available and we have other
current stm32 reference designs for testing.
Move Corneish Zen to HMWv2, with IDs of
`corneish_zen_left`/`corneish_zen_right`.
* Add a new .dtsi for setting up nRF52 boot mode/retained memory
  settings
* Adjust XIAO BLE to use the new include file
* Add boot mode to to the nice!nano
Move the ZMK metadata files for upstream Zephyr boards to align with the
HWMv2 directory structure that uses the vendor ID for the parent
directofy for a board directory.
By convention, avoid enabling ZMK Display by default on shields that may
be built with under-resourced controllers (e.g. nRF52833 based ones).
Avoid using WS2812_LED_STRIP, since that Kconfig was renamed/split into
SPI/GPIO/I2S symbols.
Adjust the .conf/.overlay files to match the proper naming for the
XIAO rp2040 board. Also add the necessary Kconfig/DTS bits for
supporting bootloader using retained memory/boot mode retention.
Updated LVGL is bumping our stack size, so adjust the system work queue
and dedicated display queue stack sizes as needed to account for this.
When thread names are enabled, pass a name to the dedicated display
queue for better tracibility when using the thread analyzer.
@petejohanson petejohanson force-pushed the core/move-to-zephyr-4-1 branch 4 times, most recently from 7c371cb to c67bc03 Compare October 12, 2025 06:32
@wlo2
Copy link

wlo2 commented Oct 13, 2025

Can confirm &bootloader is now correctly puts dongle into the bootloader if called from macro (Central locality) for Seeed XIAO nRF52840 with a Adafruit bootloader, solid work!

nmunnich and others added 7 commits October 13, 2025 16:20
Install Zephyr deps using the newer `west packages pip --install`.

Signed-off-by: Peter Johanson <[email protected]>
Add necessary DTS/Kconfig settings to upstream RP2040 boards so they can
use the ZMK bootloader functionality using the boot mode retention
infrastructure.
@petejohanson petejohanson force-pushed the core/move-to-zephyr-4-1 branch from c67bc03 to d209263 Compare October 13, 2025 22:20
Update all links to the Zephyr docs to the 4.1.0 versions to match our
Zephyr version in use.
Some optional modules, like libmetal, which is used on nRF5340,
specfically require CMake v3, so add a note in the native toolchain
setup about this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants