Add connecting MCU to JTAG support for GW1NSR-4C
This commit is contained in:
parent
0581803def
commit
e847c3a7b0
|
|
@ -52,6 +52,8 @@ class Device {
|
||||||
virtual int idCode() = 0;
|
virtual int idCode() = 0;
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
|
virtual bool connectJtagToMCU() {return false;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Jtag *_jtag;
|
Jtag *_jtag;
|
||||||
std::string _filename;
|
std::string _filename;
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ using namespace std;
|
||||||
# define STATUS_FLASH_LOCK (1 << 17)
|
# define STATUS_FLASH_LOCK (1 << 17)
|
||||||
#define EF_PROGRAM 0x71
|
#define EF_PROGRAM 0x71
|
||||||
#define EFLASH_ERASE 0x75
|
#define EFLASH_ERASE 0x75
|
||||||
|
#define SWITCH_TO_MCU_JTAG 0x7a
|
||||||
|
|
||||||
/* BSCAN spi (external flash) (see below for details) */
|
/* BSCAN spi (external flash) (see below for details) */
|
||||||
/* most common pins def */
|
/* most common pins def */
|
||||||
|
|
@ -576,6 +577,12 @@ bool Gowin::flashFLASH(uint32_t page, uint8_t *data, int length)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Gowin::connectJtagToMCU()
|
||||||
|
{
|
||||||
|
wr_rd(SWITCH_TO_MCU_JTAG, NULL, 0, NULL, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* TN653 p. 9 */
|
/* TN653 p. 9 */
|
||||||
bool Gowin::flashSRAM(uint8_t *data, int length)
|
bool Gowin::flashSRAM(uint8_t *data, int length)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class Gowin: public Device, SPIInterface {
|
||||||
void reset() override;
|
void reset() override;
|
||||||
void program(unsigned int offset, bool unprotect_flash) override;
|
void program(unsigned int offset, bool unprotect_flash) override;
|
||||||
void programFlash();
|
void programFlash();
|
||||||
|
bool connectJtagToMCU() override;
|
||||||
|
|
||||||
/* spi interface */
|
/* spi interface */
|
||||||
virtual bool protect_flash(uint32_t len) override {
|
virtual bool protect_flash(uint32_t len) override {
|
||||||
|
|
|
||||||
13
src/main.cpp
13
src/main.cpp
|
|
@ -79,6 +79,7 @@ struct arguments {
|
||||||
int port;
|
int port;
|
||||||
string interface;
|
string interface;
|
||||||
string mcufw;
|
string mcufw;
|
||||||
|
bool conmcu;
|
||||||
};
|
};
|
||||||
|
|
||||||
int run_xvc_server(const struct arguments &args, const cable_t &cable,
|
int run_xvc_server(const struct arguments &args, const cable_t &cable,
|
||||||
|
|
@ -538,6 +539,13 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.conmcu == true) {
|
||||||
|
fpga->connectJtagToMCU();
|
||||||
|
delete(fpga);
|
||||||
|
delete(jtag);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/* unprotect SPI flash */
|
/* unprotect SPI flash */
|
||||||
if (args.unprotect_flash && args.bit_file.empty()) {
|
if (args.unprotect_flash && args.bit_file.empty()) {
|
||||||
fpga->unprotect_flash();
|
fpga->unprotect_flash();
|
||||||
|
|
@ -716,6 +724,8 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
|
||||||
cxxopts::value<int>(args->port))
|
cxxopts::value<int>(args->port))
|
||||||
("mcufw", "Microcontroller firmware",
|
("mcufw", "Microcontroller firmware",
|
||||||
cxxopts::value<std::string>(args->mcufw))
|
cxxopts::value<std::string>(args->mcufw))
|
||||||
|
("conmcu", "Connect JTAG to MCU",
|
||||||
|
cxxopts::value<bool>(args->conmcu))
|
||||||
("V,Version", "Print program version");
|
("V,Version", "Print program version");
|
||||||
|
|
||||||
options.parse_positional({"bitstream"});
|
options.parse_positional({"bitstream"});
|
||||||
|
|
@ -846,7 +856,8 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
|
||||||
!args->protect_flash &&
|
!args->protect_flash &&
|
||||||
!args->unprotect_flash &&
|
!args->unprotect_flash &&
|
||||||
!args->xvc &&
|
!args->xvc &&
|
||||||
!args->reset) {
|
!args->reset &&
|
||||||
|
!args->conmcu) {
|
||||||
printError("Error: bitfile not specified");
|
printError("Error: bitfile not specified");
|
||||||
cout << options.help() << endl;
|
cout << options.help() << endl;
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue