Skip to content

Conversation

alex-tdrn
Copy link
Contributor

@alex-tdrn alex-tdrn commented Aug 10, 2025

I've tested these changes by running the cargo test + cargo check with and without the vial feature.

I haven't tested directly that a firmware built with vial in mind still works as expected, but I've tested that some of the examples build and flash. Would need some help here from other people to test these changes, if they use vial.

Made it so we test multiple combinations of features on CI, since the storage tests have not been working for a while.
Also add cargo check with different feature sets. This way, any PR will be alerted if they have leftover code that's not needed for one of the feature combinations.

I've tested that I can use non-modifier tap-hold with the "vial" feature removed (although there seem to be some key repeating bugs, which I'm still investigating. I don't think they are related to this PR though). So this closes #470 .

Also added a .gitattributes and .editorconfig file to force everything to have LF endings. I'm on windows, and neovim creates CRLF by default, if there's no .editorconfig file telling it otherwise.

NOTE: this is a breaking change for users who have no-default-features in their Cargo.toml. They will have to add back the vial feature, unless they use the matrix_tester or vial_lock features, since they automatically bring in the vial feature.

EDIT: would also close #272

Copy link

github-actions bot commented Aug 10, 2025

Binary Size Report

use_config/nrf52832_ble

   text	   data	    bss	    dec	    hex	filename
 305540	   5040	  37028	 347608	  54dd8	rmk-nrf52832
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +375  [ = ]       0    .debug_info
  +0.1%    +258  [ = ]       0    .debug_loc
  +0.1%    +183  [ = ]       0    .debug_line
  +1.5%    +118  [ = ]       0    .debug_abbrev
  +0.2%     +56  +0.2%     +56    .rodata
   +45%     +19  [ = ]       0    [Unmapped]
  -0.2%      -1  [ = ]       0    .defmt
  -0.0%      -8  [ = ]       0    .debug_aranges
  -0.0%      -8  -0.0%      -8    .text
  -0.0%     -40  [ = ]       0    .debug_ranges
  -0.0%     -48  [ = ]       0    .symtab
  -0.1%    -231  [ = ]       0    .strtab
  -0.0%    -925  [ = ]       0    .debug_str
  -0.0%    -252  +0.0%     +48    TOTAL

use_config/nrf52840_ble

   text	   data	    bss	    dec	    hex	filename
 343068	   5040	  99420	 447528	  6d428	rmk-nrf52840
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +478  [ = ]       0    .debug_info
  +0.0%    +152  [ = ]       0    .debug_loc
  +0.0%    +103  [ = ]       0    .debug_line
  +0.1%     +56  +0.1%     +56    .rodata
  +0.0%     +16  [ = ]       0    .symtab
  -0.1%      -1  [ = ]       0    .defmt
 -14.0%      -6  [ = ]       0    [Unmapped]
  -0.0%      -8  [ = ]       0    .debug_aranges
  -0.0%     -16  -0.0%     -16    .text
  -0.0%     -32  [ = ]       0    .debug_ranges
  -0.1%    -224  [ = ]       0    .strtab
  -0.0%    -730  [ = ]       0    .debug_str
  -0.0%    -212  +0.0%     +40    TOTAL

use_config/nrf52840_ble_split

   text	   data	    bss	    dec	    hex	filename
 412012	   6260	  45332	 463604	  712f4	central

   text	   data	    bss	    dec	    hex	filename
 262584	   5668	  26420	 294672	  47f10	peripheral
Diff

Central Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +425  [ = ]       0    .debug_info
  +0.0%    +123  [ = ]       0    .debug_line
  +0.1%     +56  +0.1%     +56    .rodata
  +0.0%     +40  [ = ]       0    .debug_ranges
  +0.0%     +29  [ = ]       0    .debug_loc
  +0.0%     +16  [ = ]       0    .symtab
  -0.0%      -8  [ = ]       0    .debug_aranges
 -14.5%      -8  [ = ]       0    [Unmapped]
  -0.0%     -20  -0.0%     -20    .text
  -0.0%    -103  [ = ]       0    .debug_str
  -0.1%    -222  [ = ]       0    .strtab
  +0.0%    +328  +0.0%     +36    TOTAL

Peripheral Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.2%    +343  [ = ]       0    .debug_line
  -0.0%      -1  [ = ]       0    .strtab
  -1.9%      -1  [ = ]       0    [Unmapped]
  -0.0%      -8  [ = ]       0    .debug_aranges
  -0.0%    -406  [ = ]       0    .debug_info
  -0.1% -1.20Ki  [ = ]       0    .debug_str
  -0.0% -1.27Ki  [ = ]       0    TOTAL

use_config/pi_pico_w_ble

   text	   data	    bss	    dec	    hex	filename
 576000	      0	  56092	 632092	  9a51c	rmk-pi-pico-w
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +113  [ = ]       0    .debug_line
  +0.0%     +48  +0.0%     +48    .rodata
  -0.2%      -1  [ = ]       0    .defmt
  -6.0%      -3  [ = ]       0    [Unmapped]
  -0.0%      -8  [ = ]       0    .debug_aranges
  -0.0%     -12  -0.0%     -12    .text
  -0.0%     -24  [ = ]       0    .debug_ranges
  -0.1%     -80  [ = ]       0    .symtab
  -0.1%    -248  [ = ]       0    .strtab
  -0.0%    -570  [ = ]       0    .debug_info
  -0.1% -1.04Ki  [ = ]       0    .debug_loc
  -0.1% -2.12Ki  [ = ]       0    .debug_str
  -0.1% -3.93Ki  +0.0%     +36    TOTAL

use_config/pi_pico_w_ble_split

   text	   data	    bss	    dec	    hex	filename
 604280	      0	  58656	 662936	  a1d98	central

   text	   data	    bss	    dec	    hex	filename
 479832	      0	  41744	 521576	  7f568	peripheral
Diff

Central Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +734  [ = ]       0    .debug_str
  +0.0%     +56  +0.0%     +56    .rodata
  +0.0%     +32  [ = ]       0    .debug_loc
  +0.0%     +25  [ = ]       0    .debug_info
   +30%     +13  [ = ]       0    [Unmapped]
  +0.0%     +10  [ = ]       0    .debug_line
  -0.1%      -1  [ = ]       0    .defmt
  -0.0%      -8  [ = ]       0    .debug_aranges
  -0.0%      -8  [ = ]       0    .debug_ranges
  -0.0%     -36  -0.0%     -36    .text
  -0.1%     -80  [ = ]       0    .symtab
  -0.1%    -209  [ = ]       0    .strtab
  +0.0%    +528  +0.0%     +20    TOTAL

Peripheral Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +44  [ = ]       0    .debug_line
  +0.0%     +17  [ = ]       0    .strtab
  +5.7%      +3  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  -0.0%      -8  [ = ]       0    .debug_aranges
  -0.0%     -83  [ = ]       0    .debug_info
  -0.0%    -389  [ = ]       0    .debug_str
  -0.0%    -420  -0.0%      -4    TOTAL

use_config/rp2040

   text	   data	    bss	    dec	    hex	filename
 128928	      0	  21732	 150660	  24c84	rmk-rp2040
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +107  [ = ]       0    .debug_str
  +0.0%     +15  [ = ]       0    .debug_line
   +35%     +12  [ = ]       0    [Unmapped]
  +0.0%      +4  [ = ]       0    .strtab
  -0.0%     -10  [ = ]       0    .debug_info
  -0.0%     -12  -0.0%     -12    .text
  +0.0%    +116  -0.0%     -12    TOTAL

use_config/rp2040_split

   text	   data	    bss	    dec	    hex	filename
 140588	      0	  16728	 157316	  26684	central

   text	   data	    bss	    dec	    hex	filename
  22320	      0	   2280	  24600	   6018	peripheral
Diff

Central Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +171  [ = ]       0    .debug_str
  +0.0%     +18  [ = ]       0    .debug_loc
  +0.0%     +12  +0.0%     +12    .text
  +0.0%      +7  [ = ]       0    .strtab
 -22.4%     -11  [ = ]       0    [Unmapped]
  -0.0%     -87  [ = ]       0    .debug_info
  -0.1%    -142  [ = ]       0    .debug_line
  -0.0%     -32  +0.0%     +12    TOTAL

Peripheral Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +1  [ = ]       0    .debug_info
  -0.0%      -1  [ = ]       0    .strtab
  -4.5%      -3  [ = ]       0    [Unmapped]
  -0.0%      -5  [ = ]       0    .debug_str
  -0.0%      -8  [ = ]       0    TOTAL

use_config/stm32f1

   text	   data	    bss	    dec	    hex	filename
  82628	     24	  14524	  97176	  17b98	rmk-stm32f1
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +9  [ = ]       0    .strtab
  -7.4%      -4  [ = ]       0    [Unmapped]
  -0.0%      -5  [ = ]       0    .debug_line
  -0.0%      -5  [ = ]       0    .debug_loc
  -0.0%    -217  [ = ]       0    .debug_info
  -0.0%    -370  [ = ]       0    .debug_str
  -0.0%    -592  [ = ]       0    TOTAL

use_config/stm32f4

   text	   data	    bss	    dec	    hex	filename
 132536	    316	  17432	 150284	  24b0c	rmk-stm32f4
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +790  [ = ]       0    .debug_str
  +0.0%    +234  [ = ]       0    .debug_info
  +0.0%     +11  [ = ]       0    .strtab
  -3.2%      -2  [ = ]       0    [Unmapped]
  -0.1%    -153  [ = ]       0    .debug_line
  +0.0%    +880  [ = ]       0    TOTAL

use_config/stm32h7

   text	   data	    bss	    dec	    hex	filename
 119444	    260	  16608	 136312	  21478	rmk-stm32h7
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +495  [ = ]       0    .debug_str
  +0.0%     +72  [ = ]       0    .debug_info
  +0.0%     +33  [ = ]       0    .debug_loc
  +0.0%     +19  [ = ]       0    .debug_line
  +0.0%      +4  +0.0%      +4    .text
  +0.0%      +3  [ = ]       0    .strtab
  -9.4%      -6  [ = ]       0    [Unmapped]
  +0.0%    +620  +0.0%      +4    TOTAL

@alex-tdrn
Copy link
Contributor Author

Ah, didn't take the toml config into account. I'll fix it tomorrow.

@@ -1,3 +1,5 @@
#![cfg(feature = "vial")]
Copy link
Owner

Choose a reason for hiding this comment

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

It's unnecessary because this file is already behind vial feature gate in via/mod.rs

@@ -1,3 +1,5 @@
#![cfg(feature = "vial")]
Copy link
Owner

Choose a reason for hiding this comment

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

It's unnecessary because this file is already behind vial feature gate in via/mod.rs

@HaoboGu
Copy link
Owner

HaoboGu commented Aug 11, 2025

Thanks for the work!

Is it possible to move vial related code to separated sub-mods? For example, adding a vial.rs in src/ble/trouble and moving vial code to src/ble/trouble/vial.rs. This way could reduce the usage of #[cfg(not(feature = "vial"))].

And, I have to admit the current implementation is not very clear, all those features aren't decoupled very well, making it hard to extract/disable a single functionality. Some refactoring is needed 🥲

@alex-tdrn
Copy link
Contributor Author

Thanks for the work!

Is it possible to move vial related code to separated sub-mods? For example, adding a vial.rs in src/ble/trouble and moving vial code to src/ble/trouble/vial.rs. This way could reduce the usage of #[cfg(not(feature = "vial"))].

And, I have to admit the current implementation is not very clear, all those features aren't decoupled very well, making it hard to extract/disable a single functionality. Some refactoring is needed 🥲

True, I'll try to isolate vial a bit better this week, and I'll see what I can come up with ✌️. Marking this as draft again until I fix CI and do some refactoring to reduce the cfg soup a bit.

@alex-tdrn alex-tdrn marked this pull request as draft August 11, 2025 07:24
Contributors who work on Windows might accidentally commit newly
created files with CRLF line endings, later causing noisy diffs
when Linux developers work on the same files and they do not have
`core.autocrlf = true`.
However nowadays, most text editors work with LF line endings just
fine on windows, so there's no need for this incompatibility.

Add an `.editorconfig` file which causes the text editor to create
new files using LF from the get-go instead of CRLF (VSCode needs
https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
in order to conform, neovim has support for this built-in).

Add a `.gitattributes` file to tell git to always checkout files using
LF as line ending.

https://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/
https://docs.github.com/en/get-started/git-basics/configuring-git-to-handle-line-endings
this allows users who do not need vial to use more complex combinations
of features that cannot be expressed in the VIA binary format, such as
e.g. non-modifier tap-hold
previously, the "storage" feature was not being tested, which lead
to test code for the storage feature to become out of date
this makes sure that we don't have dead code left over when it is not
needed for certain features
@alex-tdrn alex-tdrn force-pushed the separate_vial_feature branch from 9464017 to 3a58a02 Compare August 17, 2025 08:04
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.

Non-modifier tap-hold support Option to disable Vial configuration storage
2 participants