Skip to content

Commit c2e408f

Browse files
facchinmcmaglie
authored andcommitted
Fallback searching for an hex bootloader if hex sketch selected
1 parent cc83916 commit c2e408f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

merge_sketch_with_bootloader.go

+11
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ func (s *MergeSketchWithBootloader) Run(ctx *types.Context) error {
9292

9393
mergedSketchPath := filepath.Join(filepath.Dir(builtSketchPath), sketchFileName+".with_bootloader"+extension)
9494

95+
// make sure that sketch and bootloader have the same format
96+
97+
if (!strings.HasSuffix(bootloaderPath, extension)) {
98+
// oops, need to retrieve the .hex version of the bootloader
99+
if _, err := os.Stat(strings.TrimSuffix(bootloaderPath, ".bin") + extension); err != nil {
100+
return nil
101+
} else {
102+
bootloaderPath = strings.TrimSuffix(bootloaderPath, ".bin") + extension
103+
}
104+
}
105+
95106
var err error
96107
if extension == ".hex" {
97108
err = mergeHex(builtSketchPath, bootloaderPath, mergedSketchPath)

0 commit comments

Comments
 (0)