|
1 | 1 | package bossac |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "io/ioutil" |
5 | 4 | "log" |
6 | 5 | "os" |
7 | | - "path/filepath" |
8 | 6 | "time" |
9 | 7 |
|
10 | 8 | "github.com/arduino/FirmwareUpdater/utils/context" |
11 | 9 | "github.com/arduino/arduino-cli/arduino/serialutils" |
12 | 10 | "github.com/arduino/arduino-cli/executils" |
13 | 11 | "github.com/arduino/go-paths-helper" |
14 | | - "github.com/pkg/errors" |
15 | 12 | ) |
16 | 13 |
|
17 | 14 | type Bossac struct { |
@@ -43,36 +40,6 @@ func (b *Bossac) Flash(filename string) error { |
43 | 40 | return err |
44 | 41 | } |
45 | 42 |
|
46 | | -func (b *Bossac) DumpAndFlash(ctx *context.Context, filename string) (string, error) { |
47 | | - dir, err := ioutil.TempDir("", "wifiFlasher_dump") |
48 | | - if err != nil { |
49 | | - return "", errors.WithMessage(err, "creating temp dir to store current sketch") |
50 | | - } |
51 | | - |
52 | | - log.Println("Entering board into bootloader mode") |
53 | | - port, err := serialutils.Reset(ctx.PortName, true) |
54 | | - if err != nil { |
55 | | - return "", err |
56 | | - } |
57 | | - |
58 | | - log.Println("Reading existing sketch from the baord, to restore it later") |
59 | | - err = b.invoke("-u", "-r", "-p", port, filepath.Join(dir, "dump.bin")) |
60 | | - |
61 | | - log.Println("Original sketch saved at " + filepath.Join(dir, "dump.bin")) |
62 | | - if err != nil { |
63 | | - return "", err |
64 | | - } |
65 | | - |
66 | | - log.Println("Flashing " + filename) |
67 | | - err = b.invoke("-e", "-R", "-p", port, "-w", filename) |
68 | | - |
69 | | - ctx.PortName, err = serialutils.WaitForNewSerialPortOrDefaultTo(port) |
70 | | - log.Println("Board is back online " + ctx.PortName) |
71 | | - time.Sleep(1 * time.Second) |
72 | | - |
73 | | - return filepath.Join(dir, "dump.bin"), err |
74 | | -} |
75 | | - |
76 | 43 | func (b *Bossac) invoke(args ...string) error { |
77 | 44 | cmd, err := executils.NewProcessFromPath(b.bossacPath, args...) |
78 | 45 | if err != nil { |
|
0 commit comments