Skip to content

Commit dee5388

Browse files
authored
Merge pull request HaoboGu#161 from HaoboGu/feat/add_clear_storage_option
feat(storage): add `clear_storage` option
2 parents 72294e7 + 6f29ac7 commit dee5388

File tree

20 files changed

+51
-3
lines changed

20 files changed

+51
-3
lines changed

docs/src/faq.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ By default, Rust compiler generates `elf` file in target folder. There're a litt
3838

3939
This script requires you have `python` command available in your commandline. Some platforms have `python3` command only, you can change `python` in `Makefile.toml` to `python3` in this case.
4040

41+
### I changed keymap in `keyboard.toml`, but the keyboard is not updated
42+
43+
RMK assumes that users change the keymap using [vial](https://vial.rocks). So reflashing the firmware won't change the keymap by default. For testing senario, RMK provides a config `clear_storage` under `[storage]` section, you can enable it to clear the storage when the keyboard boots.
44+
45+
```toml
46+
[storage]
47+
# Set `clear_storage` to true to clear all the stored info when the keyboard boots
48+
clear_storage = true
49+
```
50+
51+
Note that the storage will be clear EVERYTIME you reboot the keyboard.
52+
4153
### I can see a `RMK Start` log, but nothing else
4254

4355
First you need to check the RCC config of your board, make sure that the USB's clock is enabled and set to 48MHZ. For example, if you're using stm32f1, you can set the RCC as the following:

docs/src/storage.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ enabled = true
2121
start_addr = 0x00000000
2222
# How many sectors are used for storage, the default value is 2
2323
num_sectors = 2
24+
# Clear storage at keyboard boot.
25+
# Set it to true will reset the storage(including keymap, BLE bond info, etc.) at each reboot.
26+
# This option is useful when testing the firmware.
27+
clear_storage = false
2428
```
2529

2630
You can also edit `storage_config` field in `RmkConfig` if you're using Rust API:
@@ -31,6 +35,7 @@ You can also edit `storage_config` field in `RmkConfig` if you're using Rust API
3135
let storage_config = StorageConfig {
3236
start_addr: 0x70000,
3337
num_sectors: 2,
38+
..Default::default()
3439
};
3540
let keyboard_config = RmkConfig {
3641
usb_config: keyboard_usb_config,

examples/use_config/nrf52840_ble/keyboard.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ cols = 3
1919
layers = 2
2020
keymap = [
2121
[
22-
["A", "B", "C"],
22+
["A", "A", "A"],
2323
["Kc1", "Kc2", "Kc3"],
2424
["LCtrl", "MO(1)", "LShift"],
2525
["OSL(1)", "LT(2, Kc9)", "LM(1, LShift | LGui)"]
@@ -45,6 +45,7 @@ capslock.low_active = false
4545
[storage]
4646
# Storage feature is enabled by default
4747
# enabled = false
48+
clear_storage = true
4849

4950
[ble]
5051
enabled = true

examples/use_rust/nrf52832_ble/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ async fn main(spawner: Spawner) {
4747
let storage_config = StorageConfig {
4848
start_addr: 0x70000,
4949
num_sectors: 2,
50+
..Default::default()
5051
};
5152
let keyboard_config = RmkConfig {
5253
usb_config: keyboard_usb_config,

examples/use_rust/nrf52840_ble/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ async fn main(spawner: Spawner) {
9696
let storage_config = StorageConfig {
9797
start_addr: 0,
9898
num_sectors: 6,
99+
..Default::default()
99100
};
100101
let keyboard_config = RmkConfig {
101102
usb_config: keyboard_usb_config,

examples/use_rust/nrf52840_ble_split/src/central.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ async fn main(spawner: Spawner) {
9898
let storage_config = StorageConfig {
9999
start_addr: 0,
100100
num_sectors: 6,
101+
..Default::default()
101102
};
102103
let keyboard_config = RmkConfig {
103104
usb_config: keyboard_usb_config,

rmk-macro/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `clear_storage` option
13+
1014
## [0.3.4] - 2024-11-27
1115

1216
### Changed

rmk-macro/src/config/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ pub struct StorageConfig {
7777
pub num_sectors: Option<u8>,
7878
#[serde(default = "default_true")]
7979
pub enabled: bool,
80+
// Clear on the storage at reboot, set this to true if you want to reset the keymap
81+
pub clear_storage: Option<bool>,
8082
}
8183

8284
#[derive(Clone, Default, Debug, Deserialize)]

rmk-macro/src/default_config/esp32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(crate) fn default_esp32(chip: ChipModel) -> KeyboardConfig {
1717
start_addr: Some(0),
1818
num_sectors: Some(32),
1919
enabled: true,
20+
..Default::default()
2021
},
2122
..Default::default()
2223
}

rmk-macro/src/default_config/nrf52810.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(crate) fn default_nrf52810(chip: ChipModel) -> KeyboardConfig {
1717
start_addr: Some(0x28000),
1818
num_sectors: Some(8),
1919
enabled: true,
20+
..Default::default()
2021
},
2122
..Default::default()
2223
}

0 commit comments

Comments
 (0)