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

Don't make EEPROM size assumptions with dynamic keymaps. #16054

Merged
merged 8 commits into from Feb 2, 2022

Conversation

tzarc
Copy link
Member

@tzarc tzarc commented Jan 26, 2022

Description

Individuals have broken their boards by using the default assumption of having 1kB of EEPROM available.
Falling back to the transient EEPROM driver, which defaults to 36 bytes, means enabling VIA is going to attempt to obliterate up to 1kB of RAM past the start of the transient EEPROM array.

This PR fixes the dynamic keymap code such that it actually uses the selected driver's overall limit.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@tzarc tzarc requested a review from a team January 26, 2022 08:22
@github-actions github-actions bot added the core label Jan 26, 2022
@tzarc tzarc added the bug label Jan 26, 2022
@tzarc tzarc marked this pull request as ready for review January 26, 2022 08:39
@drashna drashna requested a review from a team January 26, 2022 16:55
Comment on lines 76 to 81
/* These bits are used for optimizing encoding of bytes, 0 and 1 */
#define FEE_WORD_ENCODING 0x8000
#define FEE_VALUE_NEXT 0x6000
#define FEE_VALUE_RESERVED 0x4000
#define FEE_VALUE_ENCODED 0x2000
#define FEE_BYTE_RANGE 0x80
Copy link
Contributor

Choose a reason for hiding this comment

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

These defines are not used in the size calculations below and may stay internal (although their values are related to FEE_ADDRESS_MAX_SIZE, because that value is determined by the encoding used here, and FEE_ADDRESS_MAX_SIZE is needed in the size checks).

Comment on lines 86 to 87
/* Flash word value after erase */
#define FEE_EMPTY_WORD ((uint16_t)0xFFFF)
Copy link
Contributor

Choose a reason for hiding this comment

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

This also does not need to be in the header file.

@github-actions github-actions bot added keyboard keymap via Adds via keymap and/or updates keyboard for via support cli qmk cli command python labels Jan 27, 2022
@drashna
Copy link
Member

drashna commented Jan 29, 2022

@sigprof look good?

Copy link
Contributor

@sigprof sigprof left a comment

Choose a reason for hiding this comment

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

The qmk multibuild change should be made in a separate PR, but the EEPROM changes look good (hope that they won't break existing boards — now some of them would probably get much more available space for macros).

@tzarc tzarc marked this pull request as draft January 30, 2022 19:46
@tzarc
Copy link
Member Author

tzarc commented Jan 30, 2022

I've converted to draft while I go through and confirm binary reproducibility. As you've said, some of them have gained support for more space, I want to confirm that this is indeed the only side-effect.

@tzarc
Copy link
Member Author

tzarc commented Feb 2, 2022

Looking at diff's between a handful of builds looks very much isolated to sizing changes -- traditionally more eeprom was available with the wear-leveling EEPROM-on-flash implementation but VIA was still artificially limited to 1kB by default.

@tzarc
Copy link
Member Author

tzarc commented Feb 2, 2022

The qmk multibuild change should be made in a separate PR

Will raise it.

@github-actions github-actions bot removed the cli qmk cli command label Feb 2, 2022
@tzarc tzarc marked this pull request as ready for review February 2, 2022 04:04
@tzarc tzarc merged commit e22efc0 into qmk:develop Feb 2, 2022
@tzarc tzarc deleted the dynamic-keymap-maxlen branch February 2, 2022 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug core keyboard keymap via Adds via keymap and/or updates keyboard for via support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants