From 0f9422f09a3e7ecc6b7108a651e9f979cbfbed2f Mon Sep 17 00:00:00 2001 From: Giovanni Bruni Date: Tue, 13 Feb 2024 09:20:35 +0100 Subject: [PATCH 1/3] latticeBitParser: add support for loading Lattice (Nexus) encrypted bitstreams, by adding key and preamble of encrypted bitstreams to if statements. --- src/latticeBitParser.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/latticeBitParser.cpp b/src/latticeBitParser.cpp index beb15ec70f..4c7ad92da5 100644 --- a/src/latticeBitParser.cpp +++ b/src/latticeBitParser.cpp @@ -68,7 +68,8 @@ int LatticeBitParser::parseHeader() printError("Preamble key not found"); return EXIT_FAILURE; } - if ((uint8_t)_raw_data[pos-1] != 0xbd && (uint8_t)_raw_data[pos-1] != 0xbf) { + //0xbe is the key for encrypted bitstreams in Nexus fpgas + if ((uint8_t)_raw_data[pos-1] != 0xbd && (uint8_t)_raw_data[pos-1] != 0xbf && (uint8_t)_raw_data[pos-1] != 0xbe) { printError("Wrong preamble key"); return EXIT_FAILURE; } @@ -98,7 +99,8 @@ int LatticeBitParser::parse() /* check preamble */ uint32_t preamble = (*(uint32_t *)&_raw_data[_endHeader+1]); - if ((preamble != 0xb3bdffff) && (preamble != 0xb3bfffff)) { + //0xb3beffff is the preamble for encrypted bitstreams in Nexus fpgas + if ((preamble != 0xb3bdffff) && (preamble != 0xb3bfffff) && (preamble != 0xb3beffff)) { printError("Error: missing preamble\n"); return EXIT_FAILURE; } From e923ef4059cfb4bb98e33d145cb8e99f8b15e07e Mon Sep 17 00:00:00 2001 From: Giovanni Bruni Date: Tue, 13 Feb 2024 09:24:47 +0100 Subject: [PATCH 2/3] lattice nexus boards: change from CABLE_DEFAULT (i.e. 6MHz) to CABLE_MHZ(1) (i.e. 1MHz) as at 6MHz the download of bitstreams is not stable. With "not stable" we mean that: - when dealing with Certus/Crosslink, most of the times it works - when dealing with CertusPro devices, most of the times it doesn't work We think this is due to the size of the bitstream and the way that the transmission/storing is handled on the receiving side (i.e. the FPGA). --- src/board.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/board.hpp b/src/board.hpp index 54fa83d007..98ff6c5137 100644 --- a/src/board.hpp +++ b/src/board.hpp @@ -131,10 +131,10 @@ static std::map board_list = { JTAG_BOARD("colorlight-i5", "", "cmsisdap", 0, 0, CABLE_DEFAULT), JTAG_BOARD("colorlight-i9", "", "cmsisdap", 0, 0, CABLE_DEFAULT), JTAG_BOARD("colorlight-i9+", "xc7a50tfgg484", "", 0, 0, CABLE_DEFAULT), - JTAG_BOARD("crosslinknx_evn", "", "ft2232", 0, 0, CABLE_DEFAULT), - JTAG_BOARD("certusnx_versa_evn", "", "ft2232", 0, 0, CABLE_DEFAULT), - JTAG_BOARD("certuspronx_evn", "", "ft2232", 0, 0, CABLE_DEFAULT), - JTAG_BOARD("certuspronx_versa_evn", "", "ft2232", 0, 0, CABLE_DEFAULT), + JTAG_BOARD("crosslinknx_evn", "", "ft2232", 0, 0, CABLE_MHZ(1)), + JTAG_BOARD("certusnx_versa_evn", "", "ft2232", 0, 0, CABLE_MHZ(1)), + JTAG_BOARD("certuspronx_evn", "", "ft2232", 0, 0, CABLE_MHZ(1)), + JTAG_BOARD("certuspronx_versa_evn", "", "ft2232", 0, 0, CABLE_MHZ(1)), JTAG_BOARD("cyc1000", "10cl025256", "ft2232", 0, 0, CABLE_DEFAULT), JTAG_BOARD("c10lp-refkit", "10cl055484", "ft2232", 0, 0, CABLE_DEFAULT), JTAG_BOARD("de0", "", "usb-blaster",0, 0, CABLE_DEFAULT), @@ -160,7 +160,7 @@ static std::map 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("gr740-mini", "", "ft4232hp_b", 0, 0, CABLE_MHZ(1)), JTAG_BOARD("hseda-xc6slx16", "xc6slx16ftg256", "", 0, 0, CABLE_DEFAULT), /* most ice40 boards uses the same pinout */ SPI_BOARD("ice40_generic", "lattice", "ft2232", From ffc519c0e2a74117d7d8ecd6988a0441ad684ead Mon Sep 17 00:00:00 2001 From: Giovanni Bruni Date: Tue, 13 Feb 2024 09:32:30 +0100 Subject: [PATCH 3/3] lattice: improve info about "BSE Error Code" from Device Status Register --- src/lattice.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lattice.cpp b/src/lattice.cpp index 695b4afba5..5ca516ea11 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -1080,7 +1080,8 @@ void Lattice::displayReadReg(uint64_t dev) err = (dev >> 23)&0x07; } - printf("\t"); + printf("\tBSE Error Code\n"); + printf("\t\t"); switch (err) { case 0: printf("No err\n"); @@ -1106,8 +1107,17 @@ void Lattice::displayReadReg(uint64_t dev) case 7: printf("SDM EOF\n"); break; + case 8: + printf("Authentication ERR\n"); + break; + case 9: + printf("Authentication Setup ERR\n"); + break; + case 10: + printf("Bitstream Engine Timeout ERR\n"); + break; default: - printf("unknown %x\n", err); + printf("unknown error: %x\n", err); } if (_fpga_family == NEXUS_FAMILY) { @@ -1164,7 +1174,7 @@ void Lattice::displayReadReg(uint64_t dev) printf("Bitstream Engine Timeout ERR\n"); break; default: - printf("unknown %x\n", err); + printf("unknown error: %x\n", err); } if ((dev >> 38) & 0x01) printf("\tBypass Mode\n"); if ((dev >> 39) & 0x01) printf("\tFlow Through Mode\n");