Skip to content

add get-version command #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add some debug printing
  • Loading branch information
umbynos committed Sep 27, 2021
commit e5ae5db14503d39304c027a6332108d67a7afb60
3 changes: 3 additions & 0 deletions cli/certificates/flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/arduino/arduino-fwuploader/flasher"
"github.com/arduino/arduino-fwuploader/indexes/download"
"github.com/arduino/go-paths-helper"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -78,6 +79,7 @@ func runFlash(cmd *cobra.Command, args []string) {
feedback.Errorf("Error downloading loader sketch from %s: %s", board.LoaderSketch.URL, err)
os.Exit(errorcodes.ErrGeneric)
}
logrus.Debugf("loader sketch downloaded in %s", loaderSketchPath.String())

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

Expand All @@ -89,6 +91,7 @@ func runFlash(cmd *cobra.Command, args []string) {

// Wait a bit after flashing the loader sketch for the board to become
// available again.
logrus.Debug("sleeping for 3 sec")
time.Sleep(3 * time.Second)

// Get flasher depending on which module to use
Expand Down
6 changes: 5 additions & 1 deletion cli/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func CheckFlags(fqbn, address string) {
feedback.Errorf("Error during firmware flashing: missing board address")
os.Exit(errorcodes.ErrBadArgument)
}
logrus.Debugf("fqbn: %s, address: %s", fqbn, address)
}

// GetBoard is an helper function useful to get the IndexBoard,
Expand All @@ -57,6 +58,7 @@ func GetBoard(firmwareIndex *firmwareindex.Index, fqbn string) *firmwareindex.In
feedback.Errorf("Can't find board with %s fqbn", fqbn)
os.Exit(errorcodes.ErrBadArgument)
}
logrus.Debugf("got board: %s", board.Fqbn)
return board
}

Expand All @@ -73,6 +75,7 @@ func GetUploadToolDir(packageIndex *packageindex.Index, board *firmwareindex.Ind
feedback.Errorf("Error downloading tool %s: %s", board.Uploader, err)
os.Exit(errorcodes.ErrGeneric)
}
logrus.Debugf("upload tool downloaded in %s", uploadToolDir.String())
return uploadToolDir
}

Expand All @@ -89,6 +92,7 @@ func FlashSketch(board *firmwareindex.IndexBoard, sketch string, uploadToolDir *
uploaderCommand = strings.ReplaceAll(uploaderCommand, "{serial.port.file}", bootloaderPort)
uploaderCommand = strings.ReplaceAll(uploaderCommand, "{loader.sketch}", sketch) // we leave that name here because it's only a template,

logrus.Debugf("uploading with command: %s", uploaderCommand)
commandLine, err := properties.SplitQuotedString(uploaderCommand, "\"", false)
if err != nil {
feedback.Errorf(`Error splitting command line "%s": %s`, uploaderCommand, err)
Expand Down Expand Up @@ -122,7 +126,7 @@ func GetNewAddress(board *firmwareindex.IndexBoard, oldAddress string) (string,
return "", fmt.Errorf("error during sketch flashing: missing board address. %s", err)
}
if newUploadPort != "" {
logrus.Infof("Found port to upload Loader: %s", newUploadPort)
logrus.Infof("Found port to upload: %s", newUploadPort)
bootloaderPort = newUploadPort
}
}
Expand Down
4 changes: 4 additions & 0 deletions cli/firmware/flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func runFlash(cmd *cobra.Command, args []string) {
} else {
firmware = board.GetFirmware(moduleVersion)
}
logrus.Debugf("module name: %s, firmware version: %s", firmware.Module, firmware.Version.String())
if firmware == nil {
feedback.Errorf("Error getting firmware for board: %s", commonFlags.Fqbn)
os.Exit(errorcodes.ErrGeneric)
Expand All @@ -103,12 +104,14 @@ func runFlash(cmd *cobra.Command, args []string) {
feedback.Errorf("Error downloading firmware from %s: %s", firmware.URL, err)
os.Exit(errorcodes.ErrGeneric)
}
logrus.Debugf("firmware file downloaded in %s", firmwareFile.String())

loaderSketchPath, err := download.DownloadSketch(board.LoaderSketch)
if err != nil {
feedback.Errorf("Error downloading loader sketch from %s: %s", board.LoaderSketch.URL, err)
os.Exit(errorcodes.ErrGeneric)
}
logrus.Debugf("loader sketch downloaded in %s", loaderSketchPath.String())

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

Expand All @@ -135,6 +138,7 @@ func updateFirmware(board *firmwareindex.IndexBoard, loaderSketch, moduleName st
}
// Wait a bit after flashing the loader sketch for the board to become
// available again.
logrus.Debug("sleeping for 3 sec")
time.Sleep(3 * time.Second)

// Get flasher depending on which module to use
Expand Down