From 296d1a8178234dd6284083251f6f82e65aa4ec2d Mon Sep 17 00:00:00 2001 From: Lukasz Gniadzik Date: Wed, 24 Feb 2021 03:54:09 +0100 Subject: [PATCH 1/7] Add vscode tasks for flashing mbed shell example. Add seperated task for DISCO build. --- .devcontainer/Dockerfile | 3 ++ .devcontainer/devcontainer.json | 4 +- .vscode/tasks.json | 32 +++++++++++- scripts/examples/mbed_example_utils.sh | 70 ++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 2 deletions(-) create mode 100755 scripts/examples/mbed_example_utils.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 580d6e93069ddc..fce208ad3162e5 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -35,6 +35,9 @@ RUN apt-get -fy install git vim emacs sudo \ wget curl telnet \ docker.io \ iputils-ping net-tools + +RUN python3 -m pip install pyocd pyusb + RUN groupadd -g $USER_GID $USERNAME RUN useradd -s /bin/bash -u $USER_UID -g $USER_GID -G docker -m $USERNAME RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 08dfc59833061f..91e692eba3c1e4 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,9 @@ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", - "--network=host" + "--network=host", + "-v","/dev/bus/usb:/dev/bus/usb:ro", + "--device-cgroup-rule=a 189:* rmw" ], "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5d111c58ab4bc1..540d28ad10fc83 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -233,7 +233,7 @@ } }, { - "label": "Build nRF mbed shell Example", + "label": "Build Mbed Shell example (NRF52840-DK)", "type": "shell", "command": "scripts/examples/mbed_example.sh", "args": ["-a=shell", "-b=NRF52840_DK", "-p=release"], @@ -245,6 +245,36 @@ "${workspaceFolder}/examples/shell/mbed/build" ] } + }, + { + "label": "Build Mbed Shell example (DISCO_L475VG_IOT01A)", + "type": "shell", + "command": "scripts/examples/mbed_example.sh", + "args": ["-a=shell", "-b=DISCO_L475VG_IOT01A", "-p=release"], + "group": "build", + "problemMatcher": { + "base": "$gcc", + "fileLocation": [ + "relative", + "${workspaceFolder}/examples/shell/mbed/build" + ] + } + }, + { + "label": "Flash Mbed Shell example (NRF52840-DK)", + "type": "shell", + "command": "scripts/examples/mbed_example_utils.sh", + "args": ["-a=shell", "-b=NRF52840_DK"], + "problemMatcher": [], + "group": "build" + }, + { + "label": "Flash Mbed Shell example (DISCO_L475VG_IOT01A)", + "type": "shell", + "command": "scripts/examples/mbed_example_utils.sh", + "args": ["-a=shell", "-b=DISCO_L475VG_IOT01A"], + "problemMatcher": [], + "group": "build" } ] } diff --git a/scripts/examples/mbed_example_utils.sh b/scripts/examples/mbed_example_utils.sh new file mode 100755 index 00000000000000..bd6963c87d832f --- /dev/null +++ b/scripts/examples/mbed_example_utils.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cd "$(dirname "$0")/../../examples" + +SUPPORTED_TARGET_BOARD=(DISCO_L475VG_IOT01A NRF52840_DK) +SUPPORTED_APP=(shell) + +APP= +TARGET_BOARD= +PYOCD_TARGET= + +for i in "$@"; do + case $i in + -a=* | --app=*) + APP="${i#*=}" + shift + ;; + -b=* | --board=*) + TARGET_BOARD="${i#*=}" + shift + ;; + *) + # unknown option + ;; + esac +done + +case $TARGET_BOARD in +NRF52840_DK) + PYOCD_TARGET=nrf52840 + ;; + +DISCO_L475VG_IOT01A) + PYOCD_TARGET=stm32l475xg + ;; + +*) + # unknown option + ;; +esac + +if [[ ! " ${SUPPORTED_TARGET_BOARD[@]} " =~ " ${TARGET_BOARD} " ]]; then + echo "ERROR: Target $TARGET_BOARD not supported" + exit 1 +fi + +if [[ ! " ${SUPPORTED_APP[@]} " =~ " ${APP} " ]]; then + echo "ERROR: Application $APP not supported" + exit 1 +fi + +echo "############################" +pyocd flash -t $PYOCD_TARGET $PWD/$APP/mbed/build-$TARGET_BOARD/chip-mbed-$APP-example.hex +echo "############################" From 76d2c6a5276f4076683cb1b1973528420d7d60c6 Mon Sep 17 00:00:00 2001 From: Lukasz Gniadzik Date: Fri, 26 Feb 2021 03:45:59 +0100 Subject: [PATCH 2/7] Add vscode launch task for debugging shell example. --- .vscode/launch.json | 122 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index d41815e9d3110c..94f67e7c5776f9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -83,6 +83,128 @@ "ignoreFailures": true } ] + }, + { + "name": "Shell Mbed Example Debug [NRF52840_DK]", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/chip-mbed-shell-example", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceRoot}/examples/shell/mbed", + "environment": [], + "externalConsole": false, + "debugServerArgs": "", + "serverLaunchTimeout": 20000, + "filterStderr": true, + "filterStdout": false, + "serverStarted": "GDB\\ server\\ started", + "logging": { + "moduleLoad": true, + "trace": true, + "engineLogging": true, + "programOutput": true, + "exceptions": true + }, + "linux": { + "MIMode": "gdb", + "MIDebuggerPath": "arm-none-eabi-gdb", + "debugServerPath": "pyocd-gdbserver" + }, + "setupCommands": [ + { + "text": "-target-select remote localhost:3333", + "description": "connect to target", + "ignoreFailures": false + }, + { + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/chip-mbed-shell-example", + "description": "load file", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor endian little\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor reset\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor halt\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor arm semihosting enable\"", + "ignoreFailures": false + }, + { + "text": "-target-download", + "description": "flash target", + "ignoreFailures": false + } + ] + }, + { + "name": "Shell Mbed Example Debug [DISCO_L475VG_IOT01A]", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/chip-mbed-shell-example", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceRoot}/examples/shell/mbed", + "environment": [], + "externalConsole": false, + "debugServerArgs": "", + "serverLaunchTimeout": 20000, + "filterStderr": true, + "filterStdout": false, + "serverStarted": "GDB\\ server\\ started", + "logging": { + "moduleLoad": true, + "trace": true, + "engineLogging": true, + "programOutput": true, + "exceptions": true + }, + "linux": { + "MIMode": "gdb", + "MIDebuggerPath": "arm-none-eabi-gdb", + "debugServerPath": "pyocd-gdbserver" + }, + "setupCommands": [ + { + "text": "-target-select remote localhost:3333", + "description": "connect to target", + "ignoreFailures": false + }, + { + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/chip-mbed-shell-example", + "description": "load file", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor endian little\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor reset\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor halt\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor arm semihosting enable\"", + "ignoreFailures": false + }, + { + "text": "-target-download", + "description": "flash target", + "ignoreFailures": false + } + ] } ] } From 7a001e836aca5100d7bf921cfb3e400051004de6 Mon Sep 17 00:00:00 2001 From: Lukasz Gniadzik Date: Mon, 1 Mar 2021 14:05:49 +0100 Subject: [PATCH 3/7] Add libncurses5 to chip-vscode Dockerfile. the libncurses5 is required by the pyOCD. --- .devcontainer/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index fce208ad3162e5..48e111e8e5f9db 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -34,7 +34,8 @@ RUN apt-get -fy install git vim emacs sudo \ build-essential cmake cppcheck valgrind \ wget curl telnet \ docker.io \ - iputils-ping net-tools + iputils-ping net-tools \ + libncurses5 RUN python3 -m pip install pyocd pyusb From 31273b166bc3547b7909343d8e867a390539d590 Mon Sep 17 00:00:00 2001 From: Lukasz Gniadzik Date: Mon, 1 Mar 2021 14:48:29 +0100 Subject: [PATCH 4/7] Add input variables support to vscode mbed tasks. --- .vscode/launch.json | 74 +++++++-------------------------------------- .vscode/tasks.json | 46 ++++++++++++++-------------- 2 files changed, 33 insertions(+), 87 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 94f67e7c5776f9..5319ebdf6c7f05 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -85,10 +85,10 @@ ] }, { - "name": "Shell Mbed Example Debug [NRF52840_DK]", + "name": "Shell Mbed Example Debug", "type": "cppdbg", "request": "launch", - "program": "${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/chip-mbed-shell-example", + "program": "${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", "args": [], "stopAtEntry": true, "cwd": "${workspaceRoot}/examples/shell/mbed", @@ -118,7 +118,7 @@ "ignoreFailures": false }, { - "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/chip-mbed-shell-example", + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", "description": "load file", "ignoreFailures": false }, @@ -144,67 +144,15 @@ "ignoreFailures": false } ] - }, + } + ], + "inputs": [ { - "name": "Shell Mbed Example Debug [DISCO_L475VG_IOT01A]", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/chip-mbed-shell-example", - "args": [], - "stopAtEntry": true, - "cwd": "${workspaceRoot}/examples/shell/mbed", - "environment": [], - "externalConsole": false, - "debugServerArgs": "", - "serverLaunchTimeout": 20000, - "filterStderr": true, - "filterStdout": false, - "serverStarted": "GDB\\ server\\ started", - "logging": { - "moduleLoad": true, - "trace": true, - "engineLogging": true, - "programOutput": true, - "exceptions": true - }, - "linux": { - "MIMode": "gdb", - "MIDebuggerPath": "arm-none-eabi-gdb", - "debugServerPath": "pyocd-gdbserver" - }, - "setupCommands": [ - { - "text": "-target-select remote localhost:3333", - "description": "connect to target", - "ignoreFailures": false - }, - { - "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/chip-mbed-shell-example", - "description": "load file", - "ignoreFailures": false - }, - { - "text": "-interpreter-exec console \"monitor endian little\"", - "ignoreFailures": false - }, - { - "text": "-interpreter-exec console \"monitor reset\"", - "ignoreFailures": false - }, - { - "text": "-interpreter-exec console \"monitor halt\"", - "ignoreFailures": false - }, - { - "text": "-interpreter-exec console \"monitor arm semihosting enable\"", - "ignoreFailures": false - }, - { - "text": "-target-download", - "description": "flash target", - "ignoreFailures": false - } - ] + "type": "pickString", + "id": "mbedTarget", + "description": "What mbed target will be used?", + "options": ["NRF52840_DK", "DISCO_L475VG_IOT01A"], + "default": "NRF52840_DK" } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 540d28ad10fc83..81a5fc39736b20 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -233,10 +233,14 @@ } }, { - "label": "Build Mbed Shell example (NRF52840-DK)", + "label": "Build Mbed Shell Example", "type": "shell", "command": "scripts/examples/mbed_example.sh", - "args": ["-a=shell", "-b=NRF52840_DK", "-p=release"], + "args": [ + "-a=shell", + "-b=${input:mbedTarget}", + "-p=${input:mbedProfile}" + ], "group": "build", "problemMatcher": { "base": "$gcc", @@ -247,34 +251,28 @@ } }, { - "label": "Build Mbed Shell example (DISCO_L475VG_IOT01A)", - "type": "shell", - "command": "scripts/examples/mbed_example.sh", - "args": ["-a=shell", "-b=DISCO_L475VG_IOT01A", "-p=release"], - "group": "build", - "problemMatcher": { - "base": "$gcc", - "fileLocation": [ - "relative", - "${workspaceFolder}/examples/shell/mbed/build" - ] - } - }, - { - "label": "Flash Mbed Shell example (NRF52840-DK)", + "label": "Flash Mbed Shell Example", "type": "shell", "command": "scripts/examples/mbed_example_utils.sh", - "args": ["-a=shell", "-b=NRF52840_DK"], + "args": ["-a=shell", "-b=${input:mbedTarget}"], "problemMatcher": [], "group": "build" + } + ], + "inputs": [ + { + "type": "pickString", + "id": "mbedTarget", + "description": "What mbed target will be used?", + "options": ["NRF52840_DK", "DISCO_L475VG_IOT01A"], + "default": "NRF52840_DK" }, { - "label": "Flash Mbed Shell example (DISCO_L475VG_IOT01A)", - "type": "shell", - "command": "scripts/examples/mbed_example_utils.sh", - "args": ["-a=shell", "-b=DISCO_L475VG_IOT01A"], - "problemMatcher": [], - "group": "build" + "type": "pickString", + "id": "mbedProfile", + "description": "What mbed profile do you want to use?", + "options": ["release", "debug", "develop"], + "default": "debug" } ] } From 179d3f0d88cdb53b2dd885eaef9a4e08746fdcd7 Mon Sep 17 00:00:00 2001 From: Lukasz Gniadzik Date: Mon, 1 Mar 2021 23:54:18 +0100 Subject: [PATCH 5/7] Split mbed shell debug task to local and remote tasks. 'Local' means that gdbserver will be run inside the container, where 'remote' will try to connect to gdbserver which run on the host. If user want to use 'remote' debug mode then he has to remember to run pyocd-gdbserver with '--allow-remote' flag (host side). 'Remote' configuration should work on all systems. 'Local' debug mode should be fine for most use cases where only raw usb is used to provide debug probe support. However I observed that for STLink probe, the gdbserver can't automatically detect debug target. This is related to limited access to host mounted volumes inside container, which are used by STLink to pass information about stm hardware. In result, debugger will not stop at 'main()' entry point automatically what means that may be some other problems with breakpoints during debugging. As a workaround for this issue, user may consider to specify directly debug target for pyocd-gdbserver. To do that, he should use 'debugServerArgs' inside 'Shell Mbed Example Debug [local]' configuration. --- .devcontainer/devcontainer.json | 6 ++- .vscode/launch.json | 69 +++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 91e692eba3c1e4..616a7dcd8afe7b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,8 +5,10 @@ "--security-opt", "seccomp=unconfined", "--network=host", - "-v","/dev/bus/usb:/dev/bus/usb:ro", - "--device-cgroup-rule=a 189:* rmw" + "-v", + "/dev/bus/usb:/dev/bus/usb:ro", + "--device-cgroup-rule=a 189:* rmw", + "--add-host=host.docker.internal:host-gateway" ], "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" diff --git a/.vscode/launch.json b/.vscode/launch.json index 5319ebdf6c7f05..8c8393c735451d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -85,7 +85,7 @@ ] }, { - "name": "Shell Mbed Example Debug", + "name": "Shell Mbed Example Debug [local]", "type": "cppdbg", "request": "launch", "program": "${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", @@ -106,11 +106,6 @@ "programOutput": true, "exceptions": true }, - "linux": { - "MIMode": "gdb", - "MIDebuggerPath": "arm-none-eabi-gdb", - "debugServerPath": "pyocd-gdbserver" - }, "setupCommands": [ { "text": "-target-select remote localhost:3333", @@ -123,7 +118,54 @@ "ignoreFailures": false }, { - "text": "-interpreter-exec console \"monitor endian little\"", + "text": "-interpreter-exec console \"monitor reset\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor halt\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor arm semihosting enable\"", + "ignoreFailures": false + }, + { + "text": "-target-download", + "description": "flash target", + "ignoreFailures": false + } + ], + "linux": { + "MIMode": "gdb", + "MIDebuggerPath": "arm-none-eabi-gdb", + "debugServerPath": "pyocd-gdbserver", + "debugServerArgs": "" // [-t ] + } + }, + { + "name": "Shell Mbed Example Debug [remote]", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceRoot}/examples/shell/mbed", + "environment": [], + "externalConsole": false, + "debugServerArgs": "", + "serverLaunchTimeout": 20000, + "filterStderr": true, + "filterStdout": false, + "serverStarted": "GDB\\ server\\ started", + "setupCommands": [ + { + "text": "-target-select remote host.docker.internal:3333", + "description": "connect to target", + "ignoreFailures": false + }, + { + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", + "description": "load file", "ignoreFailures": false }, { @@ -143,7 +185,18 @@ "description": "flash target", "ignoreFailures": false } - ] + ], + "logging": { + "moduleLoad": true, + "trace": true, + "engineLogging": true, + "programOutput": true, + "exceptions": true + }, + "linux": { + "MIMode": "gdb", + "MIDebuggerPath": "arm-none-eabi-gdb" + } } ], "inputs": [ From cf84265ce5cad242f4ab5b04b74121de605f76d2 Mon Sep 17 00:00:00 2001 From: Lukasz Gniadzik Date: Tue, 2 Mar 2021 00:09:11 +0100 Subject: [PATCH 6/7] Split shell mbed 'local' debug task. It looks like splitting 'local' debug task into two, separated tasks with fixed hardware targets, may be more convenient from user perspective. Unfortunately vscode doesn't support nested variable substitution, as well as map/dictionary data stractures inside its .json files. For that reason there is no easy way to get 'local' debug task working with automatic HW target detection. --- .vscode/launch.json | 88 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 15 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 8c8393c735451d..165e6d9966fdb9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -85,7 +85,7 @@ ] }, { - "name": "Shell Mbed Example Debug [local]", + "name": "Shell Mbed Example Debug [remote]", "type": "cppdbg", "request": "launch", "program": "${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", @@ -99,6 +99,62 @@ "filterStderr": true, "filterStdout": false, "serverStarted": "GDB\\ server\\ started", + "setupCommands": [ + { + "text": "-target-select remote host.docker.internal:3333", + "description": "connect to target", + "ignoreFailures": false + }, + { + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", + "description": "load file", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor reset\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor halt\"", + "ignoreFailures": false + }, + { + "text": "-interpreter-exec console \"monitor arm semihosting enable\"", + "ignoreFailures": false + }, + { + "text": "-target-download", + "description": "flash target", + "ignoreFailures": false + } + ], + "logging": { + "moduleLoad": true, + "trace": true, + "engineLogging": true, + "programOutput": true, + "exceptions": true + }, + "linux": { + "MIMode": "gdb", + "MIDebuggerPath": "arm-none-eabi-gdb" + } + }, + { + "name": "Shell Mbed Example Debug [local: nrf52840]", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/chip-mbed-shell-example", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceRoot}/examples/shell/mbed", + "environment": [], + "externalConsole": false, + "debugServerArgs": "", + "serverLaunchTimeout": 20000, + "filterStderr": true, + "filterStdout": false, + "serverStarted": "GDB\\ server\\ started", "logging": { "moduleLoad": true, "trace": true, @@ -113,7 +169,7 @@ "ignoreFailures": false }, { - "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/chip-mbed-shell-example", "description": "load file", "ignoreFailures": false }, @@ -139,14 +195,14 @@ "MIMode": "gdb", "MIDebuggerPath": "arm-none-eabi-gdb", "debugServerPath": "pyocd-gdbserver", - "debugServerArgs": "" // [-t ] + "debugServerArgs": "-t nrf52840" } }, { - "name": "Shell Mbed Example Debug [remote]", + "name": "Shell Mbed Example Debug [local: stm32l475xg]", "type": "cppdbg", "request": "launch", - "program": "${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", + "program": "${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/chip-mbed-shell-example", "args": [], "stopAtEntry": true, "cwd": "${workspaceRoot}/examples/shell/mbed", @@ -157,14 +213,21 @@ "filterStderr": true, "filterStdout": false, "serverStarted": "GDB\\ server\\ started", + "logging": { + "moduleLoad": true, + "trace": true, + "engineLogging": true, + "programOutput": true, + "exceptions": true + }, "setupCommands": [ { - "text": "-target-select remote host.docker.internal:3333", + "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false }, { - "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/chip-mbed-shell-example", "description": "load file", "ignoreFailures": false }, @@ -186,16 +249,11 @@ "ignoreFailures": false } ], - "logging": { - "moduleLoad": true, - "trace": true, - "engineLogging": true, - "programOutput": true, - "exceptions": true - }, "linux": { "MIMode": "gdb", - "MIDebuggerPath": "arm-none-eabi-gdb" + "MIDebuggerPath": "arm-none-eabi-gdb", + "debugServerPath": "pyocd-gdbserver", + "debugServerArgs": "-t stm32l475xg" } } ], From 2e55ecefddc1d946e34c39781829f3dffe6aad53 Mon Sep 17 00:00:00 2001 From: Lukasz Gniadzik Date: Tue, 2 Mar 2021 02:10:12 +0100 Subject: [PATCH 7/7] Update mbed vscode tasks to work with mbed profiles. After switching to Mbed 6.7.0 and mbed-tools 7.1.2 it is possible to have separeted build directory depending on mbed application profile during compilation. This change improves flash and debug vscode mbed tasks to use this feature. Change set: - add option to select profile for flash task - add option to select mbed profile for debug task - update mbed_example_utils.sh to search for app binary depanding on selected profile. --- .vscode/launch.json | 19 +++++++++++++------ .vscode/tasks.json | 8 ++++++-- scripts/examples/mbed_example_utils.sh | 13 ++++++++++++- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 165e6d9966fdb9..425c518c2f09b6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -88,7 +88,7 @@ "name": "Shell Mbed Example Debug [remote]", "type": "cppdbg", "request": "launch", - "program": "${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", + "program": "${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/${input:mbedProfile}/chip-mbed-shell-example", "args": [], "stopAtEntry": true, "cwd": "${workspaceRoot}/examples/shell/mbed", @@ -106,7 +106,7 @@ "ignoreFailures": false }, { - "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/chip-mbed-shell-example", + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-${input:mbedTarget}/${input:mbedProfile}/chip-mbed-shell-example", "description": "load file", "ignoreFailures": false }, @@ -144,7 +144,7 @@ "name": "Shell Mbed Example Debug [local: nrf52840]", "type": "cppdbg", "request": "launch", - "program": "${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/chip-mbed-shell-example", + "program": "${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/${input:mbedProfile}/chip-mbed-shell-example", "args": [], "stopAtEntry": true, "cwd": "${workspaceRoot}/examples/shell/mbed", @@ -169,7 +169,7 @@ "ignoreFailures": false }, { - "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/chip-mbed-shell-example", + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-NRF52840_DK/${input:mbedProfile}/chip-mbed-shell-example", "description": "load file", "ignoreFailures": false }, @@ -202,7 +202,7 @@ "name": "Shell Mbed Example Debug [local: stm32l475xg]", "type": "cppdbg", "request": "launch", - "program": "${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/chip-mbed-shell-example", + "program": "${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/${input:mbedProfile}/chip-mbed-shell-example", "args": [], "stopAtEntry": true, "cwd": "${workspaceRoot}/examples/shell/mbed", @@ -227,7 +227,7 @@ "ignoreFailures": false }, { - "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/chip-mbed-shell-example", + "text": "-file-exec-and-symbols ${workspaceRoot}/examples/shell/mbed/build-DISCO_L475VG_IOT01A/${input:mbedProfile}/chip-mbed-shell-example", "description": "load file", "ignoreFailures": false }, @@ -264,6 +264,13 @@ "description": "What mbed target will be used?", "options": ["NRF52840_DK", "DISCO_L475VG_IOT01A"], "default": "NRF52840_DK" + }, + { + "type": "pickString", + "id": "mbedProfile", + "description": "What mbed profile do you want to use?", + "options": ["debug", "develop"], + "default": "develop" } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 81a5fc39736b20..f26e6e21f5ed49 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -254,7 +254,11 @@ "label": "Flash Mbed Shell Example", "type": "shell", "command": "scripts/examples/mbed_example_utils.sh", - "args": ["-a=shell", "-b=${input:mbedTarget}"], + "args": [ + "-a=shell", + "-b=${input:mbedTarget}", + "-p=${input:mbedProfile}" + ], "problemMatcher": [], "group": "build" } @@ -272,7 +276,7 @@ "id": "mbedProfile", "description": "What mbed profile do you want to use?", "options": ["release", "debug", "develop"], - "default": "debug" + "default": "develop" } ] } diff --git a/scripts/examples/mbed_example_utils.sh b/scripts/examples/mbed_example_utils.sh index bd6963c87d832f..d5f1c0317ed1af 100755 --- a/scripts/examples/mbed_example_utils.sh +++ b/scripts/examples/mbed_example_utils.sh @@ -20,10 +20,12 @@ cd "$(dirname "$0")/../../examples" SUPPORTED_TARGET_BOARD=(DISCO_L475VG_IOT01A NRF52840_DK) SUPPORTED_APP=(shell) +SUPPORTED_PROFILES=(release develop debug) APP= TARGET_BOARD= PYOCD_TARGET= +PROFILE= for i in "$@"; do case $i in @@ -35,6 +37,10 @@ for i in "$@"; do TARGET_BOARD="${i#*=}" shift ;; + -p=* | --profile=*) + PROFILE="${i#*=}" + shift + ;; *) # unknown option ;; @@ -65,6 +71,11 @@ if [[ ! " ${SUPPORTED_APP[@]} " =~ " ${APP} " ]]; then exit 1 fi +if [[ ! " ${SUPPORTED_PROFILES[@]} " =~ " ${PROFILE} " ]]; then + echo "ERROR: Profile $PROFILE not supported" + exit 1 +fi + echo "############################" -pyocd flash -t $PYOCD_TARGET $PWD/$APP/mbed/build-$TARGET_BOARD/chip-mbed-$APP-example.hex +pyocd flash -t $PYOCD_TARGET $PWD/$APP/mbed/build-$TARGET_BOARD/$PROFILE/chip-mbed-$APP-example.hex echo "############################"