@@ -69,8 +69,8 @@ func runFlash(cmd *cobra.Command, args []string) {
6969 // at the end cleanup the fwuploader temp dir
7070 defer globals .FwUploaderPath .RemoveAll ()
7171
72- packageIndex , firmwareIndex := common .InitIndexes ()
7372 common .CheckFlags (commonFlags .Fqbn , commonFlags .Address )
73+ packageIndex , firmwareIndex := common .InitIndexes ()
7474 board := common .GetBoard (firmwareIndex , commonFlags .Fqbn )
7575 uploadToolDir := common .DownloadRequiredToolsForBoard (packageIndex , board )
7676
@@ -92,7 +92,6 @@ func runFlash(cmd *cobra.Command, args []string) {
9292 moduleName = strings .ToUpper (moduleName )
9393
9494 var firmwareFilePath * paths.Path
95- var err error
9695 // If a local firmware file has been specified
9796 if fwFile != "" {
9897 firmwareFilePath = paths .New (fwFile )
@@ -111,9 +110,10 @@ func runFlash(cmd *cobra.Command, args []string) {
111110 feedback .Fatal (fmt .Sprintf ("Error getting firmware for board: %s" , commonFlags .Fqbn ), feedback .ErrGeneric )
112111 }
113112 logrus .Debugf ("module name: %s, firmware version: %s" , firmware .Module , firmware .Version .String ())
114- firmwareFilePath , err = download .DownloadFirmware (firmware )
115- if err != nil {
113+ if fwPath , err := download .DownloadFirmware (firmware ); err != nil {
116114 feedback .Fatal (fmt .Sprintf ("Error downloading firmware from %s: %s" , firmware .URL , err ), feedback .ErrGeneric )
115+ } else {
116+ firmwareFilePath = fwPath
117117 }
118118 logrus .Debugf ("firmware file downloaded in %s" , firmwareFilePath .String ())
119119 }
0 commit comments