<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span></code></pre></div><p>If there are settings here already, then just add everything between the first and last curly brackets and separate the existing settings with a comma from the newly added ones.</p></li></ol><divclass="tip custom-block"><pclass="custom-block-title">TIP</p><p>If you installed MSYS2 to a different folder, then you'll need to change the path for <code>terminal.integrated.shell.windows</code> to the correct path for your system.</p></div><olstart="4"><li><p>Hit Ctrl-<code>`</code> (Grave) to bring up the terminal or go to <kbd><kbd>View</kbd>><kbd>Terminal</kbd></kbd> (command <code>workbench.action.terminal.toggleTerminal</code>). A new terminal will be opened if there isn‘t one already.</p><p>This should start the terminal in the workspace's folder (so the <code>qmk_firmware</code> folder), and then you can compile your keyboard.</p></li></ol><h2id="every-other-operating-system"tabindex="-1">Every other Operating System <aclass="header-anchor"href="#every-other-operating-system"aria-label="Permalink to "Every other Operating System""></a></h2><ol><li>Head to <ahref="https://code.visualstudio.com/"target="_blank"rel="noreferrer">VS Code</a> and download the installer</li><li>Run the installer</li><li>That's it</li></ol><p>No, really, that's it. The paths needed are already included when installing the packages, and it is much better about detecting the current workspace files and parsing them for IntelliSense.</p><h2id="extensions"tabindex="-1">Extensions <aclass="header-anchor"href="#extensions"aria-label="Permalink to "Extensions""></a></h2><p>There are a number of extensions that you may want to install:</p><ul><li><ahref="https://marketplace.visualstudio.com/items?itemName=donjayamanne.git-extension-pack"target="_blank"rel="noreferrer">Git Extension Pack</a> - This installs a bunch of Git related tools that may make using Git with QMK Firmware easier.</li><li><ahref="https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd"target="_blank"rel="noreferrer">clangd</a> - <em>[Optional]</em> - This is the language server for C/C++ that VS Code uses. It provides IntelliSense and other features.</li><li><ahref="https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig"target="_blank"rel="noreferrer">EditorConfig for VS Code</a> - <em>[Optional]</em> - Helps to keep the code to the QMK Coding Conventions.</li><li><ahref="https://marketplace.visualstudio.com/items?itemName=bierner.github-markdown-preview"target="_blank"rel="noreferrer">GitHub Markdown Preview</a> - <em>[Optional]</em> - Makes the markdown preview in VS Code more like GitHub's.</li><li><ahref="https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare"target="_blank"rel="noreferrer">VS Live Share Extension Pack</a> - <em>[Optional]</em> - This extension allows somebody else to access your workspace (or you to access somebody else's workspace) and help out. This is great if you're having issues and need some help from somebody.</li></ul><p>Restart once you've installed any extensions.</p><h1id="configure-vs-code-for-qmk"tabindex="-1">Configure VS Code for QMK <aclass="header-anchor"href="#configure-vs-code-for-qmk"aria-label="Permalink to "Configure VS Code for QMK""></a></h1><ol><li>Click <kbd><kbd>File</kbd>><kbd>Open Folder</kbd></kbd></li><li>Open the QMK Firmware folder that you cloned from GitHub.</li><li>Click <kbd><kbd>File</kbd>><kbd>Save Workspace As...</kbd></kbd></li></ol><h2id="configuring-vs-code"tabindex="-1">Configuring VS Code <aclass="header-anchor"href="#configuring-vs-code"aria-label="Permalink to "Configuring VS Code""></a></h2><p>Using the <ahref="https://clang.llvm.org/docs/JSONCompilationDatabase.html"target="_blank"rel="noreferrer">standard <code>compile_commands.json</code> database</a>, we can get the VS code
<spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Use IntelliSense to learn about possible attributes.</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Hover to view descriptions of existing attributes.</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387</span></span>
<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>You'll need to perform some modifications to the file above in order to target your specific device:</p><ul><li><code>"name"</code>: Can be anything, but if you're debugging multiple targets you'll want something descriptive here.</li><li><code>"cwd"</code>: The path to the QMK Firmware repository root directory -- <em>if using the <code>.vscode</code> directory existing in the <code>qmk_firmware</code> git repository, the default above should be correct</em></li><li><code>"executable"</code>: The path to the <code>elf</code> file generated as part of the build for your keyboard -- <em>exists in <code><qmk_firmware>/.build</code></em></li><li><code>"BMPGDBSerialPort"</code>: The <code>COM</code> port under Windows, or the <code>/dev/...</code> path for Linux/macOS. Two serial port devices will be created -- the Black Magic Probe debug port is <em>usually</em> the first. If it doesn't work, try the second.</li><li><code>"svdFile"</code>: <em>[Optional]</em> The path to the SVD file that defines the register layout for the MCU -- the appropriate file can be downloaded from the <ahref="https://github.com/posborne/cmsis-svd/tree/master/data/STMicro"target="_blank"rel="noreferrer">cmsis-svd repository</a></li><li><code>"device"</code>: The name of the MCU, which matches the <code><name></code> tag at the top of the downloaded <code>svd</code> file.</li><li><code>"armToolchainPath"</code>: <em>[Optional]</em> The path to the ARM toolchain installation location on Windows -- under normal circumstances Linux/macOS will auto-detect this correctly and will not need to be specified.</li></ul><divclass="warning custom-block"><pclass="custom-block-title">WARNING</p><p>Windows builds of QMK Firmware are generally compiled using QMK MSYS, and the path to gdb's location (<code>C:\\QMK_MSYS\\mingw64\\bin</code>) needs to be specified under <code>armToolchainPath</code> for it to be detected. You may also need to change the GDB path to point at <code>C:\\QMK_MSYS\\mingw64\\bin\\gdb-multiarch.exe</code> in the VSCode Cortex-Debug user settings: <imgsrc="https://i.imgur.com/EGrPM1L.png"alt="VSCode Settings"></p></div><p>The following modifications must be made to the keyboard's <code>rules.mk</code> file to enable debug information and disable optimisations -- this will ensure breakpoints and variable viewing works correctly:</p><divclass="language-makefile vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">makefile</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Enable debug information in the final binaries</span></span>
<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">OPT = g</span></span></code></pre></div><p>At this point, you should build and flash your firmware through normal methods (<code>qmk compile ...</code> and <code>qmk flash ...</code>).</p><p>Once completed, you can:</p><ul><li>Switch to the debug view in VS Code (in the sidebar, the Play button with a bug next to it)</li><li>Select the newly-created debug target in the dropdown at the top of the sidebar</li><li>Click the green play button next to the dropdown</li></ul><p>VS Code's debugger will then start executing the compiled firmware on the MCU.</p><p>At this stage, you should have full debugging set up, with breakpoints and variable listings working!</p></div></div></main><footerclass="VPDocFooter"data-v-39a288b8data-v-09de1c0f><!--[--><!--]--><divclass="edit-info"data-v-09de1c0f><divclass="edit-link"data-v-09de1c0f><aclass="VPLink link vp-external-link-icon no-icon edit-link-button"href="https://github.com/qmk/qmk_firmware/edit/master/docs/other_vscode.md"target="_blank"rel="noreferrer"data-v-09de1c0f><!--[--><spanclass="vpi-square-pen edit-link-icon"data-v-09de1c0f></span> Edit this page<!--]--></a></div><!----></div><navclass="prev-next"data-v-09de1c0f><divclass="pager"data-v-09de1c0f><aclass="VPLink link pager-link prev"href="/other_eclipse"data-v-09de1c0f><!--[--><spanclass="desc"data-v-09de1c0f>Previous page</span><spanclass="title"data-v-09de1c0f>Using Eclipse with QMK</span><!--]--></a></div><divclass="pager"data-v-09de1c0f><aclass="VPLink link pager-link next"href="/newbs_git_best_practices"data-v-09de1c0f><!--[--><spanclass="desc"data-v-09de1c0f>Next page</span><spanclass="title"data-v-09de1c0f>Introduction</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>