st-flash: print proper error in case of option byte read error.
User could get a wrong "stlink_fread()" error in case of bad stlink_read_option_foo..
@@ -218,6 +218,10 @@ int main(int ac, char** av)
printf("%x\n",option_byte);
} else {
printf("This format is available for STM32F2 and STM32F4 only\n");
+ if (err == -1)
+ {
+ printf("could not read option bytes\n");
+ goto on_error;
}
} else {
if ((o.addr >= sl->flash_base) && (o.size == 0) &&
@@ -229,13 +233,14 @@ int main(int ac, char** av)
o.size = sl->sram_size;
}
err = stlink_fread(sl, o.filename, o.format == FLASH_FORMAT_IHEX, o.addr, o.size);
- }
+
if (err == -1)
{
printf("stlink_fread() == -1\n");
goto on_error;
}
}
+ }
if (o.reset){
if (sl->version.stlink_v > 1) stlink_jtag_reset(sl, 2);
