Metriche repository
- Star
- (20.368 star)
- Metriche merge PR
- (Merge medio 20g 9h) (27 PR mergiate in 30 g)
Descrizione
Describe the Bug
Loading a custom configuration for VIA is commonly implemented as follows:
void via_init_kb(void) {
if (via_eeprom_is_valid()) {
// Read config from EEPROM
} else {
// Write default config to EEPROM
}
}
This will load the configuration from the EEPROM if VIA's magic values are present, otherwise a default configuration will be stored. This works correctly in some cases, however, if the keyboard is restarted after clearing the EEPROM without any further writes to the configuration, a blank configuration will be loaded. Steps to replicate are as follows:
- Use Bootmagic Lite to reset EEPROM.
- Reconnect keyboard to exit bootloader. This causes a default custom configuration to be used and saved.
- Reconnect keyboard without making any changes that cause the custom configuration to be updated. This causes a blank configuration to be loaded.
I believe this is caused by the following:
keyboard_initis called which callsvia_initwhich then callsvia_init_kb.- On returning from
via_init_kb,via_initchecks to see if the EEPROM is valid and useseeconfig_init_viato initialise it if not. keyboard_initeventually callsquantum_initwhich callsmagicto check if the EEPROM starts with the magic number (different to VIA's magic values). If the magic number isn't presenteeconfig_initis called.eeconfig_initcallseeconfig_init_quantumwhich callseeprom_driver_eraseto erase the EEPROM, clearing any writes that have already occurred.eeconfig_init_quantumthen callseeconfig_init_viato initialise VIA's EEPROM again, but without callingvia_init_kb.
An easy workaround is to save the configuration at a later stage such as within keyboard_post_init_user, although this potentially causes EEPROM writes on every boot. Another workaround would be to write defaults in eeconfig_init_kb and perform reads within keyboard_post_init_user.
Keyboard Used
No response
Link to product page (if applicable)
No response
Operating System
No response
qmk doctor Output
No response
Is AutoHotKey / Karabiner installed
- AutoHotKey (Windows)
- Karabiner (macOS)
Other keyboard-related software installed
No response
Additional Context
No response