spiInterface: unprotect_flash: fix return. Improve messages

This commit is contained in:
Gwenhael Goavec-Merou 2022-04-30 20:16:30 +02:00
parent d7365495aa
commit db410839af
1 changed files with 4 additions and 4 deletions

View File

@ -55,11 +55,10 @@ bool SPIInterface::protect_flash(uint32_t len)
bool SPIInterface::unprotect_flash() bool SPIInterface::unprotect_flash()
{ {
bool ret = true; bool ret = true;
printInfo("unprotect_flash: ", false);
/* move device to spi access */ /* move device to spi access */
if (!prepare_flash_access()) { if (!prepare_flash_access()) {
printError("Fail"); printError("SPI Flash prepare access failed");
return false; return false;
} }
@ -68,13 +67,14 @@ bool SPIInterface::unprotect_flash()
SPIFlash flash(this, false, _spif_verbose); SPIFlash flash(this, false, _spif_verbose);
/* configure flash protection */ /* configure flash protection */
ret = flash.disable_protection() != 0; printInfo("unprotect_flash: ", false);
ret = (flash.disable_protection() == 0);
if (!ret) if (!ret)
printError("Fail " + std::to_string(ret)); printError("Fail " + std::to_string(ret));
else else
printSuccess("Done"); printSuccess("Done");
} catch (std::exception &e) { } catch (std::exception &e) {
printError("Fail"); printError("SPI Flash access failed: ", false);
printError(e.what()); printError(e.what());
ret = false; ret = false;
} }