Skip to content

Commit

Permalink
[skip-changelog] Added a compatibility trick in debug -I for `toolc…
Browse files Browse the repository at this point in the history
…hain.prefix` key (#2428)

* Added a compatibility trick in "debug -I" for toolchain.prefix key

The key was ignored in older versions of the Arduino IDE.
In the upcoming release (Arduino IDE 2.2.2) the key is used, but it was
wrongly set to "arm-none-eabi-" when we actually want "arm-none-eabi".

This patch ensure backward and forward compatibility.

* Fixed debug command
  • Loading branch information
cmaglie committed Nov 15, 2023
1 parent e5f2271 commit 2eba12e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion commands/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func getCommandLine(req *rpc.GetDebugConfigRequest, pme *packagemanager.Explorer
var gdbPath *paths.Path
switch debugInfo.GetToolchain() {
case "gcc":
gdbexecutable := debugInfo.ToolchainPrefix + "gdb"
gdbexecutable := debugInfo.ToolchainPrefix + "-gdb"
if runtime.GOOS == "windows" {
gdbexecutable += ".exe"
}
Expand Down
9 changes: 8 additions & 1 deletion commands/debug/debug_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl
}
}

// HOTFIX: for samd (and maybe some other platforms). We should keep this for a reasonable
// amount of time to allow seamless platforms update.
toolchainPrefix := debugProperties.Get("toolchain.prefix")
if toolchainPrefix == "arm-none-eabi-" {
toolchainPrefix = "arm-none-eabi"
}

customConfigs := map[string]string{}
if cortexDebugProps := debugProperties.SubTree("cortex-debug.custom"); cortexDebugProps.Size() > 0 {
customConfigs["cortex-debug"] = convertToJsonMap(cortexDebugProps)
Expand All @@ -196,7 +203,7 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl
SvdFile: debugProperties.Get("svd_file"),
Toolchain: toolchain,
ToolchainPath: debugProperties.Get("toolchain.path"),
ToolchainPrefix: debugProperties.Get("toolchain.prefix"),
ToolchainPrefix: toolchainPrefix,
ToolchainConfiguration: &toolchainConfiguration,
CustomConfigs: customConfigs,
Programmer: req.GetProgrammer(),
Expand Down
4 changes: 2 additions & 2 deletions docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The string field `server_configuration.script` is now an array and has been rena
"executable": "/tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/Blink.ino.elf",
"toolchain": "gcc",
"toolchain_path": "/home/user/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/",
"toolchain_prefix": "arm-none-eabi-",
"toolchain_prefix": "arm-none-eabi",
"server": "openocd",
"server_path": "/home/user/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/bin/openocd",
"server_configuration": {
Expand Down Expand Up @@ -2245,7 +2245,7 @@ Now:
debug.executable={build.path}/{build.project_name}.elf
debug.toolchain=gcc
debug.toolchain.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
debug.toolchain.prefix=arm-none-eabi-
debug.toolchain.prefix=arm-none-eabi
debug.server=openocd
debug.server.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}/bin/
debug.server.openocd.scripts_dir={runtime.tools.openocd-0.10.0-arduino7.path}/share/openocd/scripts/
Expand Down
2 changes: 1 addition & 1 deletion rpc/cc/arduino/cli/commands/v1/debug.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/cc/arduino/cli/commands/v1/debug.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ message GetDebugConfigResponse {
string toolchain = 2;
// The toolchain directory
string toolchain_path = 3;
// The toolchain architecture prefix (for example "arm-none-eabi-")
// The toolchain architecture prefix (for example "arm-none-eabi")
string toolchain_prefix = 4;
// The GDB server type used to connect to the programmer/board (for example
// "openocd")
Expand Down

0 comments on commit 2eba12e

Please sign in to comment.