Skip to content

Commit e5ae5db

Browse files
committed
add some debug printing
1 parent 91f8c09 commit e5ae5db

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

cli/certificates/flash.go

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/arduino/arduino-fwuploader/flasher"
3434
"github.com/arduino/arduino-fwuploader/indexes/download"
3535
"github.com/arduino/go-paths-helper"
36+
"github.com/sirupsen/logrus"
3637
"github.com/spf13/cobra"
3738
)
3839

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

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

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

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

9497
// Get flasher depending on which module to use

cli/common/common.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func CheckFlags(fqbn, address string) {
4747
feedback.Errorf("Error during firmware flashing: missing board address")
4848
os.Exit(errorcodes.ErrBadArgument)
4949
}
50+
logrus.Debugf("fqbn: %s, address: %s", fqbn, address)
5051
}
5152

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

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

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

95+
logrus.Debugf("uploading with command: %s", uploaderCommand)
9296
commandLine, err := properties.SplitQuotedString(uploaderCommand, "\"", false)
9397
if err != nil {
9498
feedback.Errorf(`Error splitting command line "%s": %s`, uploaderCommand, err)
@@ -122,7 +126,7 @@ func GetNewAddress(board *firmwareindex.IndexBoard, oldAddress string) (string,
122126
return "", fmt.Errorf("error during sketch flashing: missing board address. %s", err)
123127
}
124128
if newUploadPort != "" {
125-
logrus.Infof("Found port to upload Loader: %s", newUploadPort)
129+
logrus.Infof("Found port to upload: %s", newUploadPort)
126130
bootloaderPort = newUploadPort
127131
}
128132
}

cli/firmware/flash.go

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func runFlash(cmd *cobra.Command, args []string) {
9393
} else {
9494
firmware = board.GetFirmware(moduleVersion)
9595
}
96+
logrus.Debugf("module name: %s, firmware version: %s", firmware.Module, firmware.Version.String())
9697
if firmware == nil {
9798
feedback.Errorf("Error getting firmware for board: %s", commonFlags.Fqbn)
9899
os.Exit(errorcodes.ErrGeneric)
@@ -103,12 +104,14 @@ func runFlash(cmd *cobra.Command, args []string) {
103104
feedback.Errorf("Error downloading firmware from %s: %s", firmware.URL, err)
104105
os.Exit(errorcodes.ErrGeneric)
105106
}
107+
logrus.Debugf("firmware file downloaded in %s", firmwareFile.String())
106108

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

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

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

140144
// Get flasher depending on which module to use

0 commit comments

Comments
 (0)