Skip to content

Commit 5ba7ddd

Browse files
committed
Report ERANGE results from bootloader
1 parent c8c5481 commit 5ba7ddd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Cmd_Flash.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ int Command_Flash(const std::vector<std::string>& args) {
107107
auto rcv = serial_chat(tty, FlasherCommand_FlashWrite4, buf);
108108
rc = *((uint8_t *)rcv.data());
109109

110+
110111
if (rc != FlasherResult_OK) {
111-
printf("error: failed to write flash: %s\n", FlasherResult_strerror(rc));
112-
abort();
112+
if (rc == FlasherResult_ERANGE) {
113+
printf("\nnotice: writes to flash addr 0x%08x (0x%08x) rejected by bootloader.\n", addr, addr / 2);
114+
printf("Maybe you're writing the configuration bits region?\n");
115+
} else {
116+
printf("\nerror: failed to write flash addr 0x%08x (0x%08x): %s\n", addr, addr / 2, FlasherResult_strerror(rc));
117+
abort();
118+
}
113119
}
114120
}
115121
}
116122

117-
if (rc != FlasherResult_OK) {
118-
printf("error: failed to write flash: %s\n", FlasherResult_strerror(rc));
119-
abort();
120-
}
121-
122-
123123
byte_count += len;
124124
cnt++;
125125
}

0 commit comments

Comments
 (0)