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 void reset();
|
||||
|
||||
virtual bool connectJtagToMCU() {return false;}
|
||||
|
||||
protected:
|
||||
Jtag *_jtag;
|
||||
std::string _filename;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ using namespace std;
|
|||
# define STATUS_FLASH_LOCK (1 << 17)
|
||||
#define EF_PROGRAM 0x71
|
||||
#define EFLASH_ERASE 0x75
|
||||
#define SWITCH_TO_MCU_JTAG 0x7a
|
||||
|
||||
/* BSCAN spi (external flash) (see below for details) */
|
||||
/* most common pins def */
|
||||
|
|
@ -576,6 +577,12 @@ bool Gowin::flashFLASH(uint32_t page, uint8_t *data, int length)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Gowin::connectJtagToMCU()
|
||||
{
|
||||
wr_rd(SWITCH_TO_MCU_JTAG, NULL, 0, NULL, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* TN653 p. 9 */
|
||||
bool Gowin::flashSRAM(uint8_t *data, int length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class Gowin: public Device, SPIInterface {
|
|||
void reset() override;
|
||||
void program(unsigned int offset, bool unprotect_flash) override;
|
||||
void programFlash();
|
||||
bool connectJtagToMCU() override;
|
||||
|
||||
/* spi interface */
|
||||
virtual bool protect_flash(uint32_t len) override {
|
||||
|
|
|
|||
13
src/main.cpp
13
src/main.cpp
|
|
@ -79,6 +79,7 @@ struct arguments {
|
|||
int port;
|
||||
string interface;
|
||||
string mcufw;
|
||||
bool conmcu;
|
||||
};
|
||||
|
||||
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 */
|
||||
if (args.unprotect_flash && args.bit_file.empty()) {
|
||||
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))
|
||||
("mcufw", "Microcontroller firmware",
|
||||
cxxopts::value<std::string>(args->mcufw))
|
||||
("conmcu", "Connect JTAG to MCU",
|
||||
cxxopts::value<bool>(args->conmcu))
|
||||
("V,Version", "Print program version");
|
||||
|
||||
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->unprotect_flash &&
|
||||
!args->xvc &&
|
||||
!args->reset) {
|
||||
!args->reset &&
|
||||
!args->conmcu) {
|
||||
printError("Error: bitfile not specified");
|
||||
cout << options.help() << endl;
|
||||
throw std::exception();
|
||||
|
|
|
|||
Loading…
Reference in New Issue