main: improve flash direct access
This commit is contained in:
parent
588094447f
commit
8fb36f9ba9
63
src/main.cpp
63
src/main.cpp
|
|
@ -36,6 +36,7 @@
|
|||
#include "jtag.hpp"
|
||||
#include "part.hpp"
|
||||
#include "spiFlash.hpp"
|
||||
#include "rawParser.hpp"
|
||||
#include "xilinx.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
|
@ -86,22 +87,6 @@ int main(int argc, char **argv)
|
|||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* FLASH direct access */
|
||||
if (args.spi) {
|
||||
FTDIpp_MPSSE::mpsse_bit_config spi_cable = cable_list["ft2232"].config;
|
||||
int mapping[] = {INTERFACE_A, INTERFACE_B, INTERFACE_C, INTERFACE_D};
|
||||
spi_cable.interface = mapping[args.ftdi_channel];
|
||||
cout << spi_cable.interface << endl;
|
||||
FtdiSpi *spi = new FtdiSpi(spi_cable, 6000000, args.verbose);
|
||||
SPIFlash flash((SPIInterface *)spi, args.verbose);
|
||||
flash.power_up();
|
||||
flash.reset();
|
||||
flash.read_id();
|
||||
|
||||
delete spi;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* if a board name is specified try to use this to determine cable */
|
||||
if (args.board[0] != '-' && board_list.find(args.board) != board_list.end()) {
|
||||
/* set pins config (only when user has not already provided
|
||||
|
|
@ -152,6 +137,52 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
/* FLASH direct access */
|
||||
if (args.spi) {
|
||||
FtdiSpi *spi = NULL;
|
||||
RawParser *bit = NULL;
|
||||
|
||||
try {
|
||||
spi = new FtdiSpi(cable.config, args.freq, args.verbose);
|
||||
} catch (std::exception &e) {
|
||||
printError("Error: Failed to claim cable");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
SPIFlash flash((SPIInterface *)spi, args.verbose);
|
||||
flash.power_up();
|
||||
flash.reset();
|
||||
flash.read_id();
|
||||
|
||||
if (!args.bit_file.empty()) {
|
||||
printInfo("Open file " + args.bit_file + " ", false);
|
||||
try {
|
||||
bit = new RawParser(args.bit_file, false);
|
||||
printSuccess("DONE");
|
||||
} catch (std::exception &e) {
|
||||
printError("FAIL");
|
||||
delete spi;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printInfo("Parse file ", false);
|
||||
if (bit->parse() == EXIT_FAILURE) {
|
||||
printError("FAIL");
|
||||
delete spi;
|
||||
return EXIT_FAILURE;
|
||||
} else {
|
||||
printSuccess("DONE");
|
||||
}
|
||||
|
||||
flash.erase_and_prog(args.offset, bit->getData(), bit->getLength()/8);
|
||||
}
|
||||
|
||||
delete bit;
|
||||
delete spi;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* jtag base */
|
||||
Jtag *jtag;
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue