Skip to content

Commit

Permalink
[Tizen] VSCode debug support (#19043)
Browse files Browse the repository at this point in the history
* Add readline libraries required by chip-tool

* Add support for debugging on Tizen target device

* Add missing dependencies to build LightingApp on tizen

* Add options to tizen-gdbserver script

* Automatically find connected tizen device

* Add support for devices connected via USB

* Add extension to run shell task

* Print device name in select target popup

* Describe vscode support

Co-authored-by: Arkadiusz Bokowy <a.bokowy@samsung.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
3 people authored Jun 16, 2022
1 parent 1e3f120 commit 71a9760
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 23 deletions.
5 changes: 4 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ RUN apt-get -fy install git vim emacs sudo \
wget curl telnet \
docker.io \
iputils-ping net-tools \
libncurses5
libncurses5 \
libpython2.7

RUN groupadd -g $USER_GID $USERNAME
RUN useradd -s /bin/bash -u $USER_UID -g $USER_GID -G docker -m $USERNAME
Expand Down Expand Up @@ -83,3 +84,5 @@ RUN sed -i '/^TIZEN_SDK_DATA_PATH/d' $TIZEN_SDK_ROOT/sdk.info \
&& echo TIZEN_SDK_DATA_PATH=/home/$USERNAME/tizen-sdk-data >> $TIZEN_SDK_ROOT/sdk.info \
&& ln -sf /home/$USERNAME/.tizen-cli-config $TIZEN_SDK_ROOT/tools/.tizen-cli-config \
&& : # last line

ENV TIZEN_ROOTFS /tizen_rootfs
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"aaron-bond.better-comments",
"augustocdias.tasks-shell-input",
"christian-kohler.path-intellisense",
"eamodio.gitlens",
"editorconfig.editorconfig",
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"aaron-bond.better-comments",
"augustocdias.tasks-shell-input",
"christian-kohler.path-intellisense",
"eamodio.gitlens",
"editorconfig.editorconfig",
Expand Down
33 changes: 33 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,39 @@
}
]
},
{
"name": "LightingApp (Tizen) [remote]",
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceFolder}/out/tizen-arm-light",
"program": "${workspaceFolder}/out/tizen-arm-light/chip-lighting-app",
"miDebuggerPath": "${env:TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-9.2/bin/arm-linux-gnueabi-gdb",
"additionalSOLibSearchPath": "${env:TIZEN_ROOTFS}",
"preLaunchTask": "Launch LightingApp with gdbserver attached (Tizen)",
"miDebuggerServerAddress": "localhost:9999",
"linux": {
"MIMode": "gdb"
},
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"text": "set solib-absolute-prefix ${env:TIZEN_ROOTFS}"
},
{
"text": "set sysroot ${env:TIZEN_SDK_SYSROOT}"
},
{
"text": "set debug-file-directory {env:TIZEN_SDK_SYSROOT}/usr/lib/debug"
},
{
"text": "set solib-search-path ${workspaceFolder}/out/tizen-arm-light"
}
]
},

{
"name": "Debug Mbed examples",
Expand Down
77 changes: 77 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,68 @@
"problemMatcher": {
"base": "$gcc"
}
},
{
"label": "Build LightingApp (Tizen)",
"type": "shell",
"command": "scripts/run_in_build_env.sh",
"args": [
"${workspaceFolder}/scripts/build/build_examples.py --target tizen-arm-light --enable-flashbundle build"
],
"group": "build",
"problemMatcher": {
"base": "$gcc"
}
},
{
"label": "Connect to device (Tizen)",
"type": "shell",
"command": "sdb",
"args": ["connect", "${input:tizenTargetDeviceAddress}"],
"problemMatcher": [],
"runOptions": {
"reevaluateOnRerun": false
}
},
{
"label": "Install LightingApp (Tizen)",
"type": "shell",
"command": "sdb",
"args": [
"-s",
"${input:tizenTargetDeviceAddressSdb}",
"install",
"${workspaceFolder}/out/tizen-arm-light/package/out/org.tizen.matter.example.lighting-1.0.0.tpk"
],
"problemMatcher": [],
"runOptions": {
"reevaluateOnRerun": false
}
},
{
"label": "Launch LightingApp with gdbserver attached (Tizen)",
"type": "shell",
"command": "bash",
"args": [
"${workspaceFolder}/scripts/helpers/tizen_gdbserver_run.sh",
"--app-name",
"org.tizen.matter.example.lighting",
"--target",
"${input:tizenTargetDeviceAddressSdb}"
],
"problemMatcher": [],
"runOptions": {
"reevaluateOnRerun": false
},
"isBackground": false,
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true,
"clear": true
}
}
],
"inputs": [
Expand Down Expand Up @@ -377,6 +439,21 @@
"telink-tlsr9518adk80d-light-switch",
"tizen-arm-light"
]
},
{
"type": "promptString",
"id": "tizenTargetDeviceAddress",
"description": "Enter the target device address and port in format <address>:<port>"
},
{
"id": "tizenTargetDeviceAddressSdb",
"type": "command",
"command": "shellCommand.execute",
"args": {
"command": "sdb devices | grep -v 'List of devices attached' |awk '{print $1 \"|\" $1, $3, \"(\" $2 \")\"}'",
"fieldSeparator": "|",
"description": "Select target device"
}
}
]
}
79 changes: 63 additions & 16 deletions examples/lighting-app/tizen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Generating tizen-arm-light

```sh
gn gen --check \
--fail-on-unused-args \
--export-compile-commands \
--root=$PW_PROJECT_ROOT/examples/lighting-app/tizen \
"--args=target_os=\"tizen\" target_cpu=\"arm\" tizen_sdk_root=\"$TIZEN_SDK_ROOT\" tizen_sdk_sysroot=\"$TIZEN_SDK_SYSROOT\"" \
$PW_PROJECT_ROOT/out/tizen-arm-light
--fail-on-unused-args \
--export-compile-commands \
--root=$PW_PROJECT_ROOT/examples/lighting-app/tizen \
"--args=target_os=\"tizen\" target_cpu=\"arm\" tizen_sdk_root=\"$TIZEN_SDK_ROOT\" tizen_sdk_sysroot=\"$TIZEN_SDK_SYSROOT\"" \
$PW_PROJECT_ROOT/out/tizen-arm-light
```

Building tizen-arm-light
Expand All @@ -33,16 +33,16 @@ author data as needed.

```sh
$TIZEN_SDK_ROOT/tools/ide/bin/tizen certificate \
--alias=CHIP \
--name=CHIP \
--email=chip@tizen.org \
--password=chiptizen
--alias=CHIP \
--name=CHIP \
--email=chip@tizen.org \
--password=chiptizen

$TIZEN_SDK_ROOT/tools/ide/bin/tizen security-profiles add \
--active \
--name=CHIP \
--author=$HOME/tizen-sdk-data/keystore/author/author.p12 \
--password=chiptizen
--active \
--name=CHIP \
--author=$HOME/tizen-sdk-data/keystore/author/author.p12 \
--password=chiptizen
```

This is only _one-time action_. To regenerate the author certificate and
Expand All @@ -51,9 +51,9 @@ specified commands:

```sh
rm -r \
$HOME/tizen-sdk-data \
$HOME/.tizen-cli-config \
$HOME/.secretsdb
$HOME/tizen-sdk-data \
$HOME/.tizen-cli-config \
$HOME/.secretsdb
```

After that, normally call scripts to generate the author certificate and
Expand Down Expand Up @@ -97,3 +97,50 @@ e.g.:
```sh
app_launcher --start=org.tizen.matter.example.lighting discriminator 43 wifi true
```

## Vscode support

To run all commands below `sdb` has to be installed on computer and available in
`PATH`. Also vscode has to have the `augustocdias.tasks-shell-input` extension
installed.

### Tasks

1. Build app:

```
open the Command Palette (Ctrl+Shift+P) ->
Tasks: Run Task ->
Build LightingApp (Tizen)
```

2. SDB connect to device: required to run Tizen commands below if device is
debugged over network

```
open the Command Palette (Ctrl+Shift+P) ->
Tasks: Run Task -> Connect to device (Tizen) ->
insert IP address and port
```

3. Install app: it is separated from build app step.

```
open the Command Palette (Ctrl+Shift+P) ->
Tasks: Run Task ->
Install LightingApp (Tizen)
```

4. Launch LightingApp with gdbserver attached: require to install app
previously.

```
open the Command Palette (Ctrl+Shift+P) ->
Tasks: Run Task ->
Launch LightingApp with gdbserver attached (Tizen)
```

### Debug

To debug app using vscode gdbserver has to be available on the target device,
run `./scripts/helpers/tizen_gdbserver_run.sh --help` for more information.
15 changes: 10 additions & 5 deletions integrations/docker/images/chip-build-tizen/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ RUN set -x \
http://download.tizen.org/sdk/tizenstudio/official/binary/certificate-generator_0.1.3_ubuntu-64.zip \
http://download.tizen.org/sdk/tizenstudio/official/binary/new-common-cli_2.5.7_ubuntu-64.zip \
http://download.tizen.org/sdk/tizenstudio/official/binary/new-native-cli_2.5.7_ubuntu-64.zip \
http://download.tizen.org/sdk/tizenstudio/official/binary/sdb_4.2.23_ubuntu-64.zip \
# Install tizen studio CLI
&& unzip -o '*.zip' \
&& cp -rf data/* $TIZEN_SDK_ROOT \
Expand All @@ -56,7 +57,7 @@ RUN set -x \

COPY secret-tool.py $TIZEN_SDK_ROOT/tools/certificate-encryptor/secret-tool
RUN chmod 0755 $TIZEN_SDK_ROOT/tools/certificate-encryptor/secret-tool
ENV PATH="$TIZEN_SDK_ROOT/tools/ide/bin:$PATH"
ENV PATH="$TIZEN_SDK_ROOT/tools/ide/bin:$TIZEN_SDK_ROOT/tools:$PATH"

# ------------------------------------------------------------------------------
# Get toolchain
Expand Down Expand Up @@ -94,8 +95,11 @@ RUN set -x \
-A 'libffi-devel-*.armv7l.rpm' \
-A 'liblzma-*.armv7l.rpm' \
-A 'libmount-devel-*.armv7l.rpm' \
-A 'libncurses6-*.armv7l.rpm' \
-A 'libreadline-*.armv7l.rpm' \
-A 'libuuid-*.armv7l.rpm' \
-A 'pcre-devel-*.armv7l.rpm' \
-A 'readline-devel-*.armv7l.rpm' \
-A 'xdgmime-*.armv7l.rpm' \
# Unified packages
&& wget --progress=dot:mega -r -nd --no-parent \
Expand All @@ -115,6 +119,7 @@ RUN set -x \
-A 'libcynara-commons-*.armv7l.rpm' \
-A 'libdns_sd-*.armv7l.rpm' \
-A 'libjson-glib-*.armv7l.rpm' \
-A 'libsessiond-0*.armv7l.rpm' \
-A 'libsystemd-*.armv7l.rpm' \
-A 'libtzplatform-config-*.armv7l.rpm' \
-A 'parcel-0*.armv7l.rpm' \
Expand All @@ -134,10 +139,10 @@ RUN set -x \
# Install packages
&& unrpm *.rpm \
&& cp -rf lib usr $TIZEN_SDK_SYSROOT \
# Fix some symbolic links
&& ln -sf libcap.so.2 $TIZEN_SDK_SYSROOT/usr/lib/libcap.so \
&& ln -sf libdns_sd.so.878.70.2 $TIZEN_SDK_SYSROOT/usr/lib/libdns_sd.so \
&& ln -sf libdns_sd.so.878.70.2 $TIZEN_SDK_SYSROOT/usr/lib/libdns_sd.so.878 \
# Make symbolic links relative
&& for LNK in $(find $TIZEN_SDK_SYSROOT/usr/lib -maxdepth 1 -type l); \
do ln -sf $(basename $(readlink "$LNK")) "$LNK" ; done \
&& ln -sf ../../lib/libcap.so.2 $TIZEN_SDK_SYSROOT/usr/lib/libcap.so \
&& ln -sf openssl1.1.pc $TIZEN_SDK_SYSROOT/usr/lib/pkgconfig/openssl.pc \
# Cleanup
&& rm -rf /tmp/workdir \
Expand Down
2 changes: 1 addition & 1 deletion integrations/docker/images/chip-build/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.79 Version bump reason: [Ameba] Update ameba SDK to expose xPortResetHeapMinimumEverFreeHeapSize API
0.5.80 Version bump reason: [Tizen] Add vscode debug support
Loading

0 comments on commit 71a9760

Please sign in to comment.