From 2eba12e95abe7763742e15b51da7ff15e221aede Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 15 Nov 2023 17:42:48 +0100 Subject: [PATCH] [skip-changelog] Added a compatibility trick in `debug -I` for `toolchain.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 --- commands/debug/debug.go | 2 +- 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 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/commands/debug/debug.go b/commands/debug/debug.go index ab55e317508..d4a822d59f1 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.ToolchainPrefix + "gdb" + gdbexecutable := debugInfo.ToolchainPrefix + "-gdb" if runtime.GOOS == "windows" { gdbexecutable += ".exe" } diff --git a/commands/debug/debug_info.go b/commands/debug/debug_info.go index 68727dc77bc..3dbbfd60992 100644 --- a/commands/debug/debug_info.go +++ b/commands/debug/debug_info.go @@ -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) @@ -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(), diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 537373e6d45..b624fa8711f 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -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": { @@ -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/ 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")