const__pageData=JSON.parse('{"title":"Squeezing the most out of AVR","description":"","frontmatter":{},"headers":[],"relativePath":"squeezing_avr.md","filePath":"squeezing_avr.md","lastUpdated":null}');
const_hoisted_1=/* @__PURE__ */createStaticVNode('<h1id="squeezing-the-most-out-of-avr"tabindex="-1">SqueezingthemostoutofAVR<aclass="header-anchor"href="#squeezing-the-most-out-of-avr"aria-label="Permalink to "Squeezing the most out of AVR""></a></h1><p>AVRisseverelyresource-constrained,andasQMKcontinuestogrow,itisapproachingapointwheresupportforAVRmayneedtobemovedtolegacystatusasnewerdevelopmentisunabletofitintothoseconstraints.</p><p>However,ifyouneedtoreducethecompiledsizeofyourfirmwaretofitthecontroller'slimitedflashsize,thereareanumberofoptionstodoso.</p><h2id="rules-mk-settings"tabindex="-1"><code>rules.mk</code>Settings<aclass="header-anchor"href="#rules-mk-settings"aria-label="Permalinkto"`rules.mk`Settings""></a></h2><p>Firstandforemostisenablinglinktimeoptimization.Todoso,addthistoyourrules.mk:</p><divclass="language-makevp-adaptive-theme"><buttontitle="CopyCode"class="copy"></button><spanclass="lang">make</span><preclass="shikishiki-themesgithub-lightgithub-darkvp-code"><code><spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">LTO_ENABLE=yes</span></span></code></pre></div><p>Thiswillcausethefinalsteptotakelonger,butshouldgetyouasmallercompiledsize.ThisalsodisablesActionFunctions,andActionMacros,bothofwhicharedeprecated.Thiswillgetyouthemostsavings,inmostsituations.</p><p>Fromthere,disablingextraneoussystemswillhelp--e.g.:</p><divclass="language-makevp-adaptive-theme"><buttontitle="CopyCode"class="copy"></button><spanclass="lang">make</span><preclass="shikishiki-themesgithub-lightgithub-darkvp-code"><code><spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CONSOLE_ENABLE=no</span></span>\n<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMMAND_ENABLE=no</span></span>\n<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">MOUSEKEY_ENABLE=no</span></span>\n<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">EXTRAKEY_ENABLE=no</span></span></code></pre></div><p>Thisdisablessomeofthefunctionalitythatyoumaynotneed.Butnotethatextrakeysdisablesstufflikethemediakeysandsystemvolumecontrol.</p><p>Ifthatisn'tenoughtogetyourfirmwaredowntosize,thentherearesomeadditionalfeaturesthatyoucandisable:</p><divclass="language-makevp-adaptive-theme"><buttontitle="CopyCode"class="copy"></button><spanclass="lang">make</span><preclass="shikishiki-themesgithub-lightgithub-darkvp-code"><code><spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SPACE_CADET_ENABLE=no</span></span>\n<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">GRAVE_ESC_ENABLE=no</span></span>\n<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">MAGIC_ENABLE=no</span></span></code></pre></div><p>Thesefeaturesareenabledbydefault,buttheymaynotbeneeded.Doublechecktomakesure.The<ahref="./keycodes_magic">MagicKeycodes</a>arethelargestandcontrolthingslikeNKROtoggling,GUIandALT/CTRLswapping,etc.Disablingthemwilldisablethosefunctions.See<ahref="#magic-functions">MagicFunctions</a>fordisablingrelatedfunctions.</p><p>Ifyouuse<code>sprintf</code>or<code>snprintf</code>functionsyoucansavearound~400Bytesbyenablingthisoption.</p><divclass="language-makevp-adaptive-theme"><buttontitle="CopyCode"class="copy"></button><spanclass="lang">make</span><preclass="shikishiki-themesgithub-lightgithub-darkvp-code"><code><spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">AVR_USE_MINIMAL_PRINTF=yes</span></span></code></pre></div><p>ThiswillincludesmallerimplementationsfromAVRslibcintoyourFirmware.Theyare<ahref="https://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html#gaa3b98c0d17b35642c0f3e464909