Skip to content

Commit 1f3014c

Browse files
committed
Fallback searching for an hex bootloader if hex sketch selected
1 parent cc1f62d commit 1f3014c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/arduino.cc/builder/merge_sketch_with_bootloader.go

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

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

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

0 commit comments

Comments
 (0)