Skip to main content
Graduate
April 24, 2025
Solved

Run without debugging on VSCode

  • April 24, 2025
  • 12 replies
  • 4671 views

I have setup STM32 VSCode extension on my PC and it is amazing. The only problem that I have encountered is that it is not possible to run the code without debugging. I removed the "runToEntryPoint": "main" line in launch.json. But every time I launch the code it attaches a debugger. How can I simply run the code without debugging?

 

Thank you,

Damiano

    This topic has been closed for replies.
    Best answer by Sarra.S

    In the tasks.json file, there is a a "task" labeled STM32: CubeProg: Flash project (SWD) 

    You can execute this task to perform a "flash and reset" altogether! 

    There are 3 options to execute this: 

    Option1: By "clicking": Terminal > Run Task... > CubeProg: Flash Project (SWD)
    SarraS_0-1746551491069.png

    Option2 via Run Task keyboard shortcut:

    Option3: Pre-installed keyboard shortcut:

    • CTRL + P
    • Type: "Task CubePro..." <-- You will notice that the menu auto-suggests tasks matching your pattern.

    Option3: Pre-installed keyboard shortcut: 

    • CTRL+ALT+F <-- This will immediately execute the same task

    12 replies

    ST Employee
    April 24, 2025

    Hello @DamianoF

    Did you try this and didn't not work for you? 

    SarraS_1-1745485979741.png

     

    DamianoFAuthor
    Graduate
    April 24, 2025

    Hello @Sarra.S and thank you for your answer

     

    I tried it and it kind of works, but not in the way I expected. When I click "Run Without Debugging" as you suggested, the debug buttons (those in the image below) still appear and the code does not execute until I click on the red square (which is the stop button, a little counterintuitive). What I expect is that when I click on "Run without debugging" the code will be flashed directly on the MCU, the debug buttons don't show up and the code does not wait for me to click any button at all.

     

    DamianoF_0-1745495311641.png

     

    Super User
    April 24, 2025

    STM32CubeIDE had this issue for the first few releases. It's odd that the developers didn't realize "run without debugging" was a critical feature. Maybe it's the same devs.

    DamianoFAuthor
    Graduate
    April 24, 2025

    @TDKI am not using STM32CubeIDE, but VSCode with STM32 VSCode extension

    ST Employee
    May 6, 2025

    Hello @DamianoF

    For the moment, in order to execute this from the VS Code top menu, 

    1. Stop the current MCU from running using Shift + F5 (if it is running)
    2. After compiling and flashing with "Run Without Debugging, manually reset the device on the hardware in order to start executing. 

    Please check Mattias's answer in this thread: New STM32 VSCode extension V2.0.0 released - STMicroelectronics Community

    DamianoFAuthor
    Graduate
    May 6, 2025

    Thank you @Sarra.S!

    So at the moment the only solution is to do what I already do. If possible I ask to you if you can report this limitation to the ST team that develops the extension. It is not a big limitation but it is very helpful in day-to-day use

    Sarra.SAnswer
    ST Employee
    May 6, 2025

    In the tasks.json file, there is a a "task" labeled STM32: CubeProg: Flash project (SWD) 

    You can execute this task to perform a "flash and reset" altogether! 

    There are 3 options to execute this: 

    Option1: By "clicking": Terminal > Run Task... > CubeProg: Flash Project (SWD)
    SarraS_0-1746551491069.png

    Option2 via Run Task keyboard shortcut:

    Option3: Pre-installed keyboard shortcut:

    • CTRL + P
    • Type: "Task CubePro..." <-- You will notice that the menu auto-suggests tasks matching your pattern.

    Option3: Pre-installed keyboard shortcut: 

    • CTRL+ALT+F <-- This will immediately execute the same task
    Visitor II
    July 22, 2025

    You can also make it the default build task by clicking the "Configure Default Build Task" option in the "Terminal" tab. A list of tasks is displayed, select the "CubeProg Flah.." command. Then you can build your project using CTRL + SHIFT + B (which performs the "Run Build Task")

    Explorer
    September 2, 2025

    我发现了可以创建一个task.json文件,加入以下内容

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": ":down_arrow: Flash",
                "type": "shell",
                "command": "STM32_Programmer_CLI.exe",
                "args": [
                    "-c",
                    "port=SWD",
                    "-w",
                    "${workspaceFolder}/build/Debug/TEST.bin",
                    "0x08000000",
                    "-v",
                    "-rst"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": false
                },
                "problemMatcher": []
            }
        ]
    }
    这样就可以在终端中运行这个任务,只下载而不进入调试。配合Task插件可以将这个任务直接一键运行,和IDE内的操作一致
    Visitor II
    November 18, 2025

    I have improved your task by adding a configuration to Build the code and Flash

    {
     "version": "2.0.0",
     "tasks": [
     {
     "label": "Flash STM32 (CubeProg)",
     "type": "shell",
     "command": "C:\\Program Files\\STMicroelectronics\\STM32Cube\\STM32CubeProgrammer\\bin\\STM32_Programmer_CLI.exe",
     "args": [
     "-c",
     "port=swd",
     "-d",
     "${command:cmake.launchTargetPath}", // Takes the path of the compiled binary
     "-v", // Verify after programming
     "-rst" // Reset the board to start the code
     ],
     "dependsOn": "CMake: build", // <--- This forces COMPILATION before flashing
     "group": {
     "kind": "build",
     "isDefault": true
     },
     "problemMatcher": []
     }
     ]
    }
    Graduate II
    December 9, 2025

    Hi, I found this thread trying to answer the question "how do I flash my code to my MCU without needing to go through the debugger" when using vscode. I see there's mention of ST-specific "tasks", but (using the most recent VScode extension bundle) there is no "tasks.json" in my .vscode directory. 

    Is it possible to get updated instructions on how to do this? Seems like kind of a mishmash of advice here, and not an obvious way to do any of these in the most recent build of the VSCode tooling. 

    Visitor II
    September 23, 2025

    I prefer to do common operations like this with a keyboard, and I couldn't get most of Sarra.S's suggestions to work.  Also, the "Build + Flash" task is the one to use, since it also builds.  Here's what works for me:

    Option 1: Do this every time you want to run without debugging: Ctrl+Shift+P, type "Tasks: Run Task" (or enough of it so it's at the top of the autocomplete list that pops up), Enter, use up and down arrow keys to select "Build + Flash" (which is defined in your project's autogenerated .vscode/tasks.json), Enter.

    Option 2: Add a hotkey by doing Ctrl+Shift+P, and selecting "Preferences: Open Keyboard Shortcuts (JSON)".  Set the file contents to this, overwriting what was there (or merge it if there's something important there).  After you save the file, you can press Ctrl+F5 to run the command.  Unfortunately, this applies to all your VSCode projects.

    [
     {
     "key": "ctrl+f5",
     "command": "workbench.action.tasks.runTask",
     "args": "Build + Flash"
     }
    ]



    Visitor II
    December 24, 2025

    I agree with the previous comments. Somehow the suggestions offered by ST guys simply don't exist in Vscode. For example Sarra (ST) suggested to manually run some STM32 task but similarly to another guy I don't see any STM32 related task at all, however the STM32 extension is installed. I don't know if all prerequisite are installed properly or not because there is no conprehensive guide about this topic. Also, some of you suggested to edit the tasks.json file but I can't find such a file in the imported project folders either. How could we edit a file that doesn't exist at all and a beginner has no idea where to create it and what the content of such a file should be? I'm also a beginner and I could switch from CudeIDE to Vscode with difficulties because the import/setup of a CubeIDE project in Vscode is rather complicated for a beginner. Just see this simple example: guys want to run a code without debugging. In CubeIDE it's just few clicks. In Vscode we must run non-existing Tasks and edit non-existing JSON files. No comment....

    If ST will soon decide to get rid of CubeIDE (I believe this gonna be happen) then all beginners will be lost in the maze of Vscode.

    Visitor II
    December 24, 2025

    CubeIDE 2.0.0 dropped and they removed CubeMX integration. So I thought of trying the VSCode extension but it seems like important features like this is missing.

    Anyways the tasks.json config provided by pantaleone works. If you're on a linux distro, the programmer (bundled with the extension) path is

    /home/<username>/.local/share/stm32cube/bundles/programmer/2.21.0/bin/STM32_Programmer_CLI  

    --------------

    @Krisz72 Make sure your STM32 project is setup like this : https://www.youtube.com/watch?v=aWMni01XGeI

    Then make a file named tasks.json inside .vscode folder in your project directory (Create the folder if it's not there). 
    Copy-paste the json config provided by pantaleone ( 
    https://community.st.com/t5/stm32cubeide-for-visual-studio/run-without-debugging-on-vscode/m-p/857351/highlight/true#M1494 ). 

    Go to Terminal > Run Task > Flash STM32 (CubeProg)

    Visitor II
    December 24, 2025

    Hello Evoprime!

    I can confirm that I did exactly the same what is presented on this Youtube video. Everything works like that except that there are no STM32 related tasks in Vscode and the Tasks.json file is missing from the .vscode subfolder of the new or imported projects.

    I still believe that it's not good that the "official" way to learn all these is that the beginners must pick up various hints from this forum. Anyway, thank you very much for your prompt reply!

    I wish all of you Merry Christmas!

     

    Explorer II
    December 24, 2025

    Hi Damiano,

    By default VSCode always launches the firmware through the debugger when using the provided launch configuration.
    If you want to simply run the code without debugging, you can either flash the binary directly using STM32CubeProgrammer or ST-Link Utility, or create a separate VSCode task that builds and uploads the firmware without attaching the debugger. This usually gives a much faster workflow when testing normal execution.

    In many projects we combine embedded development with Android-side testing for media and streaming applications such as MX Player, where timing and stable execution become very noticeable during real usage. Having a clean run configuration helps a lot in such scenarios.

    For anyone doing similar Android media testing and playback behavior analysis, this resource has been helpful in our work:
    mxplayermodsapk.com

    Hope this helps. Let us know if you discover an even cleaner workflow.

    Visitor II
    December 24, 2025

    Indeed, it seems like the extension no longer generates a "tasks.json".  Here are updated instructions for people who just want to flash their STM32 without starting a debug session.

    Add a file named tasks.json in the .vscode directory with these contents:

     

    {
     "version": "2.0.0",
     "windows": {
     "options": {
     "shell": {
     "executable": "cmd.exe",
     "args": ["/d", "/c"]
     }
     }
     },
     "tasks": [
     {
     "type": "shell",
     "label": "CubeProg: Flash project (SWD)",
     "command": "STM32_Programmer_CLI",
     "args": [
     "--connect",
     "port=swd",
     "--download",
     "${command:cmake.launchTargetPath}",
     "-hardRst",
     "-rst",
     "--start"
     ],
     "options": {
     "cwd": "${workspaceFolder}"
     },
     "problemMatcher": [],
     "presentation": {
     "showReuseMessage": false
     }
     },
     {
     "label": "Build + Flash",
     "dependsOrder": "sequence",
     "dependsOn": [
     "CMake: clean rebuild",
     "CubeProg: Flash project (SWD)"
     ],
     "problemMatcher": [
     "$gcc"
     ],
     "presentation": {
     "showReuseMessage": false
     }
     },
     {
     "type": "cmake",
     "label": "CMake: clean rebuild",
     "command": "cleanRebuild",
     "targets": [
     "all"
     ],
     "preset": "${command:cmake.activeBuildPresetName}",
     "group": "build",
     "problemMatcher": [],
     "detail": "CMake template clean rebuild task",
     "presentation": {
     "clear": true,
     "showReuseMessage": false
     }
     }
     ]
    }

     

    Now test the three new tasks you just defined: press Ctrl+Shift+P, type "Tasks: Run Task", press Enter, use arrow keys to select a task name, then press Enter. Make sure the tasks do what you expect.

    For faster programming, you probably want to assign a hotkey to run the "Build + Flash" task. Press Ctrl+Shift+P, type "Preferences: Open Keyboard Shortcuts (JSON)".  Set the file contents to this, overwriting what was there (or merge it if there's something important there).  After you save the file, you can press Ctrl+F5 to run the task.  Unfortunately, this applies to all your VSCode projects.

     

    [
     {
     "key": "ctrl+f5",
     "command": "workbench.action.tasks.runTask",
     "args": "Build + Flash"
     }
    ]