Add 'user-flash' CLI argument

This commit is contained in:
Jean THOMAS 2024-12-11 12:01:37 +01:00
parent a1108ca981
commit ffa006d0ee
4 changed files with 22 additions and 4 deletions

14
doc/vendors/gowin.rst vendored
View File

@ -62,3 +62,17 @@ It's possible to flash external SPI Flash (connected to MSPI) in bscan mode by u
Gowin's FPGA may fails to be detected if **JTAGSEL_N** (pin 08 for *GW1N-4K*) is used as a GPIO.
To recover you have to pull down this pin (before power up) to recover JTAG interface (*UG292 - JTAGSELL_N section*).
User Flash
----------
.. ATTENTION::
User Flash support is based on reverse engineering of the JTAG protocol. This functionality should be considered
experimental as it hasn't been thoroughly tested, and may in some circumstances destroy your device.
Gowin FPGA come with extra flash space that can be read and written from the programmable logic ("User Flash"). This
flash section can also be programmed via the JTAG interface:
.. code-block:: bash
openFPGALoader --write-flash /path/to/bitstream.fs --user-flash /path/to/flash.bin

View File

@ -77,8 +77,8 @@ using namespace std;
Gowin::Gowin(Jtag *jtag, const string filename, const string &file_type, std::string mcufw,
Device::prog_type_t prg_type, bool external_flash,
bool verify, int8_t verbose): Device(jtag, filename, file_type,
verify, verbose),
bool verify, int8_t verbose, const std::string& user_flash)
: Device(jtag, filename, file_type, verify, verbose),
SPIInterface(filename, verbose, 0, verify, false, false),
_idcode(0), is_gw1n1(false), is_gw1n4(false), is_gw1n9(false),
is_gw2a(false), is_gw5a(false),

View File

@ -22,7 +22,8 @@ class Gowin: public Device, SPIInterface {
public:
Gowin(Jtag *jtag, std::string filename, const std::string &file_type,
std::string mcufw, Device::prog_type_t prg_type,
bool external_flash, bool verify, int8_t verbose);
bool external_flash, bool verify, int8_t verbose,
const std::string& user_flash);
uint32_t idCode() override;
void reset() override;
void program(unsigned int offset, bool unprotect_flash) override;

View File

@ -97,6 +97,7 @@ struct arguments {
bool read_dna;
bool read_xadc;
string read_register;
string user_flash;
};
int run_xvc_server(const struct arguments &args, const cable_t &cable,
@ -582,7 +583,7 @@ int main(int argc, char **argv)
args.verify, args.verbose);
} else if (fab == "Gowin") {
fpga = new Gowin(jtag, args.bit_file, args.file_type, args.mcufw,
args.prg_type, args.external_flash, args.verify, args.verbose);
args.prg_type, args.external_flash, args.verify, args.verbose, args.user_flash);
} else if (fab == "lattice") {
fpga = new Lattice(jtag, args.bit_file, args.file_type,
args.prg_type, args.flash_sector, args.verify, args.verbose, args.skip_load_bridge, args.skip_reset);
@ -871,6 +872,8 @@ int parse_opt(int argc, char **argv, struct arguments *args,
cxxopts::value<bool>(args->read_xadc))
("read-register", "Read Status Register(Xilinx FPGA only)",
cxxopts::value<string>(rd_reg))
("user-flash", "User flash file (Gowin LittleBee FPGA only)",
cxxopts::value<string>(args->user_flash))
("V,Version", "Print program version");
options.parse_positional({"bitstream"});