Skip to content

Commit

Permalink
Merge pull request #395 from bg-gsl/add_ft4232hp
Browse files Browse the repository at this point in the history
Add ft4232hp, gr740-mini, mappings of spi flash for Lattice boards, small fixes for Lattice programming procedure
  • Loading branch information
trabucayre authored Oct 23, 2023
2 parents 0bbf817 + 590611a commit fc35045
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 9 deletions.
7 changes: 7 additions & 0 deletions doc/boards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@
Flash: OK
Constraints: Fomu-PVT

- ID: gr740-mini
Description: GR740-MINI
URL: https://gaisler.com/index.php/products/boards/gr740-mini
FPGA: CertusPro-NX LFCPNX-100
Memory: OK
Flash: NA

- ID: honeycomb
Description: honeycomb
URL: https://github.com/Disasm/honeycomb-pcb
Expand Down
1 change: 1 addition & 0 deletions src/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ static std::map <std::string, target_board_t> board_list = {
SPI_BOARD("gatemate_evb_spi", "colognechip", "gatemate_evb_spi",
DBUS4, DBUS5, CBUS0, DBUS3, DBUS0, DBUS1, DBUS2, 0, 0, CABLE_DEFAULT),
JTAG_BOARD("genesys2", "xc7k325tffg900", "digilent_b", 0, 0, CABLE_DEFAULT),
JTAG_BOARD("gr740-mini", "", "ft4232hp_b", 0, 0, CABLE_DEFAULT),
JTAG_BOARD("hseda-xc6slx16", "xc6slx16ftg256", "", 0, 0, CABLE_DEFAULT),
/* most ice40 boards uses the same pinout */
SPI_BOARD("ice40_generic", "lattice", "ft2232",
Expand Down
2 changes: 2 additions & 0 deletions src/cable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ static std::map <std::string, cable_t> cable_list = {
{"ft232", FTDI_SER(0x0403, 0x6014, FTDI_INTF_A, 0x08, 0x0B, 0x08, 0x0B)},
{"ft232RL", FTDI_BB( 0x0403, 0x6001, FTDI_INTF_A, 0x08, 0x0B, 0x08, 0x0B)},
{"ft4232", FTDI_SER(0x0403, 0x6011, FTDI_INTF_A, 0x08, 0x0B, 0x08, 0x0B)},
{"ft4232hp", FTDI_SER(0x0403, 0x6043, FTDI_INTF_A, 0x08, 0x0B, 0x00, 0x00)},
{"ft4232hp_b", FTDI_SER(0x0403, 0x6043, FTDI_INTF_B, 0x08, 0x0B, 0x00, 0x00)},
{"ecpix5-debug", FTDI_SER(0x0403, 0x6010, FTDI_INTF_A, 0xF8, 0xFB, 0xFF, 0xFF)},
{"jlink", CABLE_DEF(MODE_JLINK, 0x1366, 0x0105 )},
{"jlink_base", CABLE_DEF(MODE_JLINK, 0x1366, 0x0101 )},
Expand Down
31 changes: 23 additions & 8 deletions src/lattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ using namespace std;
# define REG_STATUS_AUTH_DONE (1 << 18) /* Authentication done */
# define REG_STATUS_PRI_BOOT_FAIL (1 << 21) /* Primary boot failure (1= Fail) even though secondary boot successful */
# define REG_STATUS_CNF_CHK_MASK (0x0f << 23) /* Configuration Status Check */
#define REG_STATUS_PRV_CNF_CHK_MASK (0x0fUL << 33) /* NEXUS_FAMILY: Configuration Status Check of previous bitstrem */
#define REG_STATUS_PRV_CNF_CHK_MASK (UINT64_C(0x0f) << 34) /* NEXUS_FAMILY: Configuration Status Check of previous bitstrem */
# define REG_STATUS_MACHXO3D_CNF_CHK_MASK (0x0f << 22) /* Configuration Status Check */
# define REG_STATUS_EXEC_ERR (1 << 26) /*** NOT specified for MachXO3D ***/
# define REG_STATUS_DEV_VERIFIED (1 << 27) /* I=0 Device verified correct, I=1 Device failed to verify */
Expand Down Expand Up @@ -301,11 +301,20 @@ bool Lattice::program_mem()
displayReadReg(readStatusReg());
}

/* The command code 0x1C is not listed in the manual? */
/* preload 0x1C */
uint8_t tx_buf[26];
memset(tx_buf, 0xff, 26);
wr_rd(0x1C, tx_buf, 26, NULL, 0);
/* The command code 0x1C is not listed in the manual?
* PRELOAD/SAMPLE 0x1C
* For NEXUS family fpgas, the Bscan register is 362 bits long or
* 45.25 bytes => 46 bytes
*/
uint8_t tx_buf[46];
memset(tx_buf, 0xff, 46);
int tx_len;
if(_fpga_family == NEXUS_FAMILY){
tx_len = 46;
} else {
tx_len = 26;
}
wr_rd(0x1C, tx_buf, tx_len, NULL, 0);

/* LSC_REFRESH 0x79 -- "Equivalent to toggle PROGRAMN pin"
* We REFRESH only if the fpga is in a status of error due to
Expand Down Expand Up @@ -375,9 +384,15 @@ bool Lattice::program_mem()
printSuccess("DONE");
}

/* ISC ERASE */
/* ISC ERASE
* For Nexus family (from svf file): 1 byte to tx 0x00
*/
printInfo("SRAM erase: ", false);
if (flashErase(FLASH_ERASE_SRAM) == false) {
uint32_t mask_erase[1] = {FLASH_ERASE_SRAM};
if (_fpga_family == NEXUS_FAMILY){
mask_erase[0] = 0x00;
}
if (flashErase(mask_erase[0]) == false) {
printError("FAIL");
displayReadReg(readStatusReg());
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/libusb_ll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ bool libusb_ll::scan()
snprintf(probe_type, 256, "ft232H");
else if (desc.idProduct == 0x6015)
snprintf(probe_type, 256, "ft231X");
else if (desc.idProduct == 0x6043)
snprintf(probe_type, 256, "FT4232HP");
else
snprintf(probe_type, 256, "unknown FTDI");
found = true;
Expand Down
33 changes: 32 additions & 1 deletion src/spiFlashdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,26 @@ static std::map <uint32_t, flash_t> flash_list = {
.bp_len = 4,
.bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}}
},
{0x0020bb18, {
/* https://www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/n25q/n25q_128mb_1_8v_65nm.pdf */
/* MT25QU128ABA has the same JEDEC-standard signature: https://media-www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/mt25q/die-rev-a/mt25q_qlhs_u_128_aba_0.pdf */
/* Differences: https://media-www.micron.com/-/media/client/global/documents/products/technical-note/nor-flash/tn2501_migrating_n25q_to_mt25ql.pdf */
.manufacturer = "micron",
.model = "MT25/N25Q128_1_8V",
.nr_sector = 256,
.sector_erase = true,
.subsector_erase = true,
.has_extended = true,
.tb_otp = false,
.tb_offset = (1 << 5),
.tb_register = STATR,
.bp_len = 4,
.bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}}
},
{0x0020ba18, {
/* https://media-www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/n25q/n25q_128mb_3v_65nm.pdf */
.manufacturer = "micron",
.model = "N25Q128",
.model = "N25Q128_3V",
.nr_sector = 256,
.sector_erase = true,
.subsector_erase = true,
Expand Down Expand Up @@ -283,6 +300,20 @@ static std::map <uint32_t, flash_t> flash_list = {
.bp_len = 5,
.bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}}
},
{0xc2201a, {
/* https://www.macronix.com/Lists/Datasheet/Attachments/8745/MX25L51245G,%203V,%20512Mb,%20v1.7.pdf */
.manufacturer = "Macronix",
.model = "MX25L51245G",
.nr_sector = 1024,
.sector_erase = true,
.subsector_erase = true,
.has_extended = false,
.tb_otp = true,
.tb_offset = (1 << 3),
.tb_register = CONFR,
.bp_len = 5,
.bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}}
},
{0xef4014, {
/* https://cdn-shop.adafruit.com/datasheets/W25Q80BV.pdf */
.manufacturer = "Winbond",
Expand Down

0 comments on commit fc35045

Please sign in to comment.