A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/arduino/arduino-fwuploader/commit/144292ab262c926bc555a57212442ccf6cf719b2 below:

add `-i` flag to upload a custom fw to a board (#117) · arduino/arduino-fwuploader@144292a · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+39

-18

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+39

-18

lines changed Original file line number Diff line number Diff line change

@@ -42,6 +42,7 @@ var (

42 42

commonFlags arguments.Flags // contains fqbn and address

43 43

module string

44 44

retries uint8

45 +

fwFile string

45 46

)

46 47 47 48

// NewFlashCommand creates a new `flash` command

@@ -53,13 +54,15 @@ func NewFlashCommand() *cobra.Command {

53 54

Example: "" +

54 55

" " + os.Args[0] + " firmware flash --fqbn arduino:samd:mkr1000 --address COM10 --module WINC1500@19.5.2\n" +

55 56

" " + os.Args[0] + " firmware flash -b arduino:samd:mkr1000 -a COM10 -m WINC15000\n" +

56 -

" " + os.Args[0] + " firmware flash -b arduino:samd:mkr1000 -a COM10\n",

57 +

" " + os.Args[0] + " firmware flash -b arduino:samd:mkr1000 -a COM10\n" +

58 +

" " + os.Args[0] + " firmware flash -b arduino:samd:mkr1000 -a COM10 -i firmware.bin\n",

57 59

Args: cobra.NoArgs,

58 60

Run: runFlash,

59 61

}

60 62

commonFlags.AddToCommand(command)

61 63

command.Flags().StringVarP(&module, "module", "m", "", "Firmware module ID, e.g.: WINC1500, NINA")

62 64

command.Flags().Uint8Var(&retries, "retries", 9, "Number of retries in case of upload failure (default 9)")

65 +

command.Flags().StringVarP(&fwFile, "input-file", "i", "", "Path of the firmware to upload")

63 66

return command

64 67

}

65 68

@@ -87,24 +90,35 @@ func runFlash(cmd *cobra.Command, args []string) {

87 90

// Normalize module name

88 91

moduleName = strings.ToUpper(moduleName)

89 92 90 -

var firmware *firmwareindex.IndexFirmware

91 -

if moduleVersion == "" {

92 -

firmware = board.LatestFirmware

93 +

var firmwareFilePath *paths.Path

94 +

var err error

95 +

// If a local firmware file has been specified

96 +

if fwFile != "" {

97 +

firmwareFilePath = paths.New(fwFile)

98 +

if !firmwareFilePath.Exist() {

99 +

feedback.Errorf("firmware file not found in %s", firmwareFilePath)

100 +

os.Exit(errorcodes.ErrGeneric)

101 +

}

93 102

} else {

94 -

firmware = board.GetFirmware(moduleVersion)

95 -

}

96 -

logrus.Debugf("module name: %s, firmware version: %s", firmware.Module, firmware.Version.String())

97 -

if firmware == nil {

98 -

feedback.Errorf("Error getting firmware for board: %s", commonFlags.Fqbn)

99 -

os.Exit(errorcodes.ErrGeneric)

100 -

}

101 - 102 -

firmwareFile, err := download.DownloadFirmware(firmware)

103 -

if err != nil {

104 -

feedback.Errorf("Error downloading firmware from %s: %s", firmware.URL, err)

105 -

os.Exit(errorcodes.ErrGeneric)

103 +

// Download the firmware

104 +

var firmware *firmwareindex.IndexFirmware

105 +

if moduleVersion == "" {

106 +

firmware = board.LatestFirmware

107 +

} else {

108 +

firmware = board.GetFirmware(moduleVersion)

109 +

}

110 +

logrus.Debugf("module name: %s, firmware version: %s", firmware.Module, firmware.Version.String())

111 +

if firmware == nil {

112 +

feedback.Errorf("Error getting firmware for board: %s", commonFlags.Fqbn)

113 +

os.Exit(errorcodes.ErrGeneric)

114 +

}

115 +

firmwareFilePath, err = download.DownloadFirmware(firmware)

116 +

if err != nil {

117 +

feedback.Errorf("Error downloading firmware from %s: %s", firmware.URL, err)

118 +

os.Exit(errorcodes.ErrGeneric)

119 +

}

120 +

logrus.Debugf("firmware file downloaded in %s", firmwareFilePath.String())

106 121

}

107 -

logrus.Debugf("firmware file downloaded in %s", firmwareFile.String())

108 122 109 123

loaderSketchPath, err := download.DownloadSketch(board.LoaderSketch)

110 124

if err != nil {

@@ -116,7 +130,7 @@ func runFlash(cmd *cobra.Command, args []string) {

116 130

loaderSketch := strings.ReplaceAll(loaderSketchPath.String(), loaderSketchPath.Ext(), "")

117 131 118 132

for retry := 1; retry <= int(retries); retry++ {

119 -

err = updateFirmware(board, loaderSketch, moduleName, uploadToolDir, firmwareFile)

133 +

err = updateFirmware(board, loaderSketch, moduleName, uploadToolDir, firmwareFilePath)

120 134

if err == nil {

121 135

logrus.Info("Operation completed: success! :-)")

122 136

break

Original file line number Diff line number Diff line change

@@ -22,6 +22,13 @@ like:

22 22

./arduino-fwuploader firmware flash -b arduino:samd:mkr1000 -a /dev/ttyACM0 -m WINC1500@19.6.1

23 23

```

24 24 25 +

Or if you want upload a local firmware you can use the `-i` or `--input-file` flag followed by the path of that

26 +

firmware.

27 + 28 +

```

29 +

./arduino-fwuploader firmware flash -i custom_fw.bin -b arduino:samd:mkr1000 -a /dev/ttyACM0

30 +

```

31 + 25 32

There is a retry mechanism because the flashing process uses serial communication, which sometimes can be a bit

26 33

unreliable. The retry flag is set by default to 9 retries, but it's possible to overwrite it for whatever reason. For

27 34

example to update a Nano RP2040 Connect with the retry set to 2 you can use:

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4