lattice: adapt status register to support nexus devices
This commit is contained in:
parent
871e28259e
commit
9572d060e9
186
src/lattice.cpp
186
src/lattice.cpp
|
|
@ -31,6 +31,7 @@
|
||||||
#include "progressBar.hpp"
|
#include "progressBar.hpp"
|
||||||
#include "rawParser.hpp"
|
#include "rawParser.hpp"
|
||||||
#include "display.hpp"
|
#include "display.hpp"
|
||||||
|
#include "part.hpp"
|
||||||
#include "spiFlash.hpp"
|
#include "spiFlash.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
@ -68,7 +69,7 @@ using namespace std;
|
||||||
|
|
||||||
Lattice::Lattice(Jtag *jtag, const string filename,
|
Lattice::Lattice(Jtag *jtag, const string filename,
|
||||||
bool flash_wr, bool sram_wr, bool verbose):
|
bool flash_wr, bool sram_wr, bool verbose):
|
||||||
Device(jtag, filename, verbose)
|
Device(jtag, filename, verbose), _fpga_family(UNKNOWN_FAMILY)
|
||||||
{
|
{
|
||||||
if (_filename != "") {
|
if (_filename != "") {
|
||||||
if (_file_extension == "jed" || _file_extension == "mcs") {
|
if (_file_extension == "jed" || _file_extension == "mcs") {
|
||||||
|
|
@ -84,6 +85,23 @@ Lattice::Lattice(Jtag *jtag, const string filename,
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* check device family */
|
||||||
|
uint32_t idcode = idCode();
|
||||||
|
string family = fpga_list[idcode].family;
|
||||||
|
if (family == "MachXO2")
|
||||||
|
_fpga_family = MACHXO2_FAMILY;
|
||||||
|
else if (family == "MachXO3")
|
||||||
|
_fpga_family = MACHXO3_FAMILY;
|
||||||
|
else if (family == "ECP5")
|
||||||
|
_fpga_family = ECP5_FAMILY;
|
||||||
|
else if (family == "CrosslinkNX")
|
||||||
|
_fpga_family = NEXUS_FAMILY;
|
||||||
|
else if (family == "CertusNX")
|
||||||
|
_fpga_family = NEXUS_FAMILY;
|
||||||
|
else {
|
||||||
|
printError("Unknown device family");
|
||||||
|
throw std::exception();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayFeabits(uint16_t _featbits)
|
void displayFeabits(uint16_t _featbits)
|
||||||
|
|
@ -649,50 +667,41 @@ bool Lattice::wr_rd(uint8_t cmd,
|
||||||
|
|
||||||
void Lattice::displayReadReg(uint32_t dev)
|
void Lattice::displayReadReg(uint32_t dev)
|
||||||
{
|
{
|
||||||
|
uint8_t err;
|
||||||
printf("displayReadReg\n");
|
printf("displayReadReg\n");
|
||||||
if (dev & 1<<0)
|
if (dev & 1<<0) printf("\tTRAN Mode\n");
|
||||||
printf("\tTRAN Mode\n");
|
|
||||||
printf("\tConfig Target Selection : %x\n", (dev >> 1) & 0x07);
|
printf("\tConfig Target Selection : %x\n", (dev >> 1) & 0x07);
|
||||||
if (dev & 1<<4)
|
if (dev & 1<<4) printf("\tJTAG Active\n");
|
||||||
printf("\tJTAG Active\n");
|
if (dev & 1<<5) printf("\tPWD Protect\n");
|
||||||
if (dev & 1<<5)
|
if (dev & 1<<6) printf("\tOTP\n");
|
||||||
printf("\tPWD Protect\n");
|
if (dev & 1<<7) printf("\tDecrypt Enable\n");
|
||||||
if (dev & 1<<6)
|
if (dev & REG_STATUS_DONE) printf("\tDone Flag\n");
|
||||||
printf("\tOTP\n");
|
if (dev & REG_STATUS_ISC_EN) printf("\tISC Enable\n");
|
||||||
if (dev & 1<<7)
|
if (dev & 1 << 10) printf("\tWrite Enable\n");
|
||||||
printf("\tDecrypt Enable\n");
|
if (dev & 1 << 11) printf("\tRead Enable\n");
|
||||||
if (dev & REG_STATUS_DONE)
|
if (dev & REG_STATUS_BUSY) printf("\tBusy Flag\n");
|
||||||
printf("\tDone Flag\n");
|
if (dev & REG_STATUS_FAIL) printf("\tFail Flag\n");
|
||||||
if (dev & REG_STATUS_ISC_EN)
|
if (dev & 1 << 14) printf("\tFFEA OTP\n");
|
||||||
printf("\tISC Enable\n");
|
if (dev & 1 << 15) printf("\tDecrypt Only\n");
|
||||||
if (dev & 1 << 10)
|
if (dev & 1 << 16) printf("\tPWD Enable\n");
|
||||||
printf("\tWrite Enable\n");
|
if (_fpga_family == NEXUS_FAMILY) {
|
||||||
if (dev & 1 << 11)
|
if (dev & 1 << 17) printf("\tPWD All\n");
|
||||||
printf("\tRead Enable\n");
|
if (dev & 1 << 18) printf("\tCID En\n");
|
||||||
if (dev & REG_STATUS_BUSY)
|
if (dev & 1 << 19) printf("\tinternal use\n");
|
||||||
printf("\tBusy Flag\n");
|
if (dev & 1 << 21) printf("\tEncryption PreAmble\n");
|
||||||
if (dev & REG_STATUS_FAIL)
|
if (dev & 1 << 22) printf("\tStd PreAmble\n");
|
||||||
printf("\tFail Flag\n");
|
if (dev & 1 << 23) printf("\tSPIm Fail1\n");
|
||||||
if (dev & 1 << 14)
|
err = (dev >> 24)&0x0f;
|
||||||
printf("\tFFEA OTP\n");
|
} else {
|
||||||
if (dev & 1 << 15)
|
if (dev & 1 << 17) printf("\tUFM OTP\n");
|
||||||
printf("\tDecrypt Only\n");
|
if (dev & 1 << 18) printf("\tASSP\n");
|
||||||
if (dev & 1 << 16)
|
if (dev & 1 << 19) printf("\tSDM Enable\n");
|
||||||
printf("\tPWD Enable\n");
|
if (dev & 1 << 20) printf("\tEncryption PreAmble\n");
|
||||||
if (dev & 1 << 17)
|
if (dev & 1 << 21) printf("\tStd PreAmble\n");
|
||||||
printf("\tUFM OTP\n");
|
if (dev & 1 << 22) printf("\tSPIm Fail1\n");
|
||||||
if (dev & 1 << 18)
|
err = (dev >> 23)&0x07;
|
||||||
printf("\tASSP\n");
|
}
|
||||||
if (dev & 1 << 19)
|
|
||||||
printf("\tSDM Enable\n");
|
|
||||||
if (dev & 1 << 20)
|
|
||||||
printf("\tEncryption PreAmble\n");
|
|
||||||
if (dev & 1 << 21)
|
|
||||||
printf("\tStd PreAmble\n");
|
|
||||||
if (dev & 1 << 22)
|
|
||||||
printf("\tSPIm Fail1\n");
|
|
||||||
|
|
||||||
uint8_t err = (dev >> 23)&0x07;
|
|
||||||
printf("\t");
|
printf("\t");
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -722,15 +731,90 @@ void Lattice::displayReadReg(uint32_t dev)
|
||||||
default:
|
default:
|
||||||
printf("unknown %x\n", err);
|
printf("unknown %x\n", err);
|
||||||
}
|
}
|
||||||
if (dev & REG_STATUS_EXEC_ERR)
|
|
||||||
printf("\tEXEC Error\n");
|
if (_fpga_family == NEXUS_FAMILY) {
|
||||||
if (dev & 1 << 27)
|
if ((dev >> 28) & 0x01) printf("\tEXEC Error\n");
|
||||||
printf("\tDevice failed to verify\n");
|
if ((dev >> 29) & 0x01) printf("\tID Error\n");
|
||||||
if (dev & 1 << 28)
|
if ((dev >> 30) & 0x01) printf("\tInvalid Command\n");
|
||||||
printf("\tInvalid Command\n");
|
if ((dev >> 31) & 0x01) printf("\tWDT Busy\n");
|
||||||
if (dev & 1 << 29) printf("\tSED Error\n");
|
} else {
|
||||||
if (dev & 1 << 30) printf("\tBypass Mode\n");
|
if (dev & REG_STATUS_EXEC_ERR) printf("\tEXEC Error\n");
|
||||||
if (dev & ((uint32_t)1 << 31)) printf("\tFT Mode\n");
|
if ((dev >> 27) & 0x01) printf("\tDevice failed to verify\n");
|
||||||
|
if ((dev >> 28) & 0x01) printf("\tInvalid Command\n");
|
||||||
|
if ((dev >> 29) & 0x01) printf("\tSED Error\n");
|
||||||
|
if ((dev >> 30) & 0x01) printf("\tBypass Mode\n");
|
||||||
|
if ((dev >> 31) & 0x01) printf("\tFT Mode\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (_fpga_family == NEXUS_FAMILY) {
|
||||||
|
if ((dev >> 33) & 0x01) printf("\tDry Run Done\n");
|
||||||
|
err = (dev >> 34)&0x0f;
|
||||||
|
printf("\tBSE Error 1 Code for previous bitstream execution\n");
|
||||||
|
printf("\t\t");
|
||||||
|
switch (err) {
|
||||||
|
case 0:
|
||||||
|
printf("No err\n");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
printf("ID ERR\n");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
printf("CMD ERR\n");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
printf("CRC ERR\n");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
printf("Preamble ERR\n");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
printf("Abort ERR\n");
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
printf("Overflow ERR\n");
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
printf("SDM EOF\n");
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
printf("Authentification ERR\n");
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
printf("Authentification Setup ERR\n");
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
printf("Bitstream Engine Timeout ERR\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("unknown %x\n", err);
|
||||||
|
}
|
||||||
|
if ((dev >> 38) & 0x01) printf("\tBypass Mode\n");
|
||||||
|
if ((dev >> 39) & 0x01) printf("\tFlow Through Mode\n");
|
||||||
|
if ((dev >> 42) & 0x01) printf("\tSFDP Timeout\n");
|
||||||
|
if ((dev >> 43) & 0x01) printf("\tKey Destroy pass\n");
|
||||||
|
if ((dev >> 44) & 0x01) printf("\tINITN\n");
|
||||||
|
if ((dev >> 45) & 0x01) printf("\tI3C Parity Error2\n");
|
||||||
|
if ((dev >> 46) & 0x01) printf("\tINIT Bus ID Error\n");
|
||||||
|
if ((dev >> 47) & 0x01) printf("\tI3C Parity Error1\n");
|
||||||
|
err = (dev >> 48) & 0x03;
|
||||||
|
printf("\tAuthentification mode:\n");
|
||||||
|
printf("\t\t");
|
||||||
|
switch (err) {
|
||||||
|
case 3:
|
||||||
|
case 0:
|
||||||
|
printf("No Auth\n");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
printf("ECDSA\n");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
printf("HMAC\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((dev >> 50) & 0x01) printf("\tAuthentification Done\n");
|
||||||
|
if ((dev >> 51) & 0x01) printf("\tDry Run Authentification Done\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Lattice::pollBusyFlag(bool verbose)
|
bool Lattice::pollBusyFlag(bool verbose)
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,16 @@ class Lattice: public Device, SPIInterface {
|
||||||
uint32_t timeout, bool verbose=false) override;
|
uint32_t timeout, bool verbose=false) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum lattice_family_t {
|
||||||
|
MACHXO2_FAMILY = 0,
|
||||||
|
MACHXO3_FAMILY = 1,
|
||||||
|
ECP5_FAMILY = 2,
|
||||||
|
NEXUS_FAMILY = 3,
|
||||||
|
UNKNOWN_FAMILY = 999
|
||||||
|
};
|
||||||
|
|
||||||
|
lattice_family_t _fpga_family;
|
||||||
|
|
||||||
bool program_intFlash();
|
bool program_intFlash();
|
||||||
bool program_extFlash(unsigned int offset);
|
bool program_extFlash(unsigned int offset);
|
||||||
bool wr_rd(uint8_t cmd, uint8_t *tx, int tx_len,
|
bool wr_rd(uint8_t cmd, uint8_t *tx, int tx_len,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue