Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make settings_reset builds reset all settings #2072

Merged
merged 4 commits into from
Mar 18, 2024

Conversation

joelspadin
Copy link
Collaborator

  • Added zmk_settings_erase(), which directly clears the backend data for settings.
  • Changed the settings_reset shield to run this function on startup instead of using CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START, so it now resets all settings instead of just Bluetooth ones.
  • Removed CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START, as it is no longer needed.

Future PRs can add additional ways to trigger zmk_settings_erase().

@joelspadin joelspadin requested a review from a team as a code owner December 14, 2023 06:50
Copy link
Contributor

@petejohanson petejohanson left a comment

Choose a reason for hiding this comment

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

A couple high level questions after a first pass at this.

app/Kconfig Outdated Show resolved Hide resolved
app/boards/shields/settings_reset/settings_reset.c Outdated Show resolved Hide resolved
@joelspadin joelspadin force-pushed the reset-all-settings branch 2 times, most recently from d77a92e to d88bad6 Compare December 17, 2023 06:53
@joelspadin
Copy link
Collaborator Author

Added the new KConfig option to the docs.

Copy link
Contributor

@petejohanson petejohanson left a comment

Choose a reason for hiding this comment

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

A few thoughts.

app/Kconfig Outdated Show resolved Hide resolved
@@ -1 +1,3 @@
CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START=y
CONFIG_ZMK_SETTINGS_RESET_ON_START=y
Copy link
Contributor

Choose a reason for hiding this comment

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

So, this would change this shield a bit from what it used to do... I'm not sure that's a bad thing, but probably warrants a blog post or at least announcement on Discord when merged, so folks are aware of the updated functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

So... the other areas that would be reset by this:

  • Output selection
  • External power on/off
  • Backlight on/off
  • RGB on/off and selected effect

Of those... the output selection and external power are maybe the potentially most troublesome, but I don't think some docs/info wouldn't help address.

Let's move forward with this.

@joelspadin joelspadin force-pushed the reset-all-settings branch 2 times, most recently from 11369b8 to 415c9de Compare January 20, 2024 18:44
Copy link
Contributor

@petejohanson petejohanson left a comment

Choose a reason for hiding this comment

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

Just one comment, but this all seems reasonable. Thoughts on tweaks to the settings reset docs to make it clear what this file now does?

CONFIG_SETTINGS=y
CONFIG_ZMK_SETTINGS_RESET_ON_START=y
# Disable BLE so splits don't try to re-pair until normal firmware is flashed.
CONFIG_ZMK_BLE=n
Copy link
Contributor

Choose a reason for hiding this comment

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

I do wonder if this might lead to folks not being clear if the updated firmware flashed or not... Maybe a docs update to note that when you flash settings reset, the device won't be visible/connectable at all again until flashed with regular firmware?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that seems like it would be good to clarify. Will do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. How does that look?

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM. Has this gotten thorough testing locally there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've tested it with the NVS backend. The file backend is untested. I'm not sure what currently supported build (if any) could be used for that.

Copy link
Contributor

@petejohanson petejohanson left a comment

Choose a reason for hiding this comment

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

Going over this with a fine-toothed comb one last time, found a couple lingering items.

app/Kconfig Outdated Show resolved Hide resolved
app/src/settings/reset_settings_on_start.c Outdated Show resolved Hide resolved
app/src/settings/reset_settings_on_start.c Outdated Show resolved Hide resolved
@joelspadin
Copy link
Collaborator Author

Going over this with a fine-toothed comb one last time, found a couple lingering items.

Rebased and updated everything.

Added a zmk_settings_erase() function to clear all saved settings. This
does not go through Zephyr's settings subsystem, but instead directly
clears the data from the setting storage backend, so a reboot is needed
for it to take effect.
Added a new CONFIG_ZMK_SETTINGS_RESET_ON_START option which enables init
code to call zmk_settings_erase(), and changed the settings_reset shield
to use it instead of CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START, so it now
resets all settings instead of just clearing BLE bonds.

CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START is left in place for now in case
someone still needs it. It may be replaced in the future once we find a
better way to repair a broken split connection.
Updated the section for troubleshooting split halves unable to pair now
that the settings_reset shield resets all settings and explicitly
disables CONFIG_ZMK_BLE:

- Added a note that all settings will be reset.
- Removed the section about immediately putting the halves into
  bootloader mode to prevent pairing, as this is not necessary anymore.
- Added a note that you will not be able to see or pair the Bluetooth
  keyboard until you have flashed regular firmware again.
- Added a sentence to clarify that you will need to re-pair the
  keyboard to all host devices.

Also added some text describing common scenarios where this procedure
might be needed.
@joelspadin joelspadin force-pushed the reset-all-settings branch from 5eff9a2 to 4c8bf3d Compare March 9, 2024 01:57
@petejohanson petejohanson merged commit a77288f into zmkfirmware:main Mar 18, 2024
47 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