main: review SPI mode for efinix active mode
This commit is contained in:
parent
70fb5c8439
commit
aa23aff388
75
src/main.cpp
75
src/main.cpp
|
|
@ -30,6 +30,7 @@
|
||||||
#include "cable.hpp"
|
#include "cable.hpp"
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
#include "display.hpp"
|
#include "display.hpp"
|
||||||
|
#include "efinix.hpp"
|
||||||
#include "ftdispi.hpp"
|
#include "ftdispi.hpp"
|
||||||
#include "gowin.hpp"
|
#include "gowin.hpp"
|
||||||
#include "lattice.hpp"
|
#include "lattice.hpp"
|
||||||
|
|
@ -149,7 +150,6 @@ int main(int argc, char **argv)
|
||||||
/* FLASH direct access */
|
/* FLASH direct access */
|
||||||
if (args.spi || (board && board->mode == COMM_SPI)) {
|
if (args.spi || (board && board->mode == COMM_SPI)) {
|
||||||
FtdiSpi *spi = NULL;
|
FtdiSpi *spi = NULL;
|
||||||
RawParser *bit = NULL;
|
|
||||||
spi_pins_conf_t pins_config = board->spi_pins_config;
|
spi_pins_conf_t pins_config = board->spi_pins_config;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -159,43 +159,48 @@ int main(int argc, char **argv)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (board->reset_pin) {
|
if (board->manufacturer == "efinix") {
|
||||||
spi->gpio_set_output(board->reset_pin, true);
|
Efinix target(spi, args.bit_file, board->reset_pin, board->done_pin,
|
||||||
spi->gpio_clear(board->reset_pin, true);
|
args.verbose);
|
||||||
}
|
target.program(args.offset);
|
||||||
|
} else {
|
||||||
SPIFlash flash((SPIInterface *)spi, args.verbose);
|
RawParser *bit = NULL;
|
||||||
flash.power_up();
|
if (board->reset_pin) {
|
||||||
flash.reset();
|
spi->gpio_set_output(board->reset_pin, true);
|
||||||
flash.read_id();
|
spi->gpio_clear(board->reset_pin, true);
|
||||||
|
|
||||||
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);
|
SPIFlash flash((SPIInterface *)spi, args.verbose);
|
||||||
if (bit->parse() == EXIT_FAILURE) {
|
flash.power_up();
|
||||||
printError("FAIL");
|
flash.reset();
|
||||||
delete spi;
|
flash.read_id();
|
||||||
return EXIT_FAILURE;
|
|
||||||
} else {
|
if (!args.bit_file.empty()) {
|
||||||
printSuccess("DONE");
|
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;
|
||||||
}
|
}
|
||||||
|
if (board->reset_pin)
|
||||||
flash.erase_and_prog(args.offset, bit->getData(), bit->getLength()/8);
|
spi->gpio_set(board->reset_pin, true);
|
||||||
|
|
||||||
delete bit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (board->reset_pin) {
|
|
||||||
spi->gpio_set(board->reset_pin, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete spi;
|
delete spi;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue