-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Arduino Nano RP2040 Connect support
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package rp2040load | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/arduino/FirmwareUpdater/utils/context" | ||
"github.com/arduino/arduino-cli/arduino/serialutils" | ||
"github.com/arduino/arduino-cli/executils" | ||
"github.com/arduino/go-paths-helper" | ||
) | ||
|
||
type RP2040Load struct { | ||
rp2040LoadPath *paths.Path | ||
portName string | ||
} | ||
|
||
func NewRP2040Load(ctx *context.Context) *RP2040Load { | ||
return &RP2040Load{ | ||
rp2040LoadPath: paths.New(ctx.ProgrammerPath), | ||
portName: ctx.PortName, | ||
} | ||
} | ||
|
||
func (b *RP2040Load) Flash(filename string) error { | ||
log.Println("Entering board into bootloader mode") | ||
port, err := serialutils.Reset(b.portName, true) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Println("Flashing " + filename) | ||
if err := b.invoke("-v", "-D", filename); err != nil { | ||
log.Fatalf("Error flashing %s: %s", filename, err) | ||
} | ||
|
||
b.portName, err = serialutils.WaitForNewSerialPortOrDefaultTo(port) | ||
log.Println("Board is back online " + b.portName) | ||
return err | ||
} | ||
|
||
func (b *RP2040Load) invoke(args ...string) error { | ||
cmd, err := executils.NewProcessFromPath(b.rp2040LoadPath, args...) | ||
if err != nil { | ||
return err | ||
} | ||
cmd.RedirectStdoutTo(os.Stdout) | ||
cmd.RedirectStderrTo(os.Stderr) | ||
return cmd.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters