[{"data":1,"prerenderedAt":1428},["ShallowReactive",2],{"wiki-page-/en-us/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux":3,"wiki-doc-items-/en-us/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux":1394,"language-switcher-data-/en-us/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux":1412,"wiki-i18n-paths-/en-us/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux":1427},{"id":4,"title":5,"body":6,"canonicalPath":1375,"chapter":1376,"chapterSort":1377,"date":1378,"description":48,"docI18nKey":1379,"docKey":1380,"docRoot":1381,"docTitle":1382,"extension":1383,"i18nKey":1384,"isBlogPost":1385,"isWikiDoc":784,"isWikiIndex":1385,"layout":1386,"legacyPath":1386,"locale":1387,"localeSlug":1388,"meta":1389,"navigation":784,"path":1375,"seo":1390,"sourcePath":1391,"sourceStem":1384,"stem":1392,"wikiDepth":105,"__hash__":1393},"content/_i18n/en-us/wiki/2026-04-17-STM32CubeIDE-VScode环境搭建/ch3-Linux.md","Linux",{"type":7,"value":8,"toc":1370},"minimark",[9,14,18,31,34,38,43,50,53,61,67,72,77,80,85,93,124,129,132,137,143,157,162,165,170,177,182,185,190,193,198,201,206,209,218,221,341,344,349,354,358,364,369,372,375,380,391,400,403,422,427,430,439,444,447,453,456,461,464,469,472,477,484,489,497,502,505,510,513,518,522,526,529,534,537,542,545,550,555,558,563,568,571,576,581,584,587,592,597,601,604,609,621,628,633,636,641,644,649,652,657,660,665,668,673,677,688,704,715,720,742,747,750,916,919,1003,1013,1042,1045,1050,1053,1058,1083,1086,1091,1095,1101,1104,1107,1112,1117,1120,1125,1129,1132,1137,1140,1147,1158,1329,1332,1336,1339,1344,1347,1352,1358,1361,1366],[10,11,13],"h3",{"id":12},"environment-introduction","Environment Introduction",[15,16,17],"p",{},"This tutorial covers the environment setup:",[19,20,21,25,28],"ol",{},[22,23,24],"li",{},"System: Fedora 43 KDE Edition Linux",[22,26,27],{},"System kernel: Linux 6.19.12-200.fc43.x86_64",[22,29,30],{},"Architecture: X86_64 (amd64)",[15,32,33],{},"Other Linux environments are also acceptable.",[10,35,37],{"id":36},"install-various-software-and-environments","Install various software and environments",[39,40,42],"h4",{"id":41},"install-cubemx","Install CubeMX",[15,44,45],{},[46,47],"img",{"alt":48,"src":49},"","https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image9.webp",[15,51,52],{},"Download link:",[15,54,55],{},[56,57,58],"a",{"href":58,"rel":59},"https://www.st.com.cn/zh/development-tools/stm32cubemx.html",[60],"nofollow",[15,62,63],{},[64,65,66],"strong",{},"It is recommended to download version 6.14.1 (do not download version 6.15.0, as this version has a bug, and it is unclear when it will be fixed).",[15,68,69],{},[46,70],{"alt":48,"src":71},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image10.webp",[15,73,74],{},[46,75],{"alt":48,"src":76},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image11.webp",[15,78,79],{},"Decompress it.",[15,81,82],{},[46,83],{"alt":48,"src":84},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image12.webp",[15,86,87,88,92],{},"Open this software with root privileges ",[89,90,91],"code",{},"SetupSTM32CubeMX-6.15.0",".",[94,95,99],"pre",{"className":96,"code":97,"language":98,"meta":48,"style":48},"language-cpp shiki shiki-themes github-light github-dark","sudo ./SetupSTM32CubeMX-6.15.0\n","cpp",[89,100,101],{"__ignoreMap":48},[102,103,106,110,114,117,120],"span",{"class":104,"line":105},"line",1,[102,107,109],{"class":108},"sVt8B","sudo .",[102,111,113],{"class":112},"szBVR","/",[102,115,116],{"class":108},"SetupSTM32CubeMX",[102,118,119],{"class":112},"-",[102,121,123],{"class":122},"s7hpK","6.15.0\n",[15,125,126],{},[46,127],{"alt":48,"src":128},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image13.webp",[15,130,131],{},"In the newly popped-up window, just keep clicking Next until the installation finishes. When it looks like the image below, the installation is successful.",[15,133,134],{},[46,135],{"alt":48,"src":136},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image14.webp",[15,138,139,142],{},[89,140,141],{},"/usr/local/STMicroelectronics/STM32Cube/STM32CubeMX"," Enter this folder, then open a terminal and type",[94,144,146],{"className":96,"code":145,"language":98,"meta":48,"style":48},"./STM32CubeMX\n",[89,147,148],{"__ignoreMap":48},[102,149,150,152,154],{"class":104,"line":105},[102,151,92],{"class":108},[102,153,113],{"class":112},[102,155,156],{"class":108},"STM32CubeMX\n",[15,158,159],{},[46,160],{"alt":48,"src":161},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image15.webp",[15,163,164],{},"Click Help",[15,166,167],{},[46,168],{"alt":48,"src":169},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image16.webp",[15,171,172,173,176],{},"Select ",[89,174,175],{},"Manage embedded software packages",", and check the first and latest firmware for STM32F1, F4, and H7.",[15,178,179],{},[46,180],{"alt":48,"src":181},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image17.webp",[15,183,184],{},"Click install.",[15,186,187],{},[46,188],{"alt":48,"src":189},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image18.webp",[15,191,192],{},"Logged into the account.",[15,194,195],{},[46,196],{"alt":48,"src":197},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image19.webp",[15,199,200],{},"Then wait for the download and installation to finish.",[15,202,203],{},[46,204],{"alt":48,"src":205},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image20.webp",[15,207,208],{},"Just download it.",[15,210,211,212,217],{},"Next, you can configure a desktop shortcut for CubeMX application for quick access. For detailed instructions, refer to the Appimage section of the ",[56,213,216],{"href":214,"rel":215},"https://sdutvincirobot.feishu.cn/wiki/GIKnwJo39iREkHkFGvqcy5Osntc",[60],"Vinci Robotics Team Linux Beginner Tutorial",". You can use Ctrl+F to quickly locate that section.",[15,219,220],{},"The desktop shortcut is as follows:",[94,222,226],{"className":223,"code":224,"language":225,"meta":48,"style":48},"language-bash shiki shiki-themes github-light github-dark","[Desktop Entry]\nName=STM32CubeMX\nExec=/usr/local/STMicroelectronics/STM32Cube/STM32CubeMX/STM32CubeMX\nIcon=/usr/local/STMicroelectronics/STM32Cube/STM32CubeMX/help/STM32CubeMX.png\nType=Application\nCategories=Development;Electronics;Embedded;\nComment=STM32CubeMX configuration and code generation tool\nTerminal=false\n","bash",[89,227,228,233,245,256,267,278,304,330],{"__ignoreMap":48},[102,229,230],{"class":104,"line":105},[102,231,232],{"class":108},"[Desktop Entry]\n",[102,234,236,239,242],{"class":104,"line":235},2,[102,237,238],{"class":108},"Name",[102,240,241],{"class":112},"=",[102,243,156],{"class":244},"sZZnC",[102,246,248,251,253],{"class":104,"line":247},3,[102,249,250],{"class":108},"Exec",[102,252,241],{"class":112},[102,254,255],{"class":244},"/usr/local/STMicroelectronics/STM32Cube/STM32CubeMX/STM32CubeMX\n",[102,257,259,262,264],{"class":104,"line":258},4,[102,260,261],{"class":108},"Icon",[102,263,241],{"class":112},[102,265,266],{"class":244},"/usr/local/STMicroelectronics/STM32Cube/STM32CubeMX/help/STM32CubeMX.png\n",[102,268,270,273,275],{"class":104,"line":269},5,[102,271,272],{"class":108},"Type",[102,274,241],{"class":112},[102,276,277],{"class":244},"Application\n",[102,279,281,284,286,289,292,296,298,301],{"class":104,"line":280},6,[102,282,283],{"class":108},"Categories",[102,285,241],{"class":112},[102,287,288],{"class":244},"Development",[102,290,291],{"class":108},";",[102,293,295],{"class":294},"sScJk","Electronics",[102,297,291],{"class":108},[102,299,300],{"class":294},"Embedded",[102,302,303],{"class":108},";\n",[102,305,307,310,312,315,318,321,324,327],{"class":104,"line":306},7,[102,308,309],{"class":108},"Comment",[102,311,241],{"class":112},[102,313,314],{"class":244},"STM32CubeMX",[102,316,317],{"class":294}," configuration",[102,319,320],{"class":244}," and",[102,322,323],{"class":244}," code",[102,325,326],{"class":244}," generation",[102,328,329],{"class":244}," tool\n",[102,331,333,336,338],{"class":104,"line":332},8,[102,334,335],{"class":108},"Terminal",[102,337,241],{"class":112},[102,339,340],{"class":244},"false\n",[15,342,343],{},"Just follow the tutorial, and you'll be able to achieve this effect.",[15,345,346],{},[46,347],{"alt":48,"src":348},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image21.webp",[15,350,351],{},[46,352],{"alt":48,"src":353},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image22.webp",[39,355,357],{"id":356},"install-vscode","Install VSCode",[15,359,360],{},[56,361,362],{"href":362,"rel":363},"https://code.visualstudio.com/Download",[60],[15,365,366],{},[46,367],{"alt":48,"src":368},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image23.webp",[15,370,371],{},"If it's a Debian-based system, download the .deb; if it's an RHEL-based system, download the .rpm.",[15,373,374],{},"After downloading, open your browser, locate the folder containing this installation package, and open a terminal in that path.",[15,376,377],{},[46,378],{"alt":48,"src":379},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image24.webp",[15,381,382,383,386,387,390],{},"Debian-based: Enter ",[89,384,385],{},"sudo apt install ./code"," then press the ",[89,388,389],{},"tab"," key to autocomplete the filename, then press Enter.",[15,392,393,394,397,398,390],{},"RHEL series: Enter ",[89,395,396],{},"sudo dnf install ./code"," and then press the ",[89,399,389],{},[15,401,402],{},"For example, after completion:",[94,404,406],{"className":223,"code":405,"language":225,"meta":48,"style":48},"sudo dnf install ./code-1.102.1-1752598767.el8.x86_64.rpm\n",[89,407,408],{"__ignoreMap":48},[102,409,410,413,416,419],{"class":104,"line":105},[102,411,412],{"class":294},"sudo",[102,414,415],{"class":244}," dnf",[102,417,418],{"class":244}," install",[102,420,421],{"class":244}," ./code-1.102.1-1752598767.el8.x86_64.rpm\n",[15,423,424],{},[46,425],{"alt":48,"src":426},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image25.webp",[15,428,429],{},"Then open VSCode and enter the following command in the terminal:",[94,431,433],{"className":223,"code":432,"language":225,"meta":48,"style":48},"code\n",[89,434,435],{"__ignoreMap":48},[102,436,437],{"class":104,"line":105},[102,438,432],{"class":294},[15,440,441],{},[46,442],{"alt":48,"src":443},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image26.webp",[15,445,446],{},"Then you can configure a separate environment for the CubeIDE plugin to use, avoiding conflicts with the default environment.",[15,448,449],{},[46,450],{"alt":451,"src":452},"alt text","https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776420070033.webp",[15,454,455],{},"Make some settings; just follow my lead.",[15,457,458],{},[46,459],{"alt":451,"src":460},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776420416232.webp",[15,462,463],{},"Select STM32",[15,465,466],{},[46,467],{"alt":451,"src":468},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776420490177.webp",[15,470,471],{},"Then install some plugins.",[15,473,474],{},[46,475],{"alt":48,"src":476},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image27.webp",[15,478,479,480,483],{},"Find the installation of the ",[89,481,482],{},"STM32CubeIDE for Visual Studio Code"," plugin below.",[15,485,486],{},[46,487],{"alt":451,"src":488},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776420601935.webp",[15,490,491,492,496],{},"On the right, this prompt appears asking you to select and install (requires a reliable ",[493,494,495],"em",{},"scientific network",").",[15,498,499],{},[46,500],{"alt":451,"src":501},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776420688705.webp",[15,503,504],{},"Next, some environment installations will be performed.",[15,506,507],{},[46,508],{"alt":451,"src":509},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776420710467.webp",[15,511,512],{},"You can also install some other plugins, such as Codex and others.\nThese are up to you.",[15,514,515],{},[46,516],{"alt":451,"src":517},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776420944068.webp",[10,519,521],{"id":520},"project-creation-and-testing","Project Creation and Testing",[39,523,525],{"id":524},"create-a-project-using-cubemx","Create a project using CubeMX",[15,527,528],{},"Click the button to select a microcontroller.",[15,530,531],{},[46,532],{"alt":48,"src":533},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image60.webp",[15,535,536],{},"Search for the corresponding chip, and double-click the chip option.",[15,538,539],{},[46,540],{"alt":48,"src":541},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image61.webp",[15,543,544],{},"Perform some configuration. The following are all very basic things that you definitely already know before watching this video.",[15,546,547],{},[46,548],{"alt":48,"src":549},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image62.webp",[15,551,552],{},[46,553],{"alt":48,"src":554},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image63.webp",[15,556,557],{},"Open any IO for testing, such as the LED's GPIO.",[15,559,560],{},[46,561],{"alt":48,"src":562},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image64.webp",[15,564,565],{},[46,566],{"alt":48,"src":567},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image65.webp",[15,569,570],{},"FreeRTOS also needs to be configured.",[15,572,573],{},[46,574],{"alt":48,"src":575},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image66.webp",[15,577,578],{},[46,579],{"alt":48,"src":580},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image67.webp",[15,582,583],{},"These folders also need to be configured properly. Finally, select CMake for Toolchain and choose GCC for the compiler (it's normal not to have the compiler selection option in version 6.14.1 and earlier).",[15,585,586],{},"(However, CubeMX 6.15.0 has a bug — selecting the GCC compiler here doesn't actually work, and you'll need to manually select the compiler later. This bug may be fixed in a future release.)",[15,588,589],{},[46,590],{"alt":48,"src":591},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image68.webp",[15,593,594],{},[46,595],{"alt":48,"src":596},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image69.webp",[39,598,600],{"id":599},"configure-and-compile-the-project","Configure and compile the project.",[15,602,603],{},"Open a terminal in the project folder.",[15,605,606],{},[46,607],{"alt":451,"src":608},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776421629435.webp",[94,610,612],{"className":223,"code":611,"language":225,"meta":48,"style":48},"code .\n",[89,613,614],{"__ignoreMap":48},[102,615,616,618],{"class":104,"line":105},[102,617,89],{"class":294},[102,619,620],{"class":244}," .\n",[15,622,623,624,627],{},"After opening VSCode, remember to switch to the ",[89,625,626],{},"STM32"," configuration.",[15,629,630],{},[46,631],{"alt":451,"src":632},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776421689049.webp",[15,634,635],{},"Select Yes here to configure the CMake preset.",[15,637,638],{},[46,639],{"alt":451,"src":640},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776421794873.webp",[15,642,643],{},"Generally, choose Debug.",[15,645,646],{},[46,647],{"alt":451,"src":648},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776421850499.webp",[15,650,651],{},"Find a C language code file to open, and a prompt will appear in the bottom right corner suggesting you install a C/C++ plugin. You can choose to install it or not — it does provide code suggestions, but its code suggestion capabilities are far weaker compared to the built-in clangd. If you're a beginner and don't know how to configure code suggestions, I recommend following my steps below and simply not installing this plugin.",[15,653,654],{},[46,655],{"alt":451,"src":656},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776422028364.webp",[15,658,659],{},"You can test the code suggestions to see how powerful they are.",[15,661,662],{},[46,663],{"alt":451,"src":664},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776422393367.webp",[15,666,667],{},"For compilation, either of these two \"build\" options in the image will work.",[15,669,670],{},[46,671],{"alt":451,"src":672},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776423543189.webp",[39,674,676],{"id":675},"porting-author-tungchiahuis-standard-cc-project-template","Porting author tungchiahui's standard C/C++ project template",[15,678,679,680,683,684],{},"Use the ",[89,681,682],{},"git clone"," command to clone the repository: ",[56,685,686],{"href":686,"rel":687},"https://github.com/tungchiahui/STM32HAL_CMake_CPP_Template",[60],[94,689,691],{"className":223,"code":690,"language":225,"meta":48,"style":48},"git clone https://github.com/tungchiahui/STM32HAL_CMake_CPP_Template.git\n",[89,692,693],{"__ignoreMap":48},[102,694,695,698,701],{"class":104,"line":105},[102,696,697],{"class":294},"git",[102,699,700],{"class":244}," clone",[102,702,703],{"class":244}," https://github.com/tungchiahui/STM32HAL_CMake_CPP_Template.git\n",[15,705,706,707,714],{},"Copy ",[64,708,709,710,713],{},"all files and folders (except ",[89,711,712],{},".git",")"," from the repository into our STM32 project directory.",[15,716,717],{},[46,718],{"alt":451,"src":719},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776427498924.webp",[15,721,722,723,726,727,730,731,734,735,730,738,741],{},"Then open the ",[89,724,725],{},"applications"," folder, and create ",[89,728,729],{},"led_task.cpp"," and ",[89,732,733],{},"led_task.h"," in the ",[89,736,737],{},"Src",[89,739,740],{},"Inc"," folders respectively, with the following contents:",[15,743,744],{},[46,745],{"alt":48,"src":746},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image91.webp",[15,748,749],{},"led_task.cpp:",[94,751,753],{"className":96,"code":752,"language":98,"meta":48,"style":48},"#include \"led_task.h\"\n#include \"cmsis_os.h\"\n#include \"stm32f1xx_hal.h\" \n\nGPIO_PinState pinstate = GPIO_PIN_RESET;\n\nextern \"C\"\nvoid StartDefaultTask(void *argument)\n{\n  for(;;)\n  {\n    HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,pinstate);\n    pinstate = (pinstate == GPIO_PIN_RESET) ? GPIO_PIN_SET : GPIO_PIN_RESET;\n    osDelay(500);\n  }\n}\n",[89,754,755,763,770,780,786,796,800,808,831,837,846,852,861,889,904,910],{"__ignoreMap":48},[102,756,757,760],{"class":104,"line":105},[102,758,759],{"class":112},"#include",[102,761,762],{"class":244}," \"led_task.h\"\n",[102,764,765,767],{"class":104,"line":235},[102,766,759],{"class":112},[102,768,769],{"class":244}," \"cmsis_os.h\"\n",[102,771,772,774,777],{"class":104,"line":247},[102,773,759],{"class":112},[102,775,776],{"class":244}," \"stm32f1xx_hal.h\"",[102,778,779],{"class":108}," \n",[102,781,782],{"class":104,"line":258},[102,783,785],{"emptyLinePlaceholder":784},true,"\n",[102,787,788,791,793],{"class":104,"line":269},[102,789,790],{"class":108},"GPIO_PinState pinstate ",[102,792,241],{"class":112},[102,794,795],{"class":108}," GPIO_PIN_RESET;\n",[102,797,798],{"class":104,"line":280},[102,799,785],{"emptyLinePlaceholder":784},[102,801,802,805],{"class":104,"line":306},[102,803,804],{"class":112},"extern",[102,806,807],{"class":244}," \"C\"\n",[102,809,810,813,816,819,821,824,828],{"class":104,"line":332},[102,811,812],{"class":112},"void",[102,814,815],{"class":294}," StartDefaultTask",[102,817,818],{"class":108},"(",[102,820,812],{"class":112},[102,822,823],{"class":112}," *",[102,825,827],{"class":826},"s4XuR","argument",[102,829,830],{"class":108},")\n",[102,832,834],{"class":104,"line":833},9,[102,835,836],{"class":108},"{\n",[102,838,840,843],{"class":104,"line":839},10,[102,841,842],{"class":112},"  for",[102,844,845],{"class":108},"(;;)\n",[102,847,849],{"class":104,"line":848},11,[102,850,851],{"class":108},"  {\n",[102,853,855,858],{"class":104,"line":854},12,[102,856,857],{"class":294},"    HAL_GPIO_WritePin",[102,859,860],{"class":108},"(GPIOC,GPIO_PIN_13,pinstate);\n",[102,862,864,867,869,872,875,878,881,884,887],{"class":104,"line":863},13,[102,865,866],{"class":108},"    pinstate ",[102,868,241],{"class":112},[102,870,871],{"class":108}," (pinstate ",[102,873,874],{"class":112},"==",[102,876,877],{"class":108}," GPIO_PIN_RESET) ",[102,879,880],{"class":112},"?",[102,882,883],{"class":108}," GPIO_PIN_SET ",[102,885,886],{"class":112},":",[102,888,795],{"class":108},[102,890,892,895,897,901],{"class":104,"line":891},14,[102,893,894],{"class":294},"    osDelay",[102,896,818],{"class":108},[102,898,900],{"class":899},"sj4cs","500",[102,902,903],{"class":108},");\n",[102,905,907],{"class":104,"line":906},15,[102,908,909],{"class":108},"  }\n",[102,911,913],{"class":104,"line":912},16,[102,914,915],{"class":108},"}\n",[15,917,918],{},"led_task.h:",[94,920,922],{"className":96,"code":921,"language":98,"meta":48,"style":48},"#ifndef __LED_TASK_H_\n#define __LED_TASK_H_\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#include \"cpp_interface.h\"\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n",[89,923,924,932,939,943,951,957,961,966,970,977,981,987,991,995,999],{"__ignoreMap":48},[102,925,926,929],{"class":104,"line":105},[102,927,928],{"class":112},"#ifndef",[102,930,931],{"class":294}," __LED_TASK_H_\n",[102,933,934,937],{"class":104,"line":235},[102,935,936],{"class":112},"#define",[102,938,931],{"class":294},[102,940,941],{"class":104,"line":247},[102,942,785],{"emptyLinePlaceholder":784},[102,944,945,948],{"class":104,"line":258},[102,946,947],{"class":112},"#ifdef",[102,949,950],{"class":294}," __cplusplus\n",[102,952,953,955],{"class":104,"line":269},[102,954,804],{"class":112},[102,956,807],{"class":244},[102,958,959],{"class":104,"line":280},[102,960,836],{"class":108},[102,962,963],{"class":104,"line":306},[102,964,965],{"class":112},"#endif\n",[102,967,968],{"class":104,"line":332},[102,969,785],{"emptyLinePlaceholder":784},[102,971,972,974],{"class":104,"line":833},[102,973,759],{"class":112},[102,975,976],{"class":244}," \"cpp_interface.h\"\n",[102,978,979],{"class":104,"line":839},[102,980,785],{"emptyLinePlaceholder":784},[102,982,983,985],{"class":104,"line":848},[102,984,947],{"class":112},[102,986,950],{"class":294},[102,988,989],{"class":104,"line":854},[102,990,915],{"class":108},[102,992,993],{"class":104,"line":863},[102,994,965],{"class":112},[102,996,997],{"class":104,"line":891},[102,998,785],{"emptyLinePlaceholder":784},[102,1000,1001],{"class":104,"line":906},[102,1002,965],{"class":112},[15,1004,1005,1006,734,1009,1012],{},"Then open ",[89,1007,1008],{},"CMakeLists.txt",[89,1010,1011],{},"cmake/user"," folder and add the newly created led_task.cpp to it.",[15,1014,1015,1016,1019,1020,1022,1023,1025,1026,1028,1029,1031,1032,1034,1035,1037,1038,1041],{},"Detailed explanation (optional): The ",[89,1017,1018],{},"cmake/stm32cubemx"," under ",[89,1021,1008],{}," here is managed by CubeMX. If you regenerate code with CubeMX, the contents of this file will be overwritten. However, the ",[89,1024,1008],{}," at the workspace root will not be overwritten, and it provides some areas for adding source and header files. But this can make the file too cluttered. So we chose to create a new user folder, set up a ",[89,1027,1008],{}," inside it, and then use the top-level ",[89,1030,1008],{}," to load this sub-",[89,1033,1008],{},". This sub-",[89,1036,1008],{}," makes it easier for us to modify, and the file structure is clearer. (You don't need to create these yourself—I've already added them to the ",[64,1039,1040],{},"template",", and they were copied over when you copied the template above.)",[15,1043,1044],{},"Add the cpp file as shown in the image below.",[15,1046,1047],{},[46,1048],{"alt":48,"src":1049},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image92.webp",[15,1051,1052],{},"Then, go to the top-level CMakeLists.txt and add this line to reference our own CMakeLists.txt.",[15,1054,1055],{},[46,1056],{"alt":48,"src":1057},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2025/07/18/image93.webp",[94,1059,1063],{"className":1060,"code":1061,"language":1062,"meta":48,"style":48},"language-cmake shiki shiki-themes github-light github-dark","\n# Add USER generated sources\nadd_subdirectory(cmake/user)\n","cmake",[89,1064,1065,1069,1075],{"__ignoreMap":48},[102,1066,1067],{"class":104,"line":105},[102,1068,785],{"emptyLinePlaceholder":784},[102,1070,1071],{"class":104,"line":235},[102,1072,1074],{"class":1073},"sJ8bj","# Add USER generated sources\n",[102,1076,1077,1080],{"class":104,"line":247},[102,1078,1079],{"class":112},"add_subdirectory",[102,1081,1082],{"class":108},"(cmake/user)\n",[15,1084,1085],{},"Great success, let's try compiling once. As shown in the image below, all the newly added files have been compiled.",[15,1087,1088],{},[46,1089],{"alt":451,"src":1090},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776429160105.webp",[39,1092,1094],{"id":1093},"download-the-program-to-the-board","Download the program to the board",[15,1096,1097,1098],{},"Before downloading, you first need to configure ",[1099,1100],"br",{},[15,1102,1103],{},"No need to configure ST-Link, just start debugging directly.",[15,1105,1106],{},"However, Jlink and similar tools require configuration.",[1108,1109,1111],"h5",{"id":1110},"configure-the-debugger","Configure the debugger",[1113,1114,1116],"h6",{"id":1115},"st-link","ST-Link",[15,1118,1119],{},"No configuration required.",[15,1121,1122],{},[46,1123],{"alt":451,"src":1124},"/images/2026-04-17-STM32CubeIDE-VScode%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/1776435639185.png",[1113,1126,1128],{"id":1127},"jlink","JLink",[15,1130,1131],{},"First, install the jlink-gdbserver bundle, as shown in the image below:",[15,1133,1134],{},[46,1135],{"alt":451,"src":1136},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776431910132.webp",[15,1138,1139],{},"Then you also need to configure the launch:",[15,1141,1142,1143],{},"Problem Solution: ",[56,1144,1145],{"href":1145,"rel":1146},"https://community.st.com/t5/stm32cubeide-for-visual-studio/stm32h7a3vg-debugging-with-j-link-under-vscode/m-p/826188#M960",[60],[15,1148,1149,1150,1153,1154,1157],{},"Create a ",[89,1151,1152],{},"launch.json"," under the ",[89,1155,1156],{},".vscode"," folder, then enter the following content:",[94,1159,1163],{"className":1160,"code":1161,"language":1162,"meta":48,"style":48},"language-json shiki shiki-themes github-light github-dark","{\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n        {\n            \"type\": \"jlinkgdbtarget\",\n            \"request\": \"launch\",\n            \"name\": \"STM32Cube: STM32 Launch JLink GDB Server\",\n            \"origin\": \"snippet\",\n            \"cwd\": \"${workspaceFolder}\",\n            \"preBuild\": \"${command:st-stm32-ide-debug-launch.build}\",\n            \"runEntry\": \"main\",\n            \"imagesAndSymbols\": [\n                {\n                    \"imageFileName\": \"${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}\"\n                }\n            ]\n        }\n    ]\n}\n","json",[89,1164,1165,1169,1183,1191,1196,1208,1220,1232,1244,1256,1268,1280,1287,1292,1302,1307,1312,1318,1324],{"__ignoreMap":48},[102,1166,1167],{"class":104,"line":105},[102,1168,836],{"class":108},[102,1170,1171,1174,1177,1180],{"class":104,"line":235},[102,1172,1173],{"class":899},"    \"version\"",[102,1175,1176],{"class":108},": ",[102,1178,1179],{"class":244},"\"0.2.0\"",[102,1181,1182],{"class":108},",\n",[102,1184,1185,1188],{"class":104,"line":247},[102,1186,1187],{"class":899},"    \"configurations\"",[102,1189,1190],{"class":108},": [\n",[102,1192,1193],{"class":104,"line":258},[102,1194,1195],{"class":108},"        {\n",[102,1197,1198,1201,1203,1206],{"class":104,"line":269},[102,1199,1200],{"class":899},"            \"type\"",[102,1202,1176],{"class":108},[102,1204,1205],{"class":244},"\"jlinkgdbtarget\"",[102,1207,1182],{"class":108},[102,1209,1210,1213,1215,1218],{"class":104,"line":280},[102,1211,1212],{"class":899},"            \"request\"",[102,1214,1176],{"class":108},[102,1216,1217],{"class":244},"\"launch\"",[102,1219,1182],{"class":108},[102,1221,1222,1225,1227,1230],{"class":104,"line":306},[102,1223,1224],{"class":899},"            \"name\"",[102,1226,1176],{"class":108},[102,1228,1229],{"class":244},"\"STM32Cube: STM32 Launch JLink GDB Server\"",[102,1231,1182],{"class":108},[102,1233,1234,1237,1239,1242],{"class":104,"line":332},[102,1235,1236],{"class":899},"            \"origin\"",[102,1238,1176],{"class":108},[102,1240,1241],{"class":244},"\"snippet\"",[102,1243,1182],{"class":108},[102,1245,1246,1249,1251,1254],{"class":104,"line":833},[102,1247,1248],{"class":899},"            \"cwd\"",[102,1250,1176],{"class":108},[102,1252,1253],{"class":244},"\"${workspaceFolder}\"",[102,1255,1182],{"class":108},[102,1257,1258,1261,1263,1266],{"class":104,"line":839},[102,1259,1260],{"class":899},"            \"preBuild\"",[102,1262,1176],{"class":108},[102,1264,1265],{"class":244},"\"${command:st-stm32-ide-debug-launch.build}\"",[102,1267,1182],{"class":108},[102,1269,1270,1273,1275,1278],{"class":104,"line":848},[102,1271,1272],{"class":899},"            \"runEntry\"",[102,1274,1176],{"class":108},[102,1276,1277],{"class":244},"\"main\"",[102,1279,1182],{"class":108},[102,1281,1282,1285],{"class":104,"line":854},[102,1283,1284],{"class":899},"            \"imagesAndSymbols\"",[102,1286,1190],{"class":108},[102,1288,1289],{"class":104,"line":863},[102,1290,1291],{"class":108},"                {\n",[102,1293,1294,1297,1299],{"class":104,"line":891},[102,1295,1296],{"class":899},"                    \"imageFileName\"",[102,1298,1176],{"class":108},[102,1300,1301],{"class":244},"\"${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}\"\n",[102,1303,1304],{"class":104,"line":906},[102,1305,1306],{"class":108},"                }\n",[102,1308,1309],{"class":104,"line":912},[102,1310,1311],{"class":108},"            ]\n",[102,1313,1315],{"class":104,"line":1314},17,[102,1316,1317],{"class":108},"        }\n",[102,1319,1321],{"class":104,"line":1320},18,[102,1322,1323],{"class":108},"    ]\n",[102,1325,1327],{"class":104,"line":1326},19,[102,1328,915],{"class":108},[15,1330,1331],{},"Done.",[1108,1333,1335],{"id":1334},"debugging-here-linux-may-encounter-some-usb-permission-issues-please-resolve-them-on-your-own","Debugging: (Here, Linux may encounter some USB permission issues; please resolve them on your own.)",[15,1337,1338],{},"If you are using an ST-Link, it should look like the image below:",[15,1340,1341],{},[46,1342],{"alt":451,"src":1343},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776431995915.webp",[15,1345,1346],{},"If you are using a J-Link, it should look like the image below:",[15,1348,1349],{},[46,1350],{"alt":451,"src":1351},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776432039560.webp",[15,1353,1354,1355],{},"Then this bar will appear, and it will download the program to the board.\n",[46,1356],{"alt":451,"src":1357},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776432143180.webp",[15,1359,1360],{},"Then the program was successfully downloaded and entered Debug mode.",[15,1362,1363],{},[46,1364],{"alt":451,"src":1365},"https://cdn.tungchiahui.cn/tungwebsite/assets/images/2026/04/17/1776432211211.webp",[1367,1368,1369],"style",{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .s7hpK, html code.shiki .s7hpK{--shiki-default:#B31D28;--shiki-default-font-style:italic;--shiki-dark:#FDAEB7;--shiki-dark-font-style:italic}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":48,"searchDepth":235,"depth":235,"links":1371},[1372,1373,1374],{"id":12,"depth":247,"text":13},{"id":36,"depth":247,"text":37},{"id":520,"depth":247,"text":521},"/en-us/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux","3",3000000,"2026-04-17","wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian","en-us:2026-04-17-stm32cubeide-vscode-huan-jing-da-jian","/en-us/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian","STM32CubeIDE VScode环境搭建","md","wiki/2026-04-17-STM32CubeIDE-VScode环境搭建/ch3-Linux",false,null,"en-US","en-us",{},{"title":5,"description":48},"/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux","_i18n/en-us/wiki/2026-04-17-STM32CubeIDE-VScode环境搭建/ch3-Linux","FnFJucY-DlUbHMA4WWNpked3_nvJthQhtXdiQkMUirw",[1395,1401,1407,1408],{"path":1396,"stem":1397,"title":1398,"date":1378,"chapter":1399,"chapterSort":1400,"docKey":1380,"docRoot":1381,"docTitle":1382,"isWikiDoc":784,"isWikiIndex":1385},"/en-us/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch1-jian-jie","_i18n/en-us/wiki/2026-04-17-STM32CubeIDE-VScode环境搭建/ch1-简介","Introduction","1",1000000,{"path":1402,"stem":1403,"title":1404,"date":1378,"chapter":1405,"chapterSort":1406,"docKey":1380,"docRoot":1381,"docTitle":1382,"isWikiDoc":784,"isWikiIndex":1385},"/en-us/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch2-can-kao-shi-pin","_i18n/en-us/wiki/2026-04-17-STM32CubeIDE-VScode环境搭建/ch2-参考视频","Reference video","2",2000000,{"path":1375,"stem":1392,"title":5,"date":1378,"chapter":1376,"chapterSort":1377,"docKey":1380,"docRoot":1381,"docTitle":1382,"isWikiDoc":784,"isWikiIndex":1385},{"path":1381,"stem":1409,"title":1410,"date":1378,"chapter":1386,"chapterSort":1411,"docKey":1380,"docRoot":1381,"docTitle":1382,"isWikiDoc":784,"isWikiIndex":784},"_i18n/en-us/wiki/2026-04-17-STM32CubeIDE-VScode环境搭建/index","STM32CubeIDE-VSCode Environment Setup",0,{"variants":1413},[1414,1415,1418,1421,1424],{"path":1375,"localeSlug":1388,"i18nKey":1384},{"path":1416,"localeSlug":1417,"i18nKey":1384},"/zh-hant/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux","zh-hant",{"path":1419,"localeSlug":1420,"i18nKey":1384},"/zh-hk/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux","zh-hk",{"path":1422,"localeSlug":1423,"i18nKey":1384},"/zh-tw/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux","zh-tw",{"path":1425,"localeSlug":1426,"i18nKey":1384},"/zh-cn/wiki/2026-04-17-stm32cubeide-vscode-huan-jing-da-jian/ch3-linux","zh-cn",[1375,1391,1416,1391,1419,1391,1422,1391,1425,1391],1780663019704]