xilinx: fail write-flash on SPI access errors; improve open-file errors
This commit is contained in:
parent
7a58a13f95
commit
9d466fb893
|
|
@ -804,14 +804,14 @@ int spi_comm(struct arguments args, const cable_t &cable,
|
||||||
bit = new RawParser(args.bit_file, false);
|
bit = new RawParser(args.bit_file, false);
|
||||||
printSuccess("DONE");
|
printSuccess("DONE");
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
printError("FAIL");
|
printError("FAIL: unable to open '" + args.bit_file + "': " + std::string(e.what()));
|
||||||
delete spi;
|
delete spi;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printInfo("Parse file ", false);
|
printInfo("Parse file ", false);
|
||||||
if (bit->parse() == EXIT_FAILURE) {
|
if (bit->parse() == EXIT_FAILURE) {
|
||||||
printError("FAIL");
|
printError("FAIL: unable to parse '" + args.bit_file + "'");
|
||||||
delete bit;
|
delete bit;
|
||||||
delete spi;
|
delete spi;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
|
||||||
|
|
@ -186,20 +186,24 @@ static void open_bitfile(
|
||||||
const std::string &filename, const std::string &extension,
|
const std::string &filename, const std::string &extension,
|
||||||
ConfigBitstreamParser **parser, bool reverse, bool verbose)
|
ConfigBitstreamParser **parser, bool reverse, bool verbose)
|
||||||
{
|
{
|
||||||
printInfo("Open file ", false);
|
printInfo("Open file " + filename + " ", false);
|
||||||
if (extension == "bit") {
|
try {
|
||||||
*parser = new BitParser(filename, reverse, verbose);
|
if (extension == "bit") {
|
||||||
} else if (extension == "mcs") {
|
*parser = new BitParser(filename, reverse, verbose);
|
||||||
*parser = new McsParser(filename, reverse, verbose);
|
} else if (extension == "mcs") {
|
||||||
} else {
|
*parser = new McsParser(filename, reverse, verbose);
|
||||||
*parser = new RawParser(filename, reverse);
|
} else {
|
||||||
|
*parser = new RawParser(filename, reverse);
|
||||||
|
}
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
throw std::runtime_error("Unable to open '" + filename + "': " + e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
printSuccess("DONE");
|
printSuccess("DONE");
|
||||||
|
|
||||||
printInfo("Parse file ", false);
|
printInfo("Parse file ", false);
|
||||||
if ((*parser)->parse() == EXIT_FAILURE) {
|
if ((*parser)->parse() == EXIT_FAILURE) {
|
||||||
throw std::runtime_error("Failed to parse bitstream");
|
throw std::runtime_error("Failed to parse bitstream '" + filename + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
printSuccess("DONE");
|
printSuccess("DONE");
|
||||||
|
|
@ -634,12 +638,11 @@ void Xilinx::program(unsigned int offset, bool unprotect_flash)
|
||||||
&secondary_bit, reverse, _verbose);
|
&secondary_bit, reverse, _verbose);
|
||||||
}
|
}
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
printError("FAIL");
|
|
||||||
if (bit)
|
if (bit)
|
||||||
delete bit;
|
delete bit;
|
||||||
if (secondary_bit)
|
if (secondary_bit)
|
||||||
delete secondary_bit;
|
delete secondary_bit;
|
||||||
return;
|
throw std::runtime_error(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_verbose) {
|
if (_verbose) {
|
||||||
|
|
@ -842,11 +845,13 @@ void Xilinx::program_spi(ConfigBitstreamParser * bit, std::string extention,
|
||||||
throw std::runtime_error("called with null bitstream");
|
throw std::runtime_error("called with null bitstream");
|
||||||
if (extention == "mcs") {
|
if (extention == "mcs") {
|
||||||
McsParser *parser = (McsParser *)bit;
|
McsParser *parser = (McsParser *)bit;
|
||||||
FlashInterface::write(parser->getRecords(), unprotect_flash, true);
|
if (!FlashInterface::write(parser->getRecords(), unprotect_flash, true))
|
||||||
|
throw std::runtime_error("SPI flash write failed");
|
||||||
} else {
|
} else {
|
||||||
const uint8_t *data = bit->getData();
|
const uint8_t *data = bit->getData();
|
||||||
int length = bit->getLength() / 8;
|
int length = bit->getLength() / 8;
|
||||||
FlashInterface::write(offset, data, length, unprotect_flash);
|
if (!FlashInterface::write(offset, data, length, unprotect_flash))
|
||||||
|
throw std::runtime_error("SPI flash write failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue