From db8bed0f5ab9600dac095e1d9647a185d684c222 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 17 Jan 2024 17:13:42 +0100 Subject: [PATCH 1/3] Update docs --- docs/sketch-project-file.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/sketch-project-file.md b/docs/sketch-project-file.md index 640ede7505e..90e78a4f170 100644 --- a/docs/sketch-project-file.md +++ b/docs/sketch-project-file.md @@ -10,6 +10,7 @@ multiple profiles. Each profile will define: - The board FQBN +- The programmer to use - The target core platform name and version (with the 3rd party platform index URL if needed) - A possible core platform name and version, that is a dependency of the target core platform (with the 3rd party platform index URL if needed) @@ -22,6 +23,7 @@ profiles: : notes: fqbn: + programmer: platforms: - platform: () platform_index_url: <3RD_PARTY_PLATFORM_URL> @@ -50,6 +52,7 @@ otherwise below). The available fields are: - `libraries:` is a section where the required libraries to build the project are defined. This section is optional. - `` is the version required for the library, for example, `1.0.0`. - `` is a free text string available to the developer to add comments. This field is optional. +- `` is the programmer that will be used. This field is optional. A complete example of a sketch project file may be the following: @@ -134,6 +137,7 @@ The sketch project file may be used to set the default value for some command li particular: - The `default_fqbn` key sets the default value for the `--fqbn` flag +- The `default_programmer` key sets the default value for the `--programmer` flag - The `default_port` key sets the default value for the `--port` flag - The `default_protocol` key sets the default value for the `--protocol` flag - The `default_profile` key sets the default value for the `--profile` flag @@ -141,12 +145,14 @@ particular: For example: ``` -default_fqbn: arduino:avr:uno +default_fqbn: arduino:samd:mkr1000 +default_programmer: atmel_ice default_port: /dev/ttyACM0 default_protocol: serial default_profile: myprofile ``` -With this configuration set, it is not necessary to specify the `--fqbn`, `--port`, `--protocol` or `--profile` flags to -the [`arduino-cli compile`](commands/arduino-cli_compile.md) or [`arduino-cli upload`](commands/arduino-cli_upload.md) -commands when compiling or uploading the sketch. +With this configuration set, it is not necessary to specify the `--fqbn`, `--programmer`, `--port`, `--protocol` or +`--profile` flags to the [`arduino-cli compile`](commands/arduino-cli_compile.md), +[`arduino-cli upload`](commands/arduino-cli_upload.md) or [`arduino-cli debug`](commands/arduino-cli_debug.md) commands +when compiling, uploading or debugging the sketch. From c3baa80fb74381dba169c4d2ebe92eb32eee8ab5 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Thu, 18 Jan 2024 15:43:51 +0100 Subject: [PATCH 2/3] Update TestBoardAttach to test that a programmer is correctly written to sketch.yaml --- internal/integrationtest/board/board_test.go | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/internal/integrationtest/board/board_test.go b/internal/integrationtest/board/board_test.go index df5f01ef048..977de95a989 100644 --- a/internal/integrationtest/board/board_test.go +++ b/internal/integrationtest/board/board_test.go @@ -550,7 +550,7 @@ func TestBoardAttach(t *testing.T) { sketchName := "BoardAttach" sketchPath := cli.SketchbookDir().Join(sketchName) - sketchProjectFlie := sketchPath.Join("sketch.yaml") + sketchProjectFile := sketchPath.Join("sketch.yaml") // Create a test sketch _, _, err := cli.Run("sketch", "new", sketchPath.String()) @@ -561,7 +561,7 @@ func TestBoardAttach(t *testing.T) { require.NoError(t, err) requirejson.Query(t, stdout, ".fqbn", `"arduino:avr:uno"`) - yamlData, err := sketchProjectFlie.ReadFile() + yamlData, err := sketchProjectFile.ReadFile() require.NoError(t, err) require.Contains(t, string(yamlData), "default_fqbn: arduino:avr:uno") require.NotContains(t, string(yamlData), "default_port:") @@ -574,7 +574,7 @@ func TestBoardAttach(t *testing.T) { requirejson.Query(t, stdout, ".port.address", `"/dev/ttyACM0"`) requirejson.Query(t, stdout, ".port.protocol", `"serial"`) - yamlData, err := sketchProjectFlie.ReadFile() + yamlData, err := sketchProjectFile.ReadFile() require.NoError(t, err) require.Contains(t, string(yamlData), "default_fqbn: arduino:avr:uno") require.Contains(t, string(yamlData), "default_port: /dev/ttyACM0") @@ -587,12 +587,27 @@ func TestBoardAttach(t *testing.T) { requirejson.Query(t, stdout, ".port.address", `"/dev/ttyACM0"`) requirejson.Query(t, stdout, ".port.protocol", `null`) - yamlData, err := sketchProjectFlie.ReadFile() + yamlData, err := sketchProjectFile.ReadFile() require.NoError(t, err) require.Contains(t, string(yamlData), "default_fqbn: arduino:avr:uno") require.Contains(t, string(yamlData), "default_port: /dev/ttyACM0") require.NotContains(t, string(yamlData), "default_protocol:") } + { + stdout, _, err := cli.Run("board", "attach", "-b", "arduino:samd:mkr1000", "-P", "atmel_ice", sketchPath.String(), "--format", "json") + require.NoError(t, err) + requirejson.Query(t, stdout, ".fqbn", `"arduino:samd:mkr1000"`) + requirejson.Query(t, stdout, ".programmer", `"atmel_ice"`) + requirejson.Query(t, stdout, ".port.address", `"/dev/ttyACM0"`) + requirejson.Query(t, stdout, ".port.protocol", `null`) + + yamlData, err := sketchProjectFile.ReadFile() + require.NoError(t, err) + require.Contains(t, string(yamlData), "default_fqbn: arduino:samd:mkr1000") + require.Contains(t, string(yamlData), "default_programmer: atmel_ice") + require.Contains(t, string(yamlData), "default_port: /dev/ttyACM0") + require.NotContains(t, string(yamlData), "default_protocol:") + } } func TestBoardListWithFailedBuiltinInstallation(t *testing.T) { From 1f368162bb326a261d9ec58765d39895158926a4 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 17 Jan 2024 15:58:29 +0100 Subject: [PATCH 3/3] Add TestDebugProfile to integration tests --- internal/integrationtest/debug/debug_test.go | 19 +++++++++++++++++++ .../testdata/sketch_with_profile/sketch.yaml | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/internal/integrationtest/debug/debug_test.go b/internal/integrationtest/debug/debug_test.go index 12d4c514e78..096fb6e7717 100644 --- a/internal/integrationtest/debug/debug_test.go +++ b/internal/integrationtest/debug/debug_test.go @@ -376,3 +376,22 @@ func testDebugCheck(t *testing.T, env *integrationtest.Environment, cli *integra require.NoError(t, err) requirejson.Contains(t, out, `{ "debugging_supported" : true, "debug_fqbn" : "my:samd:my6" }`) } + +func TestDebugProfile(t *testing.T) { + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) + defer env.CleanUp() + + // Init the environment explicitly + _, _, err := cli.Run("core", "update-index") + require.NoError(t, err) + + sketchPath := cli.CopySketch("sketch_with_profile") + + // Compile the sketch using the profile + _, _, err = cli.Run("compile", "--profile", "samd", sketchPath.String()) + require.NoError(t, err) + + // Debug using the profile + _, _, err = cli.Run("debug", "--profile", "samd", sketchPath.String(), "--info") + require.NoError(t, err) +} diff --git a/internal/integrationtest/testdata/sketch_with_profile/sketch.yaml b/internal/integrationtest/testdata/sketch_with_profile/sketch.yaml index ed40ce874f3..bc177c5023a 100644 --- a/internal/integrationtest/testdata/sketch_with_profile/sketch.yaml +++ b/internal/integrationtest/testdata/sketch_with_profile/sketch.yaml @@ -6,7 +6,16 @@ profiles: avr2: fqbn: arduino:avr:uno + programmer: atmel_ice platforms: - platform: arduino:avr (1.8.5) libraries: - Arduino_JSON (0.1.0) + + samd: + fqbn: arduino:samd:mkr1000 + programmer: atmel_ice + platforms: + - platform: arduino:samd (1.8.13) + libraries: + - Arduino_JSON (0.1.0)