Skip to content

Commit c3d53ad

Browse files
committed
add support for jlink as transport for openocd
though menu selection does not seem to work with debug script. Though this is probably IDE issue.
1 parent c9e285c commit c3d53ad

File tree

9 files changed

+224
-49
lines changed

9 files changed

+224
-49
lines changed

boards.txt

Lines changed: 161 additions & 32 deletions
Large diffs are not rendered by default.

platform.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,23 @@ tools.openocd.cmd.windows=bin/openocd.exe
179179

180180
tools.openocd.upload.params.verbose=-d2
181181
tools.openocd.upload.params.quiet=-d0
182-
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
182+
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
183183

184184
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
185185
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
186186

187187
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
188188
tools.openocd.program.params.verbose=-d2
189189
tools.openocd.program.params.quiet=-d0
190-
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
190+
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
191191

192192
tools.openocd.erase.params.verbose=-d3
193193
tools.openocd.erase.params.quiet=-d0
194194
tools.openocd.erase.pattern=
195195

196196
tools.openocd.bootloader.params.verbose=-d2
197197
tools.openocd.bootloader.params.quiet=-d0
198-
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
198+
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
199199

200200
#
201201
# OpenOCD sketch upload - version with configurable bootloader size
@@ -208,20 +208,20 @@ tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
208208

209209
tools.openocd-withbootsize.upload.params.verbose=-d2
210210
tools.openocd-withbootsize.upload.params.quiet=-d0
211-
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
211+
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
212212

213213
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
214214
tools.openocd-withbootsize.program.params.verbose=-d2
215215
tools.openocd-withbootsize.program.params.quiet=-d0
216-
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
216+
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
217217

218218
tools.openocd-withbootsize.erase.params.verbose=-d3
219219
tools.openocd-withbootsize.erase.params.quiet=-d0
220220
tools.openocd-withbootsize.erase.pattern=
221221

222222
tools.openocd-withbootsize.bootloader.params.verbose=-d2
223223
tools.openocd-withbootsize.bootloader.params.quiet=-d0
224-
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
224+
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
225225

226226
# ----------------------------------------
227227
# Debugger configuration (general options)
@@ -232,13 +232,17 @@ debug.executable={build.path}/{build.project_name}.elf
232232
debug.toolchain=gcc
233233
debug.toolchain.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
234234
debug.toolchain.prefix=arm-none-eabi-
235+
235236
debug.server=openocd
236237
debug.server.openocd.path={runtime.tools.openocd.path}/bin/openocd
237238
debug.server.openocd.scripts_dir={runtime.tools.openocd.path}/share/openocd/scripts/
238239
debug.server.openocd.script={runtime.platform.path}/{build.openocdscript}
239240

240-
# jlink is not supported by arduino-cli yet, but supported by IDE
241+
# JLinkServer is not supported by arduino-cli yet
242+
# https://github.com/arduino/arduino-cli/blob/eca9d9a8f00582a08fadea8a4b7e3ef01b40d082/commands/debug/debug.go#L160
243+
# use debug_custom.json to run JLinkGDBServer instead
244+
# https://docs.arduino.cc/tutorials/mkr-wifi-1010/mkr-jlink-setup
241245
#debug.server=jlink
242-
#debug.server.jlink.path={runtime.tools.openocd.path}/bin/openocd
243-
#debug.server.jlink.scripts_dir={runtime.tools.openocd.path}/share/openocd/scripts/
246+
#debug.server.jlink.path=JLinkGDBServer
247+
#debug.server.jlink.device=ATSAMD21G18
244248
#debug.server.jlink.script={runtime.platform.path}/{build.openocdscript}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"servertype": "jlink",
3+
"device": "ATSAMD21G18A",
4+
"interface": "SWD",
5+
"serverpath": "JLinkGDBServer"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"servertype": "jlink",
3+
"device": "ATSAMD51G18",
4+
"interface": "SWD",
5+
"serverpath": "JLinkGDBServer"
6+
}
File renamed without changes.

scripts/openocd/same5x.cfg renamed to scripts/openocd/daplink_samd51.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ source [find interface/cmsis-dap.cfg]
2222
transport select swd
2323

2424
# chip name
25-
set CHIPNAME same51
25+
set CHIPNAME samd51
2626

2727
source [find target/atsame5x.cfg]

scripts/openocd/jlink_samd21.cfg

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Arduino Zero OpenOCD script.
3+
#
4+
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
5+
#
6+
# This library is free software; you can redistribute it and/or
7+
# modify it under the terms of the GNU Lesser General Public
8+
# License as published by the Free Software Foundation; either
9+
# version 2.1 of the License, or (at your option) any later version.
10+
#
11+
# This library is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
# See the GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public
17+
# License along with this library; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
#
20+
21+
source [find interface/jlink.cfg]
22+
transport select swd
23+
24+
# chip name
25+
set CHIPNAME samd21
26+
27+
source [find target/at91samdXX.cfg]

scripts/openocd/samd5x.cfg renamed to scripts/openocd/jlink_samd51.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
#
2020

21-
source [find interface/cmsis-dap.cfg]
22-
#source [find interface/jlink.cfg]
21+
source [find interface/jlink.cfg]
2322
transport select swd
2423

2524
# chip name

tools/makeboards.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
'build_mcu': 'cortex-m0plus',
2626
'f_cpu': '48000000L',
2727
'extra_flags': '-DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS',
28-
'openocdscript': 'scripts/openocd/samd2x.cfg',
2928
},
3029

3130
'SAMD51': {
@@ -35,7 +34,6 @@
3534
'build_mcu': 'cortex-m4',
3635
'f_cpu': '120000000L',
3736
'extra_flags': '-D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16',
38-
'openocdscript': 'scripts/openocd/samd5x.cfg',
3937
},
4038

4139
'SAME51': {
@@ -45,8 +43,7 @@
4543
'build_mcu': 'cortex-m4',
4644
'f_cpu': '120000000L',
4745
'extra_flags': '-D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16',
48-
'openocdscript': 'scripts/openocd/same5x.cfg',
49-
},
46+
},
5047
}
5148

5249

@@ -106,7 +103,6 @@ def build_build(mcu, name, variant, vendor, product, vid, pid_list, boarddefine,
106103
print(f"{name}.build.extra_flags={extra_flags} {mcu_properties['extra_flags']} {{build.usb_flags}}")
107104

108105
print(f"{name}.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld")
109-
print(f"{name}.build.openocdscript={mcu_properties['openocdscript']}")
110106
print(f"{name}.build.variant={variant}")
111107
print(f"{name}.build.variant_system_lib=")
112108
print(f"{name}.build.vid={vid}")
@@ -171,6 +167,13 @@ def build_menu(mcu, name):
171167
print(f"{name}.menu.debug.on.build.flags.debug=-g")
172168
print()
173169

170+
print("# Menu: Debugger")
171+
script_mcu = 'samd21' if mcu == 'SAMD21' else 'samd51'
172+
print(f"{name}.menu.debugger.daplink=CMSIS-DAP (DAPLink)")
173+
print(f"{name}.menu.debugger.daplink.build.openocdscript=scripts/openocd/daplink_{script_mcu}.cfg")
174+
print(f"{name}.menu.debugger.jlink=J-Link")
175+
print(f"{name}.menu.debugger.jlink.build.openocdscript=scripts/openocd/jlink_{script_mcu}.cfg")
176+
174177

175178
def build_global_menu():
176179
print("menu.cache=Cache")
@@ -179,6 +182,7 @@ def build_global_menu():
179182
print("menu.maxqspi=Max QSPI")
180183
print("menu.usbstack=USB Stack")
181184
print("menu.debug=Debug")
185+
print("menu.debugger=Debugger")
182186

183187

184188
def make_board(mcu, name, variant, vendor, product, vid, pid_list, boarddefine, extra_flags, bootloader):

0 commit comments

Comments
 (0)