gowin: add support for GW2A
GW2A has no internal flash, and it uses a yet unknown checksum algorithm. Support it by forcing external flash and skip checksum check now. Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
This commit is contained in:
parent
82c17f6a7d
commit
fe0b4d347b
|
|
@ -141,6 +141,18 @@ Gowin::Gowin(Jtag *jtag, const string filename, const string &file_type,
|
|||
_spi_do = BSCAN_GW1NSR_4C_SPI_DO;
|
||||
_spi_msk = BSCAN_GW1NSR_4C_SPI_MSK;
|
||||
}
|
||||
|
||||
/*
|
||||
* GW2 series has no internal flash and uses new bitstream checksum
|
||||
* algorithm that is not yet supported.
|
||||
*/
|
||||
switch (idcode) {
|
||||
case 0x0000081b: /* GW2A(R)-18(C) */
|
||||
case 0x0000281b: /* GW2A(R)-55(C) */
|
||||
_external_flash = true;
|
||||
/* FIXME: implement GW2 checksum calculation */
|
||||
skip_checksum = true;
|
||||
};
|
||||
}
|
||||
|
||||
Gowin::~Gowin()
|
||||
|
|
@ -193,13 +205,15 @@ void Gowin::programFlash()
|
|||
usleep(2*150*1000);
|
||||
|
||||
/* check if file checksum == checksum in FPGA */
|
||||
status = readUserCode();
|
||||
int checksum = static_cast<FsParser *>(_fs)->checksum();
|
||||
if (checksum != status) {
|
||||
printError("CRC check : FAIL");
|
||||
printf("%04x %04x\n", checksum, status);
|
||||
} else {
|
||||
printSuccess("CRC check: Success");
|
||||
if (!skip_checksum) {
|
||||
status = readUserCode();
|
||||
int checksum = static_cast<FsParser *>(_fs)->checksum();
|
||||
if (checksum != status) {
|
||||
printError("CRC check : FAIL");
|
||||
printf("%04x %04x\n", checksum, status);
|
||||
} else {
|
||||
printSuccess("CRC check: Success");
|
||||
}
|
||||
}
|
||||
|
||||
if (_verbose)
|
||||
|
|
@ -276,13 +290,15 @@ void Gowin::program(unsigned int offset, bool unprotect_flash)
|
|||
return;
|
||||
|
||||
/* check if file checksum == checksum in FPGA */
|
||||
status = readUserCode();
|
||||
uint32_t checksum = static_cast<FsParser *>(_fs)->checksum();
|
||||
if (checksum != status) {
|
||||
printError("SRAM Flash: FAIL");
|
||||
printf("%04x %04x\n", checksum, status);
|
||||
} else {
|
||||
printSuccess("SRAM Flash: Success");
|
||||
if (!skip_checksum) {
|
||||
status = readUserCode();
|
||||
uint32_t checksum = static_cast<FsParser *>(_fs)->checksum();
|
||||
if (checksum != status) {
|
||||
printError("SRAM Flash: FAIL");
|
||||
printf("%04x %04x\n", checksum, status);
|
||||
} else {
|
||||
printSuccess("SRAM Flash: Success");
|
||||
}
|
||||
}
|
||||
if (_verbose)
|
||||
displayReadReg(readStatusReg());
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ class Gowin: public Device, SPIInterface {
|
|||
uint32_t readUserCode();
|
||||
ConfigBitstreamParser *_fs;
|
||||
bool is_gw1n1;
|
||||
bool skip_checksum;
|
||||
bool _external_flash; /**< select between int or ext flash */
|
||||
uint8_t _spi_sck; /**< clk signal offset in bscan SPI */
|
||||
uint8_t _spi_cs; /**< cs signal offset in bscan SPI */
|
||||
|
|
|
|||
Loading…
Reference in New Issue