Skip to content
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

For NINA update programmer is no more mandatory #19

Merged
merged 1 commit into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file not shown.
22 changes: 15 additions & 7 deletions modules/nina/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ func Run(ctx context.Context) {

var err error

if strings.Contains(filepath.Base(ctx.ProgrammerPath), "bossac") {
programmer = &bossac.Bossac{}
} else if strings.Contains(filepath.Base(ctx.ProgrammerPath), "avrdude") {
programmer = &avrdude.Avrdude{}
} else {
log.Fatal("Programmer path not specified correctly, programmer path set to: " + ctx.ProgrammerPath)
if ctx.ProgrammerPath != "" {
if strings.Contains(filepath.Base(ctx.ProgrammerPath), "bossac") {
programmer = &bossac.Bossac{}
} else if strings.Contains(filepath.Base(ctx.ProgrammerPath), "avrdude") {
programmer = &avrdude.Avrdude{}
} else {
log.Fatal("Programmer path not specified correctly, programmer path set to: " + ctx.ProgrammerPath)
}
}

if ctx.FWUploaderBinary != "" {
log.Println("Flashing firmware uploader nina")
if programmer == nil {
log.Fatal("ERROR: You must specify a programmer!")
}
if ctx.BinaryToRestore == "" {
ctx.BinaryToRestore, err = programmer.DumpAndFlash(&ctx, ctx.FWUploaderBinary)
} else {
Expand Down Expand Up @@ -107,9 +112,12 @@ func Run(ctx context.Context) {
}

if ctx.BinaryToRestore != "" {
log.Println("Restoring previous sketch")
f.Close()

log.Println("Restoring previous sketch")
if programmer == nil {
log.Fatal("ERROR: You must specify a programmer!")
}
if err := programmer.Flash(&ctx, ctx.BinaryToRestore); err != nil {
log.Fatal(err)
}
Expand Down