Skip to content

Instantly share code, notes, and snippets.

@sago35
Last active September 14, 2024 11:05
Show Gist options
  • Save sago35/fd1b23d4ac9ac689ae84dee0be8c13b1 to your computer and use it in GitHub Desktop.
Save sago35/fd1b23d4ac9ac689ae84dee0be8c13b1 to your computer and use it in GitHub Desktop.
TinyGo + VSCode + Cortex-Debug for Wio Terminal (ATSAMD51P19A)
{
"version": "0.2.0",
"configurations": [
{
"type": "cortex-debug",
"servertype": "openocd",
"request": "launch",
"name": "tinygo-debug",
"runToEntryPoint": "main.main",
"executable": "${workspaceRoot}/out.elf",
"configFiles": [
"interface/cmsis-dap.cfg",
"target/atsame5x.cfg"
],
"preLaunchTask": "tinygo build task",
"cwd": "${workspaceRoot}",
"gdbpath": "C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-gdb.exe",
"svdFile": "${workspaceRoot}/lib/cmsis-svd/data/Atmel/ATSAMD51P19A.svd"
}
]
}
{
"version": "2.0.0",
"tasks": [
{
"label": "tinygo build task",
"type": "shell",
"command": "tinygo build -o out.elf -target wioterminal -size short -opt 1 ./src/examples/blinky1",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
@sago35
Copy link
Author

sago35 commented Feb 12, 2022

openocd + XIAO (cmsis-dap v2) + wioterminal (atsame5x) に対して VSCode + Cortex-Debug でデバッグを行う設定例。

.vscode/launch.json に上記を書いて置く。
out.elf は例えば以下のように作って書き込んでおく。

# 作成
$ tinygo build -o out.elf --target wioterminal --size short ./src/examples/blinky1

# 書き込み
$ tinygo flash --target wioterminal --size short ./src/examples/blinky1

@sago35
Copy link
Author

sago35 commented Feb 13, 2022

.vscode/tasks.jsontinygo build task というのを作っておいて、それを .vscode/launch.json 内の preLaunchTask に指定しておく。
この状態だと、 F5 を押すなどしてデバッグ開始すると、その直前に tasks.jsontinygo build task が動き tinygo build が実行される。

今の所 tinygo build の引数などは環境に合わせて設定が必要となり面倒ではあるが、それなりにうまく動きそう。

@sago35
Copy link
Author

sago35 commented Feb 13, 2022

あと、 launch.jsonsvdFile を足しておいた。
Cortex-Debug の CORTEX PERIPHERALS から各レジスタ値を見たりできる。

@sago35
Copy link
Author

sago35 commented Feb 13, 2022

以下のように動作します。
ただ、現状ではデバッグ対象のファイル (ビルドしなおすファイル) が決め打ちだったり等の制限はあります。

tinygo-with-cortex-debug

@sago35
Copy link
Author

sago35 commented Feb 13, 2022

テストで使っている環境はこちら。

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment