From 668121bb864d3701b6186102eff416e06b899f38 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 15 Nov 2023 16:09:34 +0100 Subject: [PATCH 1/2] 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. --- commands/debug/debug_info.go | 9 ++++++++- docs/UPGRADING.md | 4 ++-- rpc/cc/arduino/cli/commands/v1/debug.pb.go | 2 +- rpc/cc/arduino/cli/commands/v1/debug.proto | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/commands/debug/debug_info.go b/commands/debug/debug_info.go index deccd59b89c..ec254e8912e 100644 --- a/commands/debug/debug_info.go +++ b/commands/debug/debug_info.go @@ -169,6 +169,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) @@ -181,7 +188,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(), diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 30cf55a9e42..b1f9dc1ec25 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -282,7 +282,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": { @@ -2514,7 +2514,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/ diff --git a/rpc/cc/arduino/cli/commands/v1/debug.pb.go b/rpc/cc/arduino/cli/commands/v1/debug.pb.go index d77de884b49..fa8c52bed21 100644 --- a/rpc/cc/arduino/cli/commands/v1/debug.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/debug.pb.go @@ -284,7 +284,7 @@ type GetDebugConfigResponse struct { Toolchain string `protobuf:"bytes,2,opt,name=toolchain,proto3" json:"toolchain,omitempty"` // The toolchain directory ToolchainPath string `protobuf:"bytes,3,opt,name=toolchain_path,json=toolchainPath,proto3" json:"toolchain_path,omitempty"` - // The toolchain architecture prefix (for example "arm-none-eabi-") + // The toolchain architecture prefix (for example "arm-none-eabi") ToolchainPrefix string `protobuf:"bytes,4,opt,name=toolchain_prefix,json=toolchainPrefix,proto3" json:"toolchain_prefix,omitempty"` // The GDB server type used to connect to the programmer/board (for example // "openocd") diff --git a/rpc/cc/arduino/cli/commands/v1/debug.proto b/rpc/cc/arduino/cli/commands/v1/debug.proto index 1b1f8441497..9e8341edb54 100644 --- a/rpc/cc/arduino/cli/commands/v1/debug.proto +++ b/rpc/cc/arduino/cli/commands/v1/debug.proto @@ -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") From 9e0443b48de2a9b37a01f5a6a17b18f98690ec5d Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 15 Nov 2023 16:27:00 +0100 Subject: [PATCH 2/2] Fixed debug command --- commands/debug/debug.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/debug/debug.go b/commands/debug/debug.go index f3faaaacfaf..f3dee2d51d1 100644 --- a/commands/debug/debug.go +++ b/commands/debug/debug.go @@ -130,7 +130,7 @@ func getCommandLine(req *rpc.GetDebugConfigRequest, pme *packagemanager.Explorer var gdbPath *paths.Path switch debugInfo.GetToolchain() { case "gcc": - gdbexecutable := debugInfo.GetToolchainPrefix() + "gdb" + gdbexecutable := debugInfo.GetToolchainPrefix() + "-gdb" if runtime.GOOS == "windows" { gdbexecutable += ".exe" }