Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 1b3f1d5

Browse files
Support hex files that are not at the end of flash
The previous code would handle an "end" record in the hex file by terminating the current flash page, but not terminating the write process. For bootloaders, which are aligned to the end of the flash, this is not a problem, but for a normal sketch at the start of flash, this causes a "no colon" error after the last page in the hex file is written. To handle this, an end record now causes readImagePage to return nullptr, which signals write loop to stop writing.
1 parent 1006eb3 commit 1b3f1d5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Standalone-Arduino-AVR-ISP-programmer.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void loop (void) {
105105
uint16_t chipsize = pgm_read_word(&targetimage->chipsize);
106106
Serial.print("Chip size: "); Serial.println(chipsize, DEC);
107107

108-
while (pageaddr < chipsize) {
108+
while (pageaddr < chipsize && hextext) {
109109
Serial.print("Writing address $"); Serial.println(pageaddr, HEX);
110110
byte *hextextpos = readImagePage (hextext, pageaddr, pagesize, pageBuffer);
111111

code.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ byte * readImagePage (byte *hextext, uint16_t pageaddr, uint8_t pagesize, byte *
241241
cksum += b;
242242
//Serial.print("Record type "); Serial.println(b, HEX);
243243
if (b == 0x1) {
244-
// end record!
244+
// end record, return nullptr to indicate we're done
245+
hextext = nullptr;
245246
break;
246247
}
247248
#if VERBOSE

0 commit comments

Comments
 (0)