Skip to content

SoC: stm32c0 support#3174

Merged
petejohanson merged 3 commits intozmkfirmware:mainfrom
petejohanson:soc/stm32c0-support
Jan 7, 2026
Merged

SoC: stm32c0 support#3174
petejohanson merged 3 commits intozmkfirmware:mainfrom
petejohanson:soc/stm32c0-support

Conversation

@petejohanson
Copy link
Contributor

Small changes needed to support stm32c0

  • Add a new nBOOT_SEL bit initialization check, to ensure the BOOT pin works properly after flashing ZMK the first time.
  • Pull in fork of hal_stm32 that has one small USB fix cherry picked in. Will not be needed once we move to a newer Zephyr version.
  • Temporary: Moving to my Zephyr fork that has some necessary USB/clock setup fixes. PR in Cherry pick of stm32c0 changes needed for full support with USB on v4.1 zephyr#50 will allow us to remove that temporary commit once it's merged.

You can see a test module that works with this here: https://github.com/petejohanson/stm32c0pad-module

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 Dec 28, 2025
@petejohanson petejohanson requested review from a team as code owners December 28, 2025 06:16
@petejohanson petejohanson changed the title Soc/stm32c0 support SoC: stm32c0 support Dec 28, 2025
Copy link
Contributor

@nmunnich nmunnich left a comment

Choose a reason for hiding this comment

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

Code looks alright at a glance, not delving too deeply.

| `CONFIG_ZMK_DBL_TAP_BOOTLOADER` | bool | Enable the double-tap to enter bootloader functionality | y if STM32 or RP2040/RP2350 |
| `CONFIG_ZMK_DBL_TAP_BOOTLOADER_TIMEOUT_MS` | int | Duration (in ms) to wait for a second reset to enter the bootloader | 500 |

### STM32 nBOOT_SEL Option Byte Setup
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like it should be a subsection of the bootloader section. Although considering the new magic value bits aren't documented under configuration, I wonder if we should have a bootloader section separate from system under config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm happy to refactor and make a dedicated "Bootloader Integration" config page, if that's what you were suggesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed your other comments, will do this extraction/refactor once you respond if that was in fact your suggestion. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that is indeed what I am suggesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@petejohanson petejohanson force-pushed the soc/stm32c0-support branch 4 times, most recently from 8c4d2c6 to e0b01e1 Compare December 30, 2025 23:08
Copy link
Contributor

@nmunnich nmunnich left a comment

Choose a reason for hiding this comment

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

Couple typos, LGTM otherwise.

Pull in ZMK fork of hal_stm32 with USB device driver fixes for stm32c0.
Newer STM32 C0 and G0 series SoCs do not by default allow use of the
BOOT0 pin/button to enter the bootloader once something has been flash
to the device, which is a change from previous series, and usually not
what's wanted for keyboards running ZMK. To address this, add some
optional, but default initialization code to check the nBOOT_SEL bit and
override it if necessary to ensure BOOT pin/button functionality.
Pull the bootloader intergration options out of the system configuration
page into their own dedicated one.

Co-authored-by: Nicolas Munnich <98408764+nmunnich@users.noreply.github.com>
@petejohanson petejohanson merged commit f85ec7e into zmkfirmware:main Jan 7, 2026
51 checks passed
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.

2 participants