main, board: added --pins argument compatible with SPI mode
This commit is contained in:
parent
319c08e841
commit
dd3204a6e0
|
|
@ -49,7 +49,7 @@ openFPGALoader -c cmsisdap fpga_bitstream.bit
|
|||
## Usage
|
||||
|
||||
```
|
||||
Usage: openFPGALoader [OPTION...] BIT_FILE
|
||||
Usage: ./openFPGALoader [OPTION...] BIT_FILE
|
||||
openFPGALoader -- a program to flash FPGA
|
||||
|
||||
--altsetting arg DFU interface altsetting (only for DFU mode)
|
||||
|
|
@ -89,7 +89,8 @@ openFPGALoader -- a program to flash FPGA
|
|||
with dump-flash
|
||||
--file-type arg provides file type instead of let's deduced
|
||||
by using extension
|
||||
--flash-sector arg flash sector (Lattice and Altera MAX10 parts only)
|
||||
--flash-sector arg flash sector (Lattice and Altera MAX10 parts
|
||||
only)
|
||||
--fpga-part arg fpga model flavor + package
|
||||
--freq arg jtag frequency (Hz)
|
||||
-f, --write-flash write bitstream in flash (default: false)
|
||||
|
|
@ -102,7 +103,8 @@ openFPGALoader -- a program to flash FPGA
|
|||
-m, --write-sram write bitstream in SRAM (default: true)
|
||||
-o, --offset arg Start address (in bytes) for read/write into
|
||||
non volatile memory (default: 0)
|
||||
--pins arg pin config TDI:TDO:TCK:TMS
|
||||
--pins arg pin config TDI:TDO:TCK:TMS or
|
||||
MOSI:MISO:SCK:CS[:HOLDN:WPN]
|
||||
--probe-firmware arg firmware for JTAG probe (usbBlasterII)
|
||||
--protect-flash arg protect SPI flash area
|
||||
--quiet Produce quiet output (no progress bar)
|
||||
|
|
@ -127,6 +129,7 @@ openFPGALoader -- a program to flash FPGA
|
|||
-D, --read-dna Read DNA (Xilinx FPGA only)
|
||||
-X, --read-xadc Read XADC (Xilinx FPGA only)
|
||||
--read-register arg Read Status Register(Xilinx FPGA only)
|
||||
--user-flash arg User flash file (Gowin LittleBee FPGA only)
|
||||
-V, --Version Print program version
|
||||
|
||||
Mandatory or optional arguments to long options are also mandatory or optional
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ typedef struct {
|
|||
uint8_t tck_pin; /*! TCK pin value */
|
||||
uint8_t tdi_pin; /*! TDI pin value */
|
||||
uint8_t tdo_pin; /*! TDO pin value */
|
||||
uint8_t ext0_pin; /* Compat with spi_pins_conf_t */
|
||||
uint8_t ext1_pin; /* Compat with spi_pins_conf_t */
|
||||
} jtag_pins_conf_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -93,7 +95,7 @@ typedef struct {
|
|||
#define JTAG_BOARD(_name, _fpga_part, _cable, _rst, _done, _freq) \
|
||||
{_name, {"", _cable, _fpga_part, _rst, _done, 0, COMM_JTAG, {}, {}, _freq, 0, 0, -1}}
|
||||
#define JTAG_BITBANG_BOARD(_name, _fpga_part, _cable, _rst, _done, _tms, _tck, _tdi, _tdo, _freq) \
|
||||
{_name, {"", _cable, _fpga_part, _rst, _done, 0, COMM_JTAG, { _tms, _tck, _tdi, _tdo }, {}, \
|
||||
{_name, {"", _cable, _fpga_part, _rst, _done, 0, COMM_JTAG, { _tms, _tck, _tdi, _tdo, 0, 0 }, {}, \
|
||||
_freq, 0, 0, -1}}
|
||||
#define SPI_BOARD(_name, _manufacturer, _fpga_part, _cable, _rst, _done, _oe, _cs, _sck, _si, _so, _holdn, _wpn, _freq) \
|
||||
{_name, {_manufacturer, _cable, _fpga_part, _rst, _done, _oe, COMM_SPI, {}, \
|
||||
|
|
|
|||
34
src/main.cpp
34
src/main.cpp
|
|
@ -114,7 +114,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
cable_t cable;
|
||||
target_board_t *board = NULL;
|
||||
jtag_pins_conf_t pins_config = {0, 0, 0, 0};
|
||||
jtag_pins_conf_t pins_config = {0, 0, 0, 0, 0, 0};
|
||||
|
||||
/* command line args. */
|
||||
struct arguments args = {0,
|
||||
|
|
@ -265,12 +265,22 @@ int main(int argc, char **argv)
|
|||
args.prg_type = Device::WR_FLASH;
|
||||
|
||||
FtdiSpi *spi = NULL;
|
||||
spi_pins_conf_t pins_config;
|
||||
if (board)
|
||||
pins_config = board->spi_pins_config;
|
||||
spi_pins_conf_t spi_pins_config;
|
||||
if (board && !args.pin_config)
|
||||
spi_pins_config = board->spi_pins_config;
|
||||
if (args.pin_config) {
|
||||
printInfo("Board default pins configuration overridden");
|
||||
spi_pins_config.cs_pin = (1 << pins_config.tms_pin);
|
||||
spi_pins_config.sck_pin = (1 << pins_config.tck_pin);
|
||||
spi_pins_config.mosi_pin = (1 << pins_config.tdi_pin);
|
||||
spi_pins_config.miso_pin = (1 << pins_config.tdo_pin);
|
||||
spi_pins_config.miso_pin = (1 << pins_config.tdo_pin);
|
||||
spi_pins_config.holdn_pin = (1 << pins_config.ext0_pin);
|
||||
spi_pins_config.wpn_pin = (1 << pins_config.ext1_pin);
|
||||
}
|
||||
|
||||
try {
|
||||
spi = new FtdiSpi(cable, pins_config, args.freq, args.verbose);
|
||||
spi = new FtdiSpi(cable, spi_pins_config, args.freq, args.verbose);
|
||||
} catch (std::exception &e) {
|
||||
printError("Error: Failed to claim cable");
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -844,7 +854,7 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
"write bitstream in SRAM (default: true)")
|
||||
("o,offset", "Start address (in bytes) for read/write into non volatile memory (default: 0)",
|
||||
cxxopts::value<unsigned int>(args->offset))
|
||||
("pins", "pin config TDI:TDO:TCK:TMS",
|
||||
("pins", "pin config TDI:TDO:TCK:TMS or MOSI:MISO:SCK:CS[:HOLDN:WPN]",
|
||||
cxxopts::value<vector<string>>(pins))
|
||||
("probe-firmware", "firmware for JTAG probe (usbBlasterII)",
|
||||
cxxopts::value<string>(args->probe_firmware))
|
||||
|
|
@ -1006,8 +1016,8 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
}
|
||||
|
||||
if (result.count("pins")) {
|
||||
if (pins.size() != 4) {
|
||||
printError("Error: pin_config need 4 pins");
|
||||
if (pins.size() < 4 || pins.size() > 6) {
|
||||
printError("Error: pin_config need 4 pins in JTAG mode or 6 pins in SPI Mode");
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
|
|
@ -1021,7 +1031,7 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
{"DCD", FT232RL_DCD},
|
||||
{"RI" , FT232RL_RI}};
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (size_t i = 0; i < pins.size(); i++) {
|
||||
int pin_num;
|
||||
try {
|
||||
pin_num = std::stoi(pins[i], nullptr, 0);
|
||||
|
|
@ -1046,6 +1056,12 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
case 3:
|
||||
pins_config->tms_pin = pin_num;
|
||||
break;
|
||||
case 4:
|
||||
pins_config->ext0_pin = pin_num;
|
||||
break;
|
||||
case 5:
|
||||
pins_config->ext1_pin = pin_num;
|
||||
break;
|
||||
}
|
||||
}
|
||||
args->pin_config = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue