Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lattice encrypted bitstreams #432

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ static std::map <std::string, target_board_t> 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),
Expand All @@ -160,7 +160,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("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",
Expand Down
16 changes: 13 additions & 3 deletions src/lattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down
6 changes: 4 additions & 2 deletions src/latticeBitParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Loading