Skip to content

feat: embed version and git hash in USB serial number#864

Open
jpds wants to merge 4 commits into
HaoboGu:mainfrom
jpds:feat/usb-serial-version-stamp
Open

feat: embed version and git hash in USB serial number#864
jpds wants to merge 4 commits into
HaoboGu:mainfrom
jpds:feat/usb-serial-version-stamp

Conversation

@jpds

@jpds jpds commented May 27, 2026

Copy link
Copy Markdown
Contributor

This PR changes the serial number from the static string (vial:f64c2b3c:000001) and replaces it with a build-time stamp of the form rmk:<version>-<git-hash> (with or without vial:... based on feature flags). Allowing users to know what they have flashed on their devices.

Vial's util.py looks for the string, anywhere in the serial.

Downstream firmware wanting to append their own build info can use const_format::concatcp!(rmk::config::RMK_BUILD_INFO, ";my-fw:", ...)

@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown

Size Report

Example main PR Diff .text .data .bss
use_config/nrf52832_ble 372.0 KiB 372.1 KiB +0.00% ⬆️ +36 0 0
use_config/nrf52840_ble 421.8 KiB 421.8 KiB -0.01% ⬇️ -44 0 0
use_config/nrf52840_ble_split (central) 497.1 KiB 497.2 KiB +0.00% ⬆️ +20 0 0
use_config/nrf52840_ble_split (peripheral) 322.3 KiB 322.3 KiB +0.00% ⬇️ -4 0 0
use_config/pi_pico_w_ble 659.2 KiB 659.2 KiB +0.00% ⬆️ +4 0 0
use_config/rp2040 147.1 KiB 147.1 KiB +0.01% ⬆️ +20 0 0
use_config/rp2040_split (central) 160.4 KiB 160.4 KiB +0.00% ⬆️ +8 0 0
use_config/rp2040_split (peripheral) 27.4 KiB 27.4 KiB +0.00% 0 0 0
use_config/stm32f1 62.5 KiB 62.5 KiB +0.00% 0 0 0
use_config/stm32h7 99.9 KiB 99.9 KiB +0.00% ⬆️ +4 0 0
use_rust/nrf52832_ble 359.5 KiB 359.5 KiB +0.00% ⬆️ +16 0 0
use_rust/nrf52840_ble 417.9 KiB 417.9 KiB +0.00% ⬆️ +32 0 0
use_rust/nrf52840_ble_split (central) 506.7 KiB 506.7 KiB +0.01% ⬆️ +56 0 0
use_rust/nrf52840_ble_split (peripheral) 319.1 KiB 319.1 KiB +0.00% ⬇️ -12 0 0
use_rust/pi_pico_w_ble 659.8 KiB 659.8 KiB +0.00% ⬆️ +32 0 0
use_rust/rp2040 147.2 KiB 147.2 KiB +0.01% ⬆️ +16 0 0
use_rust/rp2040_split (central) 159.5 KiB 159.5 KiB +0.00% ⬆️ +8 0 0
use_rust/rp2040_split (peripheral) 27.8 KiB 27.8 KiB +0.01% ⬆️ +4 0 0
use_rust/stm32f1 62.5 KiB 62.5 KiB +0.00% ⬇️ -4 0 0
use_rust/stm32h7 121.1 KiB 121.1 KiB +0.01% ⬆️ +16 0 0
use_config/nrf52832_ble — 372.0 KiB → 372.1 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 341356	   5256	  34376	 380988	  5d03c	rmk-nrf52832

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 341320	   5256	  34376	 380952	  5d018	rmk-nrf52832

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +1.77Ki  [ = ]       0    .debug_info
  +0.2% +1.03Ki  [ = ]       0    .debug_loc
  +0.0%    +448  [ = ]       0    .debug_str
  +0.0%     +96  [ = ]       0    .debug_line
  +0.1%     +32  +0.1%     +32    .rodata
  +0.0%      +4  +0.0%      +4    .text
 -10.6%      -7  [ = ]       0    [Unmapped]
  -0.0%      -8  [ = ]       0    .debug_aranges
  -0.0%     -10  [ = ]       0    .strtab
  -0.0%     -20  [ = ]       0    .debug_frame
  -0.0%     -32  [ = ]       0    .debug_ranges
  -0.0%     -32  [ = ]       0    .symtab
  -0.7%     -57  [ = ]       0    .debug_abbrev
  +0.0% +3.21Ki  +0.0%     +36    TOTAL
use_config/nrf52840_ble — 421.8 KiB → 421.8 KiB (-0.01% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 375432	   5264	  51176	 431872	  69700	rmk-nrf52840

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 375476	   5264	  51176	 431916	  6972c	rmk-nrf52840

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +1.99Ki  [ = ]       0    .debug_info
  +0.0% +1.21Ki  [ = ]       0    .debug_str
  +0.2% +1.15Ki  [ = ]       0    .debug_loc
  +0.5% +1.05Ki  [ = ]       0    .debug_ranges
  +0.1%    +357  [ = ]       0    .debug_line
  +0.1%    +160  [ = ]       0    .symtab
  +0.0%    +124  [ = ]       0    .strtab
  +0.2%     +76  [ = ]       0    .debug_frame
  +0.1%     +40  [ = ]       0    .debug_aranges
  +0.1%     +32  +0.1%     +32    .rodata
   +24%     +11  [ = ]       0    [Unmapped]
  -0.2%     -14  [ = ]       0    .debug_abbrev
  -0.0%     -76  -0.0%     -76    .text
  +0.1% +6.09Ki  -0.0%     -44    TOTAL
use_config/nrf52840_ble_split (central) — 497.1 KiB → 497.2 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 455504	   6588	  46992	 509084	  7c49c	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 455484	   6588	  46992	 509064	  7c488	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +240  [ = ]       0    .debug_ranges
  +0.1%     +36  +0.1%     +36    .rodata
   +16%      +9  [ = ]       0    [Unmapped]
  -0.0%      -4  [ = ]       0    .strtab
  -0.0%     -10  [ = ]       0    .debug_loc
  -0.0%     -16  -0.0%     -16    .text
  -0.0%     -55  [ = ]       0    .debug_line
  -0.7%     -62  [ = ]       0    .debug_abbrev
  -0.0%    -105  [ = ]       0    .debug_info
  -0.0%    -969  [ = ]       0    .debug_str
  -0.0%    -936  +0.0%     +20    TOTAL
use_config/nrf52840_ble_split (peripheral) — 322.3 KiB → 322.3 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 296576	   5920	  27512	 330008	  50918	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 296580	   5920	  27512	 330012	  5091c	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +915  [ = ]       0    .debug_str
  +0.1%    +812  [ = ]       0    .debug_info
  +0.0%     +97  [ = ]       0    .debug_line
  +0.0%     +22  [ = ]       0    .debug_loc
  +0.0%      +5  [ = ]       0    .strtab
   +11%      +5  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  +0.0% +1.81Ki  -0.0%      -4    TOTAL
use_config/pi_pico_w_ble — 659.2 KiB → 659.2 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 619484	      0	  55572	 675056	  a4cf0	rmk-pi-pico-w

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 619480	      0	  55572	 675052	  a4cec	rmk-pi-pico-w

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +32  +0.0%     +32    .rodata
  +0.0%     +14  [ = ]       0    .strtab
 -10.3%      -6  [ = ]       0    [Unmapped]
  -0.0%     -28  -0.0%     -28    .text
  -0.6%     -66  [ = ]       0    .debug_abbrev
  -0.0%    -104  [ = ]       0    .debug_ranges
  -0.0%    -118  [ = ]       0    .debug_line
  -0.0%    -476  [ = ]       0    .debug_str
  -0.1%    -822  [ = ]       0    .debug_loc
  -0.0%    -866  [ = ]       0    .debug_info
  -0.0% -2.38Ki  +0.0%      +4    TOTAL
use_config/rp2040 — 147.1 KiB → 147.1 KiB (+0.01% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 135260	      0	  15372	 150632	  24c68	rmk-rp2040

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 135240	      0	  15372	 150612	  24c54	rmk-rp2040

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +135  [ = ]       0    .debug_line
  +0.0%     +80  [ = ]       0    .debug_str
  +0.0%     +39  [ = ]       0    .debug_info
  +0.1%     +12  +0.1%     +12    .rodata
   +31%     +12  [ = ]       0    [Unmapped]
  +0.0%     +10  [ = ]       0    .debug_loc
  +0.0%      +8  +0.0%      +8    .text
  +0.0%      +4  [ = ]       0    .strtab
  +0.0%    +300  +0.0%     +20    TOTAL
use_config/rp2040_split (central) — 160.4 KiB → 160.4 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 148044	      0	  16184	 164228	  28184	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 148036	      0	  16184	 164220	  2817c	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +49  [ = ]       0    .debug_str
  +0.0%     +22  [ = ]       0    .debug_loc
  +0.1%     +12  +0.1%     +12    .rodata
  +0.0%      +7  [ = ]       0    .strtab
  -0.0%      -4  -0.0%      -4    .text
 -16.7%      -7  [ = ]       0    [Unmapped]
  -0.0%     -86  [ = ]       0    .debug_line
  -0.0%    -157  [ = ]       0    .debug_info
  -0.0%    -164  +0.0%      +8    TOTAL
use_config/rp2040_split (peripheral) — 27.4 KiB → 27.4 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  25260	     60	   2764	  28084	   6db4	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  25260	     60	   2764	  28084	   6db4	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  -0.0%      -4  [ = ]       0    .strtab
  -0.0%      -4  [ = ]       0    TOTAL
use_config/stm32f1 — 62.5 KiB → 62.5 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  56472	     28	   7504	  64004	   fa04	rmk-stm32f1

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  56472	     28	   7504	  64004	   fa04	rmk-stm32f1

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +172  [ = ]       0    .debug_info
  +0.0%     +84  [ = ]       0    .debug_str
  +0.0%     +10  [ = ]       0    .debug_line
  +0.0%      +4  +0.0%      +4    .text
  +3.5%      +2  [ = ]       0    [Unmapped]
  -0.5%      -4  -0.6%      -4    .rodata
  +0.0%    +268  [ = ]       0    TOTAL
use_config/stm32h7 — 99.9 KiB → 99.9 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  92256	    268	   9736	 102260	  18f74	rmk-stm32h7

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  92252	    268	   9736	 102256	  18f70	rmk-stm32h7

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +319  [ = ]       0    .debug_info
  +0.0%    +316  [ = ]       0    .debug_str
   +59%     +24  [ = ]       0    [Unmapped]
  +0.1%     +12  +0.1%     +12    .rodata
  -0.0%      -8  -0.0%      -8    .text
  -0.1%    -147  [ = ]       0    .debug_line
  +0.0%    +516  +0.0%      +4    TOTAL
use_rust/nrf52832_ble — 359.5 KiB → 359.5 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 329488	   5264	  33368	 368120	  59df8	rmk-nrf52832

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 329472	   5264	  33368	 368104	  59de8	rmk-nrf52832

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +2.58Ki  [ = ]       0    .debug_info
  +0.2% +1.07Ki  [ = ]       0    .debug_loc
  +0.0%    +104  [ = ]       0    .debug_line
  +0.1%     +32  +0.1%     +32    .rodata
  -0.0%      -8  [ = ]       0    .debug_aranges
 -20.3%     -13  [ = ]       0    [Unmapped]
  -0.0%     -16  [ = ]       0    .debug_ranges
  -0.0%     -16  -0.0%     -16    .text
  -0.2%     -17  [ = ]       0    .debug_abbrev
  -0.0%     -20  [ = ]       0    .debug_frame
  -0.0%     -24  [ = ]       0    .strtab
  -0.0%     -32  [ = ]       0    .symtab
  -0.0%     -75  [ = ]       0    .debug_str
  +0.1% +3.56Ki  +0.0%     +16    TOTAL
use_rust/nrf52840_ble — 417.9 KiB → 417.9 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 376040	   5264	  46656	 427960	  687b8	rmk-nrf52840

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 376008	   5264	  46656	 427928	  68798	rmk-nrf52840

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +2.41Ki  [ = ]       0    .debug_info
  +0.1%    +986  [ = ]       0    .debug_loc
  +0.1%    +207  [ = ]       0    .debug_line
  +0.1%     +36  +0.1%     +36    .rodata
  +5.4%      +3  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  -0.0%      -8  [ = ]       0    .debug_aranges
  -0.0%     -16  [ = ]       0    .debug_ranges
  -0.0%     -20  [ = ]       0    .debug_frame
  -0.0%     -32  [ = ]       0    .symtab
  -0.0%    -187  [ = ]       0    .debug_str
  +0.0% +3.35Ki  +0.0%     +32    TOTAL
use_rust/nrf52840_ble_split (central) — 506.7 KiB → 506.7 KiB (+0.01% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 459584	   6588	  52728	 518900	  7eaf4	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 459528	   6588	  52728	 518844	  7eabc	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%     +36  +0.1%     +36    .rodata
  +0.0%     +20  +0.0%     +20    .text
   +31%     +13  [ = ]       0    [Unmapped]
  +0.0%      +8  [ = ]       0    .debug_ranges
  -0.0%      -5  [ = ]       0    .strtab
  -0.0%     -12  [ = ]       0    .debug_loc
  -0.4%     -38  [ = ]       0    .debug_abbrev
  -0.0%    -130  [ = ]       0    .debug_line
  -0.0%    -228  [ = ]       0    .debug_info
  -0.0%    -460  [ = ]       0    .debug_str
  -0.0%    -796  +0.0%     +56    TOTAL
use_rust/nrf52840_ble_split (peripheral) — 319.1 KiB → 319.1 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 295104	   5360	  26272	 326736	  4fc50	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 295116	   5360	  26272	 326748	  4fc5c	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +915  [ = ]       0    .debug_str
  +0.0%    +780  [ = ]       0    .debug_info
  +0.0%     +32  [ = ]       0    .debug_loc
   +23%     +12  [ = ]       0    [Unmapped]
  +0.0%      +5  [ = ]       0    .strtab
  -0.0%     -12  -0.0%     -12    .text
  +0.0% +1.69Ki  -0.0%     -12    TOTAL
use_rust/pi_pico_w_ble — 659.8 KiB → 659.8 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 619944	      0	  55716	 675660	  a4f4c	rmk-pi-pico-w

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 619912	      0	  55716	 675628	  a4f2c	rmk-pi-pico-w

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +465  [ = ]       0    .debug_info
  +0.0%    +422  [ = ]       0    .debug_str
  +0.0%     +32  +0.0%     +32    .rodata
  +0.0%     +14  [ = ]       0    .strtab
  +0.0%     +13  [ = ]       0    .debug_loc
  +0.0%     +12  [ = ]       0    .debug_line
  +4.7%      +2  [ = ]       0    [Unmapped]
  +0.0%    +960  +0.0%     +32    TOTAL
use_rust/rp2040 — 147.2 KiB → 147.2 KiB (+0.01% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 135448	      0	  15252	 150700	  24cac	rmk-rp2040

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 135432	      0	  15252	 150684	  24c9c	rmk-rp2040

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +443  [ = ]       0    .debug_info
  +0.0%    +209  [ = ]       0    .debug_str
   +37%     +15  [ = ]       0    [Unmapped]
  +0.1%     +12  +0.1%     +12    .rodata
  +0.0%     +10  [ = ]       0    .debug_loc
  +0.0%      +7  [ = ]       0    .debug_line
  +0.0%      +4  [ = ]       0    .strtab
  +0.0%      +4  +0.0%      +4    .text
  +0.0%    +704  +0.0%     +16    TOTAL
use_rust/rp2040_split (central) — 159.5 KiB → 159.5 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 147408	      0	  15964	 163372	  27e2c	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 147400	      0	  15964	 163364	  27e24	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +1.38Ki  [ = ]       0    .debug_str
  +0.0%    +368  [ = ]       0    .debug_info
  +0.1%     +96  [ = ]       0    .debug_line
  +0.0%     +51  [ = ]       0    .debug_loc
   +64%     +25  [ = ]       0    [Unmapped]
  +0.1%     +12  +0.1%     +12    .rodata
  +0.0%      +7  [ = ]       0    .strtab
  -0.0%      -4  -0.0%      -4    .text
  +0.1% +1.92Ki  +0.0%      +8    TOTAL
use_rust/rp2040_split (peripheral) — 27.8 KiB → 27.8 KiB (+0.01% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  25376	     60	   3028	  28464	   6f30	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  25372	     60	   3028	  28460	   6f2c	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%      +4  +0.1%      +4    .rodata
  -0.0%      -4  [ = ]       0    .strtab
  -6.9%      -4  [ = ]       0    [Unmapped]
  -0.0%      -4  +0.0%      +4    TOTAL
use_rust/stm32f1 — 62.5 KiB → 62.5 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  56520	     28	   7480	  64028	   fa1c	rmk-stm32f1

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  56524	     28	   7480	  64032	   fa20	rmk-stm32f1

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +213  [ = ]       0    .debug_info
   +15%      +6  [ = ]       0    [Unmapped]
  -0.6%      -4  -0.6%      -4    .rodata
  -0.0%      -9  [ = ]       0    .debug_line
  -0.0%    -282  [ = ]       0    .debug_str
  -0.0%     -76  -0.0%      -4    TOTAL
use_rust/stm32h7 — 121.1 KiB → 121.1 KiB (+0.01% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 108184	    324	  15524	 124032	  1e480	rmk-stm32h7

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 108168	    324	  15524	 124016	  1e470	rmk-stm32h7

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +133  [ = ]       0    .debug_line
  +0.0%    +103  [ = ]       0    .debug_info
  +0.0%     +98  [ = ]       0    .debug_str
  +0.2%     +12  +0.2%     +12    .rodata
  +0.0%      +4  +0.0%      +4    .text
  +0.0%      +1  [ = ]       0    .strtab
 -21.4%     -15  [ = ]       0    [Unmapped]
  +0.0%    +336  +0.0%     +16    TOTAL

@jpds jpds force-pushed the feat/usb-serial-version-stamp branch 3 times, most recently from 6af3e38 to 7306942 Compare May 27, 2026 16:02
@HaoboGu

HaoboGu commented May 28, 2026

Copy link
Copy Markdown
Owner

iirc Vial needs vial:f64c2b3c to work, could you double check whether it works on both web and Vial app?

@jpds jpds force-pushed the feat/usb-serial-version-stamp branch from 7306942 to 4974e8b Compare May 28, 2026 09:29
jpds added 4 commits May 28, 2026 10:38
`DeviceConfig::default()` now sets `serial_number` to `RMK_BUILD_INFO` instead
of the static string `"vial:f64c2b3c:000001"`. For Vial builds (the default),
`RMK_BUILD_INFO` is `rmk:<version>-<git-hash>;vial:f64c2b3c`, which lets Vial
discover the keyboard. Non-Vial builds get `rmk:<version>-<git-hash>`.

- `build.rs`: extract `get_git_hash()` helper, emit `RMK_GIT_HASH` env var
- `config/device.rs`: add `pub const RMK_BUILD_INFO`, cfg-gated to include
  `";vial:f64c2b3c"` for Vial builds; use as default `serial_number`
- `config/mod.rs`: re-export `RMK_BUILD_INFO` as `rmk::config::RMK_BUILD_INFO`

Downstream firmware can extend the stamp with their own build info:
  `const_format::concatcp!(rmk::config::RMK_BUILD_INFO, ";my-fw:", ...)`
…ult()`

All `use_rust` examples had `serial_number: "vial:f64c2b3c:000001"` set
explicitly. `DeviceConfig::default()` now stamps `serial_number` with
`RMK_BUILD_INFO` (`rmk:<version>-<git-hash>;vial:f64c2b3c` for Vial builds),
so the field is redundant. Remove it from all 16 examples.
…` path

When `serial_number` is absent from `keyboard.toml`, `Identity` resolves to
`None` and the macro codegen emits `::rmk::config::RMK_BUILD_INFO`. This gives
`use_config` keyboards the same version-stamped serial as `use_rust` keyboards.
For Vial builds (the default) that includes the `;vial:f64c2b3c` suffix. An
explicit `serial_number` in `keyboard.toml` is still emitted verbatim.
`keyboard_device.mdx` covers the default `RMK_BUILD_INFO` serial stamp, the
`;vial:f64c2b3c` suffix in Vial builds, and how downstream firmware can extend
the stamp via `concatcp!` or a custom `build.rs` env var.
@jpds jpds force-pushed the feat/usb-serial-version-stamp branch from 4974e8b to 25f27ca Compare May 28, 2026 09:38
@jpds

jpds commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

@HaoboGu I had only checked the web UI which worked fine. Adjusted now.

<Tab label={<Rust />}>

```rust title="main.rs"
use const_format::concatcp;

@HaoboGu HaoboGu May 28, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This introduces extra dependency, I think it's unnecessary?


To make your keyboard to be recognized by Vial, the `serial_number` shall start with `vial:f64c2b3c:`
If `serial_number` is omitted, RMK embeds a version stamp automatically. For Vial builds (the
default), this is `rmk:<version>-<git-hash>;vial:f64c2b3c`, which lets Vial discover the

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I prefer to have vial:f64c2b3c at the beginning(or because it might be dropped in BLE. There's length limitation in BLE's serial.

Comment thread rmk/src/config/device.rs
#[cfg(feature = "vial")]
pub const RMK_BUILD_INFO: &str = concat!(
"rmk:",
env!("CARGO_PKG_VERSION"),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

There are several thoughts about the BUILD_INFO, I think it can be improved to cover:

  1. When using RMK version from git or local path, the CARGO_PKG_VERSION will point to the version in Cargo.toml of used RMK, which is not accurate.
  2. When the workspace is dirty(for example, using a local RMK with edits), the RMK_GIT_HASH is not accurate too.
  3. When using crates.io version, CARGO_PKG_VERSION and RMK_GIT_HASH are always fixed -- that means we can remove either of them.

Comment thread rmk/build.rs
common::set_target_cfgs(&mut cfgs);

println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=.git/HEAD");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This means ALWAYS rebuild RMK in user space -- which is not correct. This is because that there's no .git/HEAD under rmk folder.

And I don't think use this to monitoring commit changes is correct, .git/HEAD won't change when committing code.

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