add direct access to spi flash
This commit is contained in:
parent
01fbbf747d
commit
f77faa2657
|
|
@ -128,6 +128,7 @@ openFPGALoader -- a program to flash FPGA
|
||||||
-o, --offset arg start offset in EEPROM
|
-o, --offset arg start offset in EEPROM
|
||||||
--pins arg pin config (only for ft232R) TDI:TDO:TCK:TMS
|
--pins arg pin config (only for ft232R) TDI:TDO:TCK:TMS
|
||||||
-r, --reset reset FPGA after operations
|
-r, --reset reset FPGA after operations
|
||||||
|
--spi SPI mode (only for FTDI in serial mode)
|
||||||
-v, --verbose Produce verbose output
|
-v, --verbose Produce verbose output
|
||||||
-h, --help Give this help list
|
-h, --help Give this help list
|
||||||
-V, --Version Print program version
|
-V, --Version Print program version
|
||||||
|
|
|
||||||
23
src/main.cpp
23
src/main.cpp
|
|
@ -30,10 +30,12 @@
|
||||||
#include "cable.hpp"
|
#include "cable.hpp"
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
#include "display.hpp"
|
#include "display.hpp"
|
||||||
|
#include "ftdispi.hpp"
|
||||||
#include "gowin.hpp"
|
#include "gowin.hpp"
|
||||||
#include "lattice.hpp"
|
#include "lattice.hpp"
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
#include "part.hpp"
|
#include "part.hpp"
|
||||||
|
#include "spiFlash.hpp"
|
||||||
#include "xilinx.hpp"
|
#include "xilinx.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
@ -55,6 +57,7 @@ struct arguments {
|
||||||
bool write_flash;
|
bool write_flash;
|
||||||
bool write_sram;
|
bool write_sram;
|
||||||
bool is_list_command;
|
bool is_list_command;
|
||||||
|
bool spi;
|
||||||
};
|
};
|
||||||
|
|
||||||
int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *pins_config);
|
int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *pins_config);
|
||||||
|
|
@ -68,7 +71,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* command line args. */
|
/* command line args. */
|
||||||
struct arguments args = {false, false, false, 0, "", "", "-", "", -1, 6000000, "-",
|
struct arguments args = {false, false, false, 0, "", "", "-", "", -1, 6000000, "-",
|
||||||
false, false, false, false, false, true, false};
|
false, false, false, false, false, true, false, false};
|
||||||
/* parse arguments */
|
/* parse arguments */
|
||||||
try {
|
try {
|
||||||
if (parse_opt(argc, argv, &args, &pins_config))
|
if (parse_opt(argc, argv, &args, &pins_config))
|
||||||
|
|
@ -83,6 +86,22 @@ int main(int argc, char **argv)
|
||||||
return EXIT_SUCCESS;
|
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 a board name is specified try to use this to determine cable */
|
||||||
if (args.board[0] != '-' && board_list.find(args.board) != board_list.end()) {
|
if (args.board[0] != '-' && board_list.find(args.board) != board_list.end()) {
|
||||||
/* set pins config (only when user has not already provided
|
/* set pins config (only when user has not already provided
|
||||||
|
|
@ -291,6 +310,8 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
|
||||||
cxxopts::value<vector<string>>(pins))
|
cxxopts::value<vector<string>>(pins))
|
||||||
("r,reset", "reset FPGA after operations",
|
("r,reset", "reset FPGA after operations",
|
||||||
cxxopts::value<bool>(args->reset))
|
cxxopts::value<bool>(args->reset))
|
||||||
|
("spi", "SPI mode (only for FTDI in serial mode)",
|
||||||
|
cxxopts::value<bool>(args->spi))
|
||||||
("v,verbose", "Produce verbose output", cxxopts::value<bool>(args->verbose))
|
("v,verbose", "Produce verbose output", cxxopts::value<bool>(args->verbose))
|
||||||
("h,help", "Give this help list")
|
("h,help", "Give this help list")
|
||||||
("V,Version", "Print program version");
|
("V,Version", "Print program version");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue