In the latest version of the cortex-debug extension, debugging starts before the code is fully compiled. This means that the compilation process runs in parallel with the debugging process. As I understand it, this is related to the specifics of how the ARMCLANG compiler is launched. A similar issue occurs when restarting the debugger, as the build task always runs.

tasks.json


        {
            "label": "build",
            "type": "shell",
            "command": "${command:eide.project.build}",
            "group": "build",
            "problemMatcher": "$gcc"
        },

launch.json

        {
            "cwd": "${workspaceFolder}",
            "executable": "./Output/Debug/Project.elf",
            "name": "Debug with ST-Link",
            "request": "launch",
            "type": "cortex-debug",
            "runToEntryPoint": "main",
            "showDevDebugOutput": "none",
            "servertype": "stlink",
            "liveWatch": {
                "enabled": true,
                "samplesPerSecond": 4
            },
            "preLaunchTask": "build",
            "svdFile": ".pack/Keil/STM32F4xx_DFP.2.14.0/CMSIS/SVD/STM32F429x.svd",
            "v1": false,
            "serverArgs": ["-m","0"],
        }

I tried to solve the problem as you suggested in one of the threads, but with that option, the ELF file is not generated, although it is created normally through the standard build.

        {
            "label": "debug build",
            "type": "shell",
            "command": "unify_builder",
            "args": ["-p", "Output/Debug/builder.params"],
            "group": "build",
            "problemMatcher": "$gcc"
        },

    Avlaak

    The command '${command:eide.project.build}' is an asynchronous operation, it will send a commandline to vscode terminal and return immediately. So you can not use this in "preLaunchTask"

    The solution is exactly what you said:

    I tried to solve the problem as you suggested in one of the threads, but with that option, the ELF file is not generated, although it is created normally through the standard build.

        {
            "label": "debug build",
            "type": "shell",
            "command": "unify_builder",
            "args": ["-p", "Output/Debug/builder.params"],
            "group": "build",
            "problemMatcher": "$gcc"
        },

    You mentioned that "the ELF file is not generated", are you paying attention to the command line output ?

    If there are any errors it will have a hint.


    I've tried it and it works. It will build at first, and than startup debug server

    7 days later

    When we run the unify_builder command we have:

    axf2elf.log after the unify_builder command

    arm-none-eabi-objcopy --update-section ER_IROM1="" "c:\Users\avlaa\Desktop\Projects\mir\Output\Debug\Project.axf" "c:\Users\avlaa\Desktop\Projects\mir\Output\Debug\Project.elf"
    
    arm-none-eabi-objcopy: cannot open: : Invalid argument

    axf2elf.log after the ${command:eide.project.build} command

    arm-none-eabi-objcopy --update-section ER_IROM1="C:\Users\avlaa\AppData\Local\Temp\\Project_1MwVhS8e.bin" "c:\Users\avlaa\Desktop\Projects\mir\Output\Debug\Project.axf" "c:\Users\avlaa\Desktop\Projects\mir\Output\Debug\Project.elf"
    
    arm-none-eabi-objcopy: c:\Users\avlaa\Desktop\Projects\mir\Output\Debug\Project.elf: warning: allocated section `RW_IRAM1' not in segment

    As I understand it, 1 argument is missing.

      Thank you, the problem was solved, as you said, I had an old version of axf2elf. It was located in the path, "C:\Users\avlaa.eide\bin\builder\bin", as I understand it, the extension did not delete this version, and when deleting the bin folder and restarting VS Code, a NOTICE.TXT file appeared with a new path.

      Write a Reply...