@@ -27,7 +27,7 @@ import (
2727 "encoding/binary"
2828 "errors"
2929 "fmt"
30- "log "
30+ "io "
3131 "strconv"
3232 "time"
3333
@@ -60,22 +60,30 @@ type WincFlasher struct {
6060 payloadSize int
6161}
6262
63- func (f * WincFlasher ) FlashFirmware (firmwareFile * paths.Path ) error {
63+ func (f * WincFlasher ) FlashFirmware (firmwareFile * paths.Path , flasherOut io. Writer ) error {
6464 logrus .Infof ("Flashing firmware %s" , firmwareFile )
65+ flasherOut .Write ([]byte (fmt .Sprintf ("Flashing firmware %s\n " , firmwareFile )))
6566 data , err := firmwareFile .ReadFile ()
6667 if err != nil {
6768 logrus .Error (err )
6869 return err
6970 }
7071 firmwareOffset := 0x0000
71- return f .flashChunk (firmwareOffset , data )
72+ if err = f .flashChunk (firmwareOffset , data ); err != nil {
73+ logrus .Error (err )
74+ return err
75+ }
76+ logrus .Infof ("Flashed all the things" )
77+ flasherOut .Write ([]byte ("Flashed all the things\n " ))
78+ return nil
7279}
7380
74- func (f * WincFlasher ) FlashCertificates (certificatePaths * paths.PathList , URLs []string ) error {
81+ func (f * WincFlasher ) FlashCertificates (certificatePaths * paths.PathList , URLs []string , flasherOut io. Writer ) error {
7582 var certificatesData []byte
7683 certificatesNumber := 0
7784 for _ , certPath := range * certificatePaths {
7885 logrus .Infof ("Converting and flashing certificate %s" , certPath )
86+ flasherOut .Write ([]byte (fmt .Sprintf ("Converting and flashing certificate %s\n " , certPath )))
7987
8088 data , err := f .certificateFromFile (certPath )
8189 if err != nil {
@@ -87,6 +95,7 @@ func (f *WincFlasher) FlashCertificates(certificatePaths *paths.PathList, URLs [
8795
8896 for _ , URL := range URLs {
8997 logrus .Infof ("Converting and flashing certificate from %s" , URL )
98+ flasherOut .Write ([]byte (fmt .Sprintf ("Converting and flashing certificate from %s\n " , URL )))
9099 data , err := f .certificateFromURL (URL )
91100 if err != nil {
92101 return err
@@ -96,7 +105,13 @@ func (f *WincFlasher) FlashCertificates(certificatePaths *paths.PathList, URLs [
96105 }
97106
98107 certificatesOffset := 0x4000
99- return f .flashChunk (certificatesOffset , certificatesData )
108+ if err := f .flashChunk (certificatesOffset , certificatesData ); err != nil {
109+ logrus .Error (err )
110+ return err
111+ }
112+ logrus .Infof ("Flashed all the things" )
113+ flasherOut .Write ([]byte ("Flashed all the things\n " ))
114+ return nil
100115}
101116
102117func (f * WincFlasher ) certificateFromFile (certificateFile * paths.Path ) ([]byte , error ) {
@@ -431,7 +446,7 @@ func (f *WincFlasher) erase(address uint32, length uint32) error {
431446 return err
432447 }
433448
434- log . Printf ("Erasing %d bytes from address 0x%X\n " , length , address )
449+ logrus . Debugf ("Erasing %d bytes from address 0x%X\n " , length , address )
435450
436451 // wait acknowledge
437452 ack := make ([]byte , 2 )
0 commit comments