Skip to content

Commit 34be246

Browse files
authored
Drop support for MKR 1000 and MKR Vidor 4000 (#209)
1 parent d625838 commit 34be246

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+453
-2220
lines changed

.ecrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"Exclude": [
3-
"^indexes/download/testdata/module_firmware_index\\.json$",
3+
"^indexes/download/testdata/plugin_firmware_index\\.json$",
44
"^indexes/download/testdata/package_index\\.json$",
5-
"^indexes/firmwareindex/testdata/module_firmware_index\\.json$",
65
"^indexes/testdata/package_index\\.json$",
6+
"^indexes/firmwareindex/testdata/plugin_firmware_index\\.json$",
77
"^LICENSE\\.txt$",
88
"^poetry\\.lock$",
99
"^\\.licenses/",

.github/workflows/generate-index.yml

+2-23
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,13 @@ jobs:
3636
- name: Install Poetry
3737
run: pip install poetry
3838

39-
- name: Install Arduino CLI
40-
uses: arduino/setup-arduino-cli@v1
41-
42-
- name: Install platforms
43-
run: |
44-
arduino-cli core update-index -v
45-
arduino-cli version
46-
arduino-cli core install arduino:samd@${{ env.SAMD_V }} -v
47-
env:
48-
SAMD_V: 1.8.11
49-
5039
- name: Install dependencies
5140
run: |
5241
cd $GITHUB_WORKSPACE
5342
task poetry:install-deps
5443
5544
- name: Generate plugin firmware index
56-
run: poetry run ./generator.py -a $(which arduino-cli)
57-
58-
- name: Generate module firmware index
59-
run: poetry run ./generator.py -a $(which arduino-cli) --no-new
45+
run: poetry run ./generator.py
6046

6147
# fix `gpg: signing failed: Inappropriate ioctl for device`
6248
# https://github.com/keybase/keybase-issues/issues/2798
@@ -68,13 +54,6 @@ jobs:
6854
6955
# disable gpg pass prompt
7056
# https://stackoverflow.com/questions/49072403/suppress-the-passphrase-prompt-in-gpg-command
71-
- name: sign the module firmware index json
72-
run: |
73-
gpg \
74-
--pinentry-mode=loopback \
75-
--passphrase "${{ secrets.PASSPHRASE }}" \
76-
--output boards/module_firmware_index.json.sig \
77-
--detach-sign boards/module_firmware_index.json
7857

7958
- name: sign the plugin firmware index json
8059
run: |
@@ -85,7 +64,7 @@ jobs:
8564
--detach-sign boards/plugin_firmware_index.json
8665
8766
- name: create the gzip
88-
run: gzip --keep boards/module_firmware_index.json boards/plugin_firmware_index.json
67+
run: gzip --keep boards/plugin_firmware_index.json
8968

9069
- name: s3 sync
9170
run: |

.prettierignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
.vs/
55
.ionide/
66

7-
indexes/download/testdata/module_firmware_index.json
7+
indexes/download/testdata/plugin_firmware_index.json
88
indexes/download/testdata/package_index.json
9-
indexes/firmwareindex/testdata/module_firmware_index.json
9+
indexes/firmwareindex/testdata/plugin_firmware_index.json
1010
indexes/testdata/package_index.json
1111

1212
# Generated files

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Arduino Firmware Uploader
22

33
The Arduino Firmware Uploader is a tool made to update the firmware and/or add SSL certificates for any Arduino board
4-
equipped with WINC or NINA Wi-Fi module.
4+
equipped with ESP32-S3 or NINA Wi-Fi module.
55

66
[![Test Go status](https://github.com/arduino/arduino-fwuploader/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/arduino-fwuploader/actions/workflows/test-go-task.yml)
77
[![Codecov](https://codecov.io/gh/arduino/arduino-fwuploader/branch/main/graph/badge.svg)](https://codecov.io/gh/arduino/arduino-fwuploader)

cli/arguments/arguments.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ type Flags struct {
3131

3232
// AddToCommand adds the flags used to set address and fqbn to the specified Command
3333
func (f *Flags) AddToCommand(cmd *cobra.Command) {
34-
cmd.Flags().StringVarP(&f.Fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:samd:mkr1000, arduino:mbed_nano:nanorp2040connect")
34+
cmd.Flags().StringVarP(&f.Fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:samd:mkrwifi1010, arduino:mbed_nano:nanorp2040connect")
3535
cmd.Flags().StringVarP(&f.Address, "address", "a", "", "Upload port, e.g.: COM10, /dev/ttyACM0")
3636
}

cli/certificates/flash.go

+8-84
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,13 @@ import (
2424
"fmt"
2525
"io"
2626
"os"
27-
"strings"
28-
"time"
2927

3028
"github.com/arduino/arduino-fwuploader/certificates"
3129
"github.com/arduino/arduino-fwuploader/cli/arguments"
3230
"github.com/arduino/arduino-fwuploader/cli/common"
3331
"github.com/arduino/arduino-fwuploader/cli/feedback"
3432
"github.com/arduino/arduino-fwuploader/cli/globals"
3533
"github.com/arduino/arduino-fwuploader/flasher"
36-
"github.com/arduino/arduino-fwuploader/indexes/download"
37-
"github.com/arduino/arduino-fwuploader/indexes/firmwareindex"
3834
"github.com/arduino/arduino-fwuploader/plugin"
3935
"github.com/arduino/go-paths-helper"
4036
"github.com/sirupsen/logrus"
@@ -54,9 +50,9 @@ func NewFlashCommand() *cobra.Command {
5450
Short: "Flashes certificates to board.",
5551
Long: "Flashes specified certificates to board at specified address.",
5652
Example: "" +
57-
" " + os.Args[0] + " certificates flash --fqbn arduino:samd:mkr1000 --address COM10 --url arduino.cc:443 --file /home/me/Digicert.cer\n" +
58-
" " + os.Args[0] + " certificates flash -b arduino:samd:mkr1000 -a COM10 -u arduino.cc:443 -u google.com:443\n" +
59-
" " + os.Args[0] + " certificates flash -b arduino:samd:mkr1000 -a COM10 -f /home/me/VeriSign.cer -f /home/me/Digicert.cer\n",
53+
" " + os.Args[0] + " certificates flash --fqbn arduino:samd:mkrwifi1010 --address COM10 --url arduino.cc:443 --file /home/me/Digicert.cer\n" +
54+
" " + os.Args[0] + " certificates flash -b arduino:renesas_uno:unor4wifi -a COM10 -u arduino.cc:443 -u google.com:443\n" +
55+
" " + os.Args[0] + " certificates flash -b arduino:samd:mkrwifi1010 -a COM10 -f /home/me/VeriSign.cer -f /home/me/Digicert.cer\n",
6056
Args: cobra.NoArgs,
6157
Run: func(cmd *cobra.Command, args []string) {
6258
runFlash(certificateURLs, certificatePaths)
@@ -81,25 +77,19 @@ func runFlash(certificateURLs, certificatePaths []string) {
8177
board := common.GetBoard(firmwareIndex, commonFlags.Fqbn)
8278
uploadToolDir := common.DownloadRequiredToolsForBoard(packageIndex, board)
8379

84-
var res *flasher.FlashResult
85-
var flashErr error
86-
if !board.IsPlugin() {
87-
res, flashErr = flashCertificates(board, uploadToolDir, certificateURLs, certificatePaths)
88-
} else {
89-
uploader, err := plugin.NewFWUploaderPlugin(uploadToolDir)
90-
if err != nil {
91-
feedback.Fatal(fmt.Sprintf("Could not open uploader plugin: %s", err), feedback.ErrGeneric)
92-
}
93-
res, flashErr = flashCertificatesWithPlugin(uploader, certificateURLs, certificatePaths)
80+
uploader, err := plugin.NewFWUploaderPlugin(uploadToolDir)
81+
if err != nil {
82+
feedback.Fatal(fmt.Sprintf("Could not open uploader plugin: %s", err), feedback.ErrGeneric)
9483
}
9584

85+
res, flashErr := flashCertificates(uploader, certificateURLs, certificatePaths)
9686
feedback.PrintResult(res)
9787
if flashErr != nil {
9888
os.Exit(int(feedback.ErrGeneric))
9989
}
10090
}
10191

102-
func flashCertificatesWithPlugin(uploader *plugin.FwUploader, certificateURLs, certificatePaths []string) (*flasher.FlashResult, error) {
92+
func flashCertificates(uploader *plugin.FwUploader, certificateURLs, certificatePaths []string) (*flasher.FlashResult, error) {
10393
tmp, err := paths.MkTempDir("", "")
10494
if err != nil {
10595
return nil, err
@@ -161,69 +151,3 @@ func flashCertificatesWithPlugin(uploader *plugin.FwUploader, certificateURLs, c
161151
},
162152
}, err
163153
}
164-
165-
func flashCertificates(board *firmwareindex.IndexBoard, uploadToolDir *paths.Path, certificateURLs, certificatePaths []string) (*flasher.FlashResult, error) {
166-
loaderSketchPath, err := download.DownloadSketch(board.LoaderSketch)
167-
if err != nil {
168-
feedback.Fatal(fmt.Sprintf("Error downloading loader sketch from %s: %s", board.LoaderSketch.URL, err), feedback.ErrGeneric)
169-
}
170-
logrus.Debugf("loader sketch downloaded in %s", loaderSketchPath.String())
171-
172-
loaderSketch := strings.ReplaceAll(loaderSketchPath.String(), loaderSketchPath.Ext(), "")
173-
programmerOut, programmerErr, err := common.FlashSketch(board, loaderSketch, uploadToolDir, commonFlags.Address)
174-
if err != nil {
175-
feedback.FatalError(err, feedback.ErrGeneric)
176-
}
177-
178-
// Wait a bit after flashing the loader sketch for the board to become
179-
// available again.
180-
logrus.Debug("sleeping for 3 sec")
181-
time.Sleep(3 * time.Second)
182-
183-
// Get flasher depending on which module to use
184-
var f flasher.Flasher
185-
moduleName := board.Module
186-
187-
// This matches the baudrate used in the FirmwareUpdater.ino sketch
188-
// https://github.com/arduino-libraries/WiFiNINA/blob/master/examples/Tools/FirmwareUpdater/FirmwareUpdater.ino
189-
const baudRate = 1000000
190-
switch moduleName {
191-
case "NINA":
192-
// we use address and not bootloaderPort because the board should not be in bootloader mode
193-
f, err = flasher.NewNinaFlasher(commonFlags.Address, baudRate, 30)
194-
case "WINC1500":
195-
f, err = flasher.NewWincFlasher(commonFlags.Address, baudRate, 30)
196-
default:
197-
err = fmt.Errorf("unknown module: %s", moduleName)
198-
}
199-
if err != nil {
200-
feedback.Fatal(fmt.Sprintf("Error during certificates flashing: %s", err), feedback.ErrGeneric)
201-
}
202-
defer f.Close()
203-
204-
// now flash the certificate
205-
certFileList := paths.NewPathList(certificatePaths...)
206-
flasherOut := new(bytes.Buffer)
207-
flasherErr := new(bytes.Buffer)
208-
if feedback.GetFormat() == feedback.JSON {
209-
err = f.FlashCertificates(&certFileList, certificateURLs, flasherOut)
210-
if err != nil {
211-
flasherErr.Write([]byte(fmt.Sprintf("Error during certificates flashing: %s", err)))
212-
}
213-
} else {
214-
err = f.FlashCertificates(&certFileList, certificateURLs, io.MultiWriter(flasherOut, os.Stdout))
215-
if err != nil {
216-
os.Stderr.Write([]byte(fmt.Sprintf("Error during certificates flashing: %s", err)))
217-
}
218-
}
219-
return &flasher.FlashResult{
220-
Programmer: &flasher.ExecOutput{
221-
Stdout: programmerOut.String(),
222-
Stderr: programmerErr.String(),
223-
},
224-
Flasher: &flasher.ExecOutput{
225-
Stdout: flasherOut.String(),
226-
Stderr: flasherErr.String(),
227-
},
228-
}, err
229-
}

cli/common/common.go

+3-73
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,15 @@
1818
package common
1919

2020
import (
21-
"bytes"
2221
"fmt"
23-
"os"
24-
"path/filepath"
25-
"strings"
2622

2723
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
28-
"github.com/arduino/arduino-cli/arduino/serialutils"
2924
"github.com/arduino/arduino-fwuploader/cli/feedback"
3025
"github.com/arduino/arduino-fwuploader/cli/globals"
3126
"github.com/arduino/arduino-fwuploader/indexes"
3227
"github.com/arduino/arduino-fwuploader/indexes/download"
3328
"github.com/arduino/arduino-fwuploader/indexes/firmwareindex"
34-
programmer "github.com/arduino/arduino-fwuploader/programmers"
3529
"github.com/arduino/go-paths-helper"
36-
"github.com/arduino/go-properties-orderedmap"
3730
"github.com/sirupsen/logrus"
3831
)
3932

@@ -59,24 +52,19 @@ func InitIndexes() (*packagemanager.PackageManager, *firmwareindex.Index) {
5952
}
6053

6154
// Load main firmware index and optional additional indexes
62-
firmwareIndex, err := indexes.GetFirmwareIndex(globals.ModuleFirmwareIndexGZURL, true)
55+
pluginFirmwareIndex, err := indexes.GetFirmwareIndex(globals.PluginFirmwareIndexGZURL, true)
6356
if err != nil {
64-
feedback.Fatal(fmt.Sprintf("Can't load firmware index: %s", err), feedback.ErrGeneric)
65-
}
66-
if pluginIndex, err := indexes.GetFirmwareIndex(globals.PluginFirmwareIndexGZURL, true); err != nil {
6757
feedback.Fatal(fmt.Sprintf("Can't load (plugin) firmware index: %s", err), feedback.ErrGeneric)
68-
} else {
69-
firmwareIndex.MergeWith(pluginIndex)
7058
}
7159
for _, additionalURL := range AdditionalFirmwareIndexURLs {
7260
additionalIndex, err := indexes.GetFirmwareIndex(additionalURL, false)
7361
if err != nil {
7462
feedback.Fatal(fmt.Sprintf("Can't load firmware index: %s", err), feedback.ErrGeneric)
7563
}
76-
firmwareIndex.MergeWith(additionalIndex)
64+
pluginFirmwareIndex.MergeWith(additionalIndex)
7765
}
7866

79-
return pmbuilder.Build(), firmwareIndex
67+
return pmbuilder.Build(), pluginFirmwareIndex
8068
}
8169

8270
// CheckFlags runs a basic check, errors if the flags are not defined
@@ -105,11 +93,6 @@ func GetBoard(firmwareIndex *firmwareindex.Index, fqbn string) *firmwareindex.In
10593
// DownloadRequiredToolsForBoard is an helper function that downloads the correct tool to flash a board,
10694
// it returns the path of the downloaded tool
10795
func DownloadRequiredToolsForBoard(pm *packagemanager.PackageManager, board *firmwareindex.IndexBoard) *paths.Path {
108-
if !board.IsPlugin() {
109-
// Just download the upload tool for integrated uploaders
110-
return downloadTool(pm, board.Uploader)
111-
}
112-
11396
// Download the plugin
11497
toolDir := downloadTool(pm, board.UploaderPlugin)
11598

@@ -133,56 +116,3 @@ func downloadTool(pm *packagemanager.PackageManager, tool string) *paths.Path {
133116
logrus.Debugf("upload tool downloaded in %s", toolDir.String())
134117
return toolDir
135118
}
136-
137-
// FlashSketch is the business logic that handles the flashing procedure,
138-
// it returns using a buffer the stdout and the stderr of the programmer
139-
func FlashSketch(board *firmwareindex.IndexBoard, sketch string, uploadToolDir *paths.Path, address string) (programmerOut, programmerErr *bytes.Buffer, err error) {
140-
bootloaderPort, err := GetNewAddress(board, address)
141-
if err != nil {
142-
return nil, nil, err
143-
}
144-
145-
uploaderCommand := board.GetUploaderCommand()
146-
uploaderCommand = strings.ReplaceAll(uploaderCommand, "{tool_dir}", filepath.FromSlash(uploadToolDir.String()))
147-
uploaderCommand = strings.ReplaceAll(uploaderCommand, "{serial.port.file}", bootloaderPort)
148-
uploaderCommand = strings.ReplaceAll(uploaderCommand, "{loader.sketch}", sketch) // we leave that name here because it's only a template,
149-
150-
logrus.Debugf("uploading with command: %s", uploaderCommand)
151-
commandLine, err := properties.SplitQuotedString(uploaderCommand, "\"", false)
152-
if err != nil {
153-
feedback.Fatal(fmt.Sprintf(`Error splitting command line "%s": %s`, uploaderCommand, err), feedback.ErrGeneric)
154-
}
155-
156-
// Flash the actual sketch
157-
programmerOut = new(bytes.Buffer)
158-
programmerErr = new(bytes.Buffer)
159-
if feedback.GetFormat() == feedback.JSON {
160-
err = programmer.Flash(commandLine, programmerOut, programmerErr)
161-
} else {
162-
err = programmer.Flash(commandLine, os.Stdout, os.Stderr)
163-
}
164-
if err != nil {
165-
return nil, nil, fmt.Errorf("error during sketch flashing: %s", err)
166-
}
167-
return programmerOut, programmerErr, err
168-
}
169-
170-
// GetNewAddress is a function used to reset a board and put it in bootloader mode
171-
// it could happen that the board is assigned to a different serial port, after the reset,
172-
// this fuction handles also this possibility
173-
func GetNewAddress(board *firmwareindex.IndexBoard, oldAddress string) (string, error) {
174-
// Check if board needs a 1200bps touch for upload
175-
bootloaderPort := oldAddress
176-
if board.UploadTouch {
177-
logrus.Info("Putting board into bootloader mode")
178-
newUploadPort, err := serialutils.Reset(oldAddress, board.UploadWait, nil, false)
179-
if err != nil {
180-
return "", fmt.Errorf("error during sketch flashing: missing board address. %s", err)
181-
}
182-
if newUploadPort != "" {
183-
logrus.Infof("Found port to upload: %s", newUploadPort)
184-
bootloaderPort = newUploadPort
185-
}
186-
}
187-
return bootloaderPort, nil
188-
}

0 commit comments

Comments
 (0)