0

i'm developing embedded firmware on zephyr RTOS. Zephyr env. works on WSL2. And "Vscode remote client" works in Win10 "Vscode Server" works on Ununtu 22.04. I use Jlink debbugger for flashing and debugging firmware. I have to use remote debugging because debugger connected to Win10 via USB. So I run the JLink "JLinkRemoteServerCL.exe" in Win10 before flash or debug.

But every time I plug or unplug the USB into the PC JLink Remote Connection disconnects. This is annoying.

My goal is to automatically run "JLinkRemoteServerCL.exe" when I run the flash task and close it after the flash task is complete.

I wrote two task for it and connect the flash task to start "JLinkRemoteServerCL.exe" task with "dependsOn" property. But Flash task doesn't start because when start to "JLinkRemoteServerCL.exe" task, it waits connection and never finish.

I do not know how to kill the "Start Remote Server" task even if i achieve run the "Flash" task.

How can I flash my MCU's with run only 1 task?

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "command": "west",
            "type": "shell",
            "group": "build",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "args": [
                "build",
                "--pristine",
                "-b",
                "${input:board}",
                "-d",
                "builds/build_${input:board}",
                "--",
                "-DBOARD_ROOT=../Common",
                "-DCONF_FILE=prj.conf",
                "-DOVERLAY_CONFIG=configs/prj_${input:board}.conf",
                "-DDTC_OVERLAY_FILE=boards/${input:board}.overlay"
            ],
            "problemMatcher": [
                "$gcc"
            ],
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": true,
            }
        },        
        {
            "label": "Build MCUBOOT",
            "command": "west",
            "type": "shell",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "args": [
                "build",
                "$ZEPHYR_BASE/../bootloader/mcuboot/boot/zephyr",
                "--pristine",
                "-b",
                "${input:board}",
                "-d",
                "builds/build_${input:board}/bootloader/mcuboot",
                "--",
                "-DBOARD_ROOT=${cwd}/../Common",
                "-DOVERLAY_CONFIG=${cwd}/bootloader_configs/prj_mcuboot_${input:board}.conf",
                "-DDTC_OVERLAY_FILE=${cwd}/boards/${input:board}.overlay",
                "-DCONFIG_BOOT_SIGNATURE_KEY_FILE=\\\"${cwd}/../Common/keys/${input:key}\\\""
            ],
            "problemMatcher": [
                "$gcc"
            ],
            "presentation": {
                "reveal": "always"
            },
        },
        {
            "label": "Flash",
            "command": "west",
            "type": "shell",
            "group": "build",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "args": [
                "flash",
                "-d",
                "builds/build_${input:board}",
                "--hex-file",
                "builds/build_${input:board}/zephyr/zephyr.bin",
                "-r",
                "jlink",
                "--tool-opt=ip 192.168.0.21"
            ],
            "dependsOn" : "Start JLink Remote Server"
        },
        {
            "label": "Flash with MCUBOOT",
            "command": "west",
            "type": "shell",
            "group": "build",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "args": [
                "flash",
                "-d",
                "builds/build_${input:board}",
                "--hex-file",
                "builds/build_${input:board}/merged.hex",
                "-r",
                "jlink",
                "--tool-opt=ip 192.168.0.21"
            ],
            "dependsOn" : "Start JLink Remote Server"
        },
        {
            "label": "Sign",
            "command": "west",
            "type": "shell",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "args": [
                "sign",
                "-t",
                "imgtool",
                "-d",
                "builds/build_${input:board}",
                "--",
                "--version",
                "${input:version_num}",
                "--key",
                "${workspaceFolder}/../Common/keys/${input:key}"
            ]
        },
        {
            "label": "Build With MCUBOOT",
            "command": "python3",
            "type": "shell",
            "group": "build",
            "args": [
                "$ZEPHYR_BASE/scripts/build/mergehex.py",
                "builds/build_${input:board}/zephyr/zephyr.signed.hex",
                "builds/build_${input:board}/bootloader/mcuboot/zephyr/zephyr.hex",
                "-o",
                "builds/build_${input:board}/merged.hex"
            ],
            "dependsOn":["Get Inputs", "Build", "Build MCUBOOT", "Sign"],
            "dependsOrder": "sequence"
        },
        {
            "label": "Start JLink Remote Server",
            "type": "shell",
            "command": "/mnt/c/Program\\ Files/SEGGER/JLink/JLinkRemoteServerCL.exe",
        },
        {
            "label": "Get Inputs",
            "type": "shell",
            "command": "echo",
            "args": [
                "Board:",
                "\b${input:board}",
                "Key:",
                "\b${input:key}",
                "Version:",
                "\b${input:version_num}"

            ],
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": true
            }
        }
    ],
    "inputs": [
        {
            "id": "board",
            "description": "Zephyr Target Board",
            "default": "witag_litum",
            "type": "pickString",
            "options":[
                "witag_litum",
                "nucleo_l073rz",
                "witag_bdcip",
                "witag",
                "tsg001",
                "ft06dch",
                "eagleeyesense",
                "lowcost",
                "nrf52833dk_nrf52833",
                "nrf52840dongle_nrf52840",
            ]
        },
        {
            "id": "version_num",
            "description": "Version Number:",
            "default": "100.100.1+0",
            "type": "promptString"
        },
        {
            "id": "key",
            "description": "MCUBOOT KEY file located in Common/keys",
            "default": "witag_litum",
            "type": "pickString",
            "options":[
                "WiTag.pem",
                "WiTag_Litum.pem",
                "root-rsa-2048.pem"
            ]
        }
    ]   
}
Frant
  • 5,382
  • 1
  • 16
  • 22
  • You need to somehow run the remote server in the background so it can be started but not waited on, have you tried the suggestion here? https://stackoverflow.com/questions/44242048/how-to-make-vscode-not-wait-for-finishing-a-prelaunchtask – Unn Dec 27 '22 at 22:19

0 Answers0