latticeBitParser: add ECP3 VERIFY ID support (avoid to fail with bitstream)

This commit is contained in:
Gwenhael Goavec-Merou 2023-12-08 07:07:35 +01:00
parent fb587e73d8
commit 807d794703
1 changed files with 16 additions and 0 deletions

View File

@ -103,6 +103,7 @@ int LatticeBitParser::parse()
return EXIT_FAILURE;
}
printf("%08x\n", preamble);
if (preamble == 0xb3bdffff) {
/* extract idcode from configuration data (area starting with 0xE2)
* and check compression when machXO2
@ -161,6 +162,9 @@ int LatticeBitParser::parse()
#define VERIFY_ID 0xE2
#define BYPASS 0xFF
/* ECP3 has a bit reversable (ie same values but 7-0 -> 0-7) */
#define ECP3_VERIFY_ID 0x47
bool LatticeBitParser::parseCfgData()
{
uint8_t *ptr;
@ -174,6 +178,18 @@ bool LatticeBitParser::parseCfgData()
case LSC_RESET_CRC:
pos += 3;
break;
case ECP3_VERIFY_ID:
ptr = (uint8_t*)&_raw_data[pos];
idcode = (((uint32_t)reverseByte(ptr[6])) << 24) |
(((uint32_t)reverseByte(ptr[5])) << 16) |
(((uint32_t)reverseByte(ptr[4])) << 8) |
(((uint32_t)reverseByte(ptr[3])) << 0);
_hdr["idcode"] = string(8, ' ');
snprintf(&_hdr["idcode"][0], 9, "%08x", idcode);
pos += 7;
if (!_is_machXO2)
return true;
break;
case VERIFY_ID:
ptr = (uint8_t*)&_raw_data[pos];
idcode = (((uint32_t)ptr[3]) << 24) |