fix up line endings and white space issues - also moved the flash sector if block into MachXO3D family - as not required for other types
This commit is contained in:
parent
b6979f54f7
commit
07752c37e2
|
|
@ -20,6 +20,49 @@
|
|||
#include "display.hpp"
|
||||
#include "feaparser.hpp"
|
||||
|
||||
/* FEAbits element defines */
|
||||
# define FEA_I2C_DG_FIL_EN (1 << 0) /* I2C deglitch filter enable for Primary I2C Port 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_FLASH_PROT_SEC_SEL (0x7 << 1) /* Flash Protection Sector Selection */
|
||||
# define FEA_MY_ASSP_EN (1 << 4) /* MY_ASSP Enabled 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_PROG_PERSIST (1 << 5) /* PROGRAMN Persistence 0=Enabled (Default), 1=Disabled */
|
||||
# define FEA_INITN_PERSIST (1 << 6) /* INITN Persistence 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_DONE_PERSIST (1 << 7) /* DONE Persistence 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_JTAG_PERSIST (1 << 8) /* JTAG Port Persistence 0=Enabled (Default), 1=Disabled */
|
||||
# define FEA_SSPI_PERSIST (1 << 9) /* Slave SPI Port Persistence 0=Enabled (Default), 1=Disabled */
|
||||
# define FEA_I2C_PERSIST (1 << 10) /* I²C Port Persistence 0=Enabled (Default), 1=Disabled */
|
||||
# define FEA_MSPI_PERSIST (1 << 11) /* Master SPI Port Persistence 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_BOOT_SEQ_SEL (0x07 << 12) /* Boot Sequence selection (used along with Master SPI Port Persistence bit) */
|
||||
# define FEA_I2C_DG_RANGE_SEL (1 << 15) /* I2C deglitch filter range selection on primary I2C port2 0= 8 to 25 ns range (Default) 1= 16 to 50 ns range */
|
||||
# define FEA_VERSION_RB_PROT (1 << 16) /* Version Rollback Protection1 0= Disabled (Default) 1= Enabled (Checks if current version of bitstream is similar to the one that is goi>
|
||||
# define FEA_RESERVED_ZERO (0xffff << 17)
|
||||
|
||||
/* Feature Row element defines */
|
||||
# define FEATURE_CUSTOM_ID (0xffffffff) /* 32 bits of Custom ID code */
|
||||
|
||||
# define FEATURE_TRACE_ID (0xff << 0) /* 8 bits for the user programmable TraceID */
|
||||
# define FEATURE_I2C_SLAVE_ADDR (0xff << 8) /* 8 bits for the user programmable I2C Slave Address */
|
||||
# define FEATURE_DUAL_BOOT_ADDR (0xffff << 16) /* 16 bits for Dual boot address (Most significant 16- bit of address for secondary boot from external flash) */
|
||||
|
||||
# define FEATURE_MASTER_RETRY_CNT (0x3 << 2) /* Master Retry Count */
|
||||
# define FEATURE_MASTER_TIMER_CNT (0x0f << 4) /* Master Timer Count */
|
||||
# define FEATURE_SLAVE_IDLE_TIMER_CNT (0x0f << 8) /* Slave Idle Timer Count */
|
||||
# define FEATURE_SFDP_CONT_FAIL (1 << 14) /* SFDP Continue on Fail */
|
||||
# define FEATURE_SFDP_EN (1 << 15) /* SFDP Enable */
|
||||
# define FEATURE_BULK_ERASE_DISABLE (1 << 16) /* No Bulk Erase */
|
||||
# define FEATURE_32BIT_SPIM (1 << 17) /* 32-bit SPIM */
|
||||
# define FEATURE_MCLK_BYPASS (1 << 18) /* MCLK Bypass */
|
||||
# define FEATURE_LSBF (1 << 19) /* LSBF */
|
||||
# define FEATURE_RX_EDGE (1 << 20)
|
||||
# define FEATURE_TX_EDGE (1 << 21)
|
||||
# define FEATURE_CPOL (1 << 22)
|
||||
# define FEATURE_CPHA (1 << 23)
|
||||
# define FEATURE_HSE_CLOCK_SEL (0x3 << 24)
|
||||
# define FEATURE_EBR_ENABLE (1 << 26)
|
||||
# define FEATURE_SSPI_AUTO (1 << 28) /* SSPI Auto */
|
||||
# define FEATURE_CPU (1 << 29) /* CPU */
|
||||
# define FEATURE_CORE_CLK_SEL (0x03 << 30) /* Core Clock Sel */
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
FeaParser::FeaParser(string filename, bool verbose):
|
||||
|
|
@ -60,7 +103,7 @@ void FeaParser::displayHeader()
|
|||
{
|
||||
if (_has_feabits) {
|
||||
printf("\nFeature Row: [0x");
|
||||
for(int i = 2; i >= 0; i--) {
|
||||
for (int i = 2; i >= 0; i--) {
|
||||
printf("%08x", _featuresRow[i]);
|
||||
}
|
||||
printf("]\n");
|
||||
|
|
@ -131,8 +174,7 @@ void FeaParser::displayHeader()
|
|||
printf("Dual Boot, No Boot\n");
|
||||
else
|
||||
printf("Unknown boot sequence selection");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (boot_mode == 0)
|
||||
printf("Dual Boot, CFG0 - Ext\n");
|
||||
else if ((boot_mode & 0x03) == 1)
|
||||
|
|
@ -169,8 +211,7 @@ void FeaParser::displayHeader()
|
|||
printf("\tFlash Protection : ");
|
||||
if (flash_prot == 0) {
|
||||
printf("None\n");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (flash_prot & 0x04)
|
||||
printf("CFG0 & CFG1 ");
|
||||
if (flash_prot & 0x02)
|
||||
|
|
|
|||
|
|
@ -15,48 +15,6 @@
|
|||
|
||||
#include "configBitstreamParser.hpp"
|
||||
|
||||
/* FEAbits element defines */
|
||||
# define FEA_I2C_DG_FIL_EN (1 << 0) /* I2C deglitch filter enable for Primary I2C Port 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_FLASH_PROT_SEC_SEL (0x7 << 1) /* Flash Protection Sector Selection */
|
||||
# define FEA_MY_ASSP_EN (1 << 4) /* MY_ASSP Enabled 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_PROG_PERSIST (1 << 5) /* PROGRAMN Persistence 0=Enabled (Default), 1=Disabled */
|
||||
# define FEA_INITN_PERSIST (1 << 6) /* INITN Persistence 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_DONE_PERSIST (1 << 7) /* DONE Persistence 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_JTAG_PERSIST (1 << 8) /* JTAG Port Persistence 0=Enabled (Default), 1=Disabled */
|
||||
# define FEA_SSPI_PERSIST (1 << 9) /* Slave SPI Port Persistence 0=Enabled (Default), 1=Disabled */
|
||||
# define FEA_I2C_PERSIST (1 << 10) /* I²C Port Persistence 0=Enabled (Default), 1=Disabled */
|
||||
# define FEA_MSPI_PERSIST (1 << 11) /* Master SPI Port Persistence 0=Disabled (Default), 1=Enabled */
|
||||
# define FEA_BOOT_SEQ_SEL (0x07 << 12) /* Boot Sequence selection (used along with Master SPI Port Persistence bit) */
|
||||
# define FEA_I2C_DG_RANGE_SEL (1 << 15) /* I2C deglitch filter range selection on primary I2C port2 0= 8 to 25 ns range (Default) 1= 16 to 50 ns range */
|
||||
# define FEA_VERSION_RB_PROT (1 << 16) /* Version Rollback Protection1 0= Disabled (Default) 1= Enabled (Checks if current version of bitstream is similar to the one that is going to be downloaded) */
|
||||
# define FEA_RESERVED_ZERO (0xffff << 17)
|
||||
|
||||
/* Feature Row element defines */
|
||||
# define FEATURE_CUSTOM_ID (0xffffffff) /* 32 bits of Custom ID code */
|
||||
|
||||
# define FEATURE_TRACE_ID (0xff << 0) /* 8 bits for the user programmable TraceID */
|
||||
# define FEATURE_I2C_SLAVE_ADDR (0xff << 8) /* 8 bits for the user programmable I2C Slave Address */
|
||||
# define FEATURE_DUAL_BOOT_ADDR (0xffff << 16) /* 16 bits for Dual boot address (Most significant 16- bit of address for secondary boot from external flash) */
|
||||
|
||||
# define FEATURE_MASTER_RETRY_CNT (0x3 << 2) /* Master Retry Count */
|
||||
# define FEATURE_MASTER_TIMER_CNT (0x0f << 4) /* Master Timer Count */
|
||||
# define FEATURE_SLAVE_IDLE_TIMER_CNT (0x0f << 8) /* Slave Idle Timer Count */
|
||||
# define FEATURE_SFDP_CONT_FAIL (1 << 14) /* SFDP Continue on Fail */
|
||||
# define FEATURE_SFDP_EN (1 << 15) /* SFDP Enable */
|
||||
# define FEATURE_BULK_ERASE_DISABLE (1 << 16) /* No Bulk Erase */
|
||||
# define FEATURE_32BIT_SPIM (1 << 17) /* 32-bit SPIM */
|
||||
# define FEATURE_MCLK_BYPASS (1 << 18) /* MCLK Bypass */
|
||||
# define FEATURE_LSBF (1 << 19) /* LSBF */
|
||||
# define FEATURE_RX_EDGE (1 << 20)
|
||||
# define FEATURE_TX_EDGE (1 << 21)
|
||||
# define FEATURE_CPOL (1 << 22)
|
||||
# define FEATURE_CPHA (1 << 23)
|
||||
# define FEATURE_HSE_CLOCK_SEL (0x3 << 24)
|
||||
# define FEATURE_EBR_ENABLE (1 << 26)
|
||||
# define FEATURE_SSPI_AUTO (1 << 28) /* SSPI Auto */
|
||||
# define FEATURE_CPU (1 << 29) /* CPU */
|
||||
# define FEATURE_CORE_CLK_SEL (0x03 << 30) /* Core Clock Sel */
|
||||
|
||||
class FeaParser: public ConfigBitstreamParser {
|
||||
public:
|
||||
FeaParser(std::string filename, bool verbose = false);
|
||||
|
|
|
|||
116
src/lattice.cpp
116
src/lattice.cpp
|
|
@ -101,7 +101,7 @@ using namespace std;
|
|||
# define REG_STATUS_PP_UFM (1 << 17) /* Password Protection enabled for all UFM flash sectors 0=Disabled (Default), 1=Enabled */
|
||||
# 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 << 22)/* Configuration Status Check */
|
||||
# define REG_STATUS_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 */
|
||||
#define READ_STATUS_REGISTER_1 0x3D /* LSC_READ_STATUS_1 */
|
||||
|
|
@ -118,7 +118,7 @@ using namespace std;
|
|||
# define REG_STATUS1_SEC_PLUS_EN_CFG0 (1 << 14) /* Security Plus enabled for CFG0 (1 = Enabled, 0 = Disabled) */
|
||||
# define REG_STATUS1_SEC_PLUS_EN_CFG1 (1 << 15) /* Security Plus enabled for CFG1 (1 = Enabled, 0 = Disabled) */
|
||||
# define REG_STATUS1_BITSTR_VERSION (1 << 16) /* Bitstream version: 1 = Bitstream in CFG0 is latter (newer) than CFG1, 0 = Bitstream in CFG1 is latter (newer) than CFG0 */
|
||||
# define REG_STATUS1_BOOT_SEQ_SEL (0x03 << 17)/* Boot Sequence selection (used along with Master SPI Port Persistence bit) */
|
||||
# define REG_STATUS1_BOOT_SEQ_SEL (0x03 << 17) /* Boot Sequence selection (used along with Master SPI Port Persistence bit) */
|
||||
# define REG_STATUS1_MSPI_PERS (1 << 20) /* Master SPI Port Persistence 0=Disabled (Default), 1=Enabled */
|
||||
# define REG_STATUS1_I2C_DG_FILTER (1 << 21) /* I2C deglitch filter enable for Primary I2C Port 0=Disabled (Default), 1=Enabled */
|
||||
# define REG_STATUS1_I2C_DG_RANGE (1 << 22) /* I2C deglitch filter range selection on primary I2C port 0= 8 to 25 ns range (Default), 1= 16 to 50 ns range */
|
||||
|
|
@ -158,9 +158,35 @@ Lattice::Lattice(Jtag *jtag, const string filename, const string &file_type,
|
|||
_fpga_family = MACHXO2_FAMILY;
|
||||
else if (family == "MachXO3LF")
|
||||
_fpga_family = MACHXO3_FAMILY;
|
||||
else if (family == "MachXO3D")
|
||||
else if (family == "MachXO3D") {
|
||||
_fpga_family = MACHXO3D_FAMILY;
|
||||
else if (family == "ECP5")
|
||||
|
||||
if (flash_sector == "CFG0") {
|
||||
_flash_sector = LATTICE_FLASH_CFG0;
|
||||
printInfo("Flash Sector: CFG0", true);
|
||||
} else if (flash_sector == "CFG1") {
|
||||
_flash_sector = LATTICE_FLASH_CFG1;
|
||||
printInfo("Flash Sector: CFG1", true);
|
||||
} else if (flash_sector == "UFM0") {
|
||||
_flash_sector = LATTICE_FLASH_UFM0;
|
||||
printInfo("Flash Sector: UFM0", true);
|
||||
} else if (flash_sector == "UFM1") {
|
||||
_flash_sector = LATTICE_FLASH_UFM1;
|
||||
printInfo("Flash Sector: UFM1", true);
|
||||
} else if (flash_sector == "UFM2") {
|
||||
_flash_sector = LATTICE_FLASH_UFM2;
|
||||
printInfo("Flash Sector: UFM2", true);
|
||||
} else if (flash_sector == "UFM3") {
|
||||
_flash_sector = LATTICE_FLASH_UFM3;
|
||||
printInfo("Flash Sector: UFM3", true);
|
||||
} else if (flash_sector == "FEA") {
|
||||
_flash_sector = LATTICE_FLASH_FEA;
|
||||
printInfo("Flash Sector: FEA", true);
|
||||
} else {
|
||||
printError("Unknown flash sector");
|
||||
throw std::exception();
|
||||
}
|
||||
} else if (family == "ECP5")
|
||||
_fpga_family = ECP5_FAMILY;
|
||||
else if (family == "CrosslinkNX")
|
||||
_fpga_family = NEXUS_FAMILY;
|
||||
|
|
@ -170,39 +196,6 @@ Lattice::Lattice(Jtag *jtag, const string filename, const string &file_type,
|
|||
printError("Unknown device family");
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
if (flash_sector == "CFG0") {
|
||||
_flash_sector = LATTICE_FLASH_CFG0;
|
||||
printInfo("Flash Sector: CFG0", true);
|
||||
}
|
||||
else if (flash_sector == "CFG1") {
|
||||
_flash_sector = LATTICE_FLASH_CFG1;
|
||||
printInfo("Flash Sector: CFG1", true);
|
||||
}
|
||||
else if (flash_sector == "UFM0") {
|
||||
_flash_sector = LATTICE_FLASH_UFM0;
|
||||
printInfo("Flash Sector: UFM0", true);
|
||||
}
|
||||
else if (flash_sector == "UFM1") {
|
||||
_flash_sector = LATTICE_FLASH_UFM1;
|
||||
printInfo("Flash Sector: UFM1", true);
|
||||
}
|
||||
else if (flash_sector == "UFM2") {
|
||||
_flash_sector = LATTICE_FLASH_UFM2;
|
||||
printInfo("Flash Sector: UFM2", true);
|
||||
}
|
||||
else if (flash_sector == "UFM3") {
|
||||
_flash_sector = LATTICE_FLASH_UFM3;
|
||||
printInfo("Flash Sector: UFM3", true);
|
||||
}
|
||||
else if (flash_sector == "FEA") {
|
||||
_flash_sector = LATTICE_FLASH_FEA;
|
||||
printInfo("Flash Sector: FEA", true);
|
||||
}
|
||||
else {
|
||||
printError("Unknown flash sector");
|
||||
throw std::exception();
|
||||
}
|
||||
}
|
||||
|
||||
void displayFeabits(uint16_t _featbits)
|
||||
|
|
@ -619,9 +612,6 @@ bool Lattice::program_flash(unsigned int offset)
|
|||
else if (_file_extension == "fea") {
|
||||
retval = program_fea_MachXO3D();
|
||||
}
|
||||
else if (_file_extension == "pub") {
|
||||
retval = program_pubkey_MachXO3D();
|
||||
}
|
||||
else
|
||||
retval = program_extFlash(offset);
|
||||
|
||||
|
|
@ -1541,52 +1531,6 @@ bool Lattice::program_fea_MachXO3D()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Lattice::program_pubkey_MachXO3D()
|
||||
{
|
||||
bool err;
|
||||
bool same = true;
|
||||
int len;
|
||||
|
||||
RawParser _pk(_filename, false);
|
||||
printInfo("Open file: ", false);
|
||||
printSuccess("DONE");
|
||||
|
||||
err = _pk.parse();
|
||||
printInfo("Parse file: ", false);
|
||||
if (err == EXIT_FAILURE) {
|
||||
printError("FAIL");
|
||||
return false;
|
||||
} else {
|
||||
printSuccess("DONE");
|
||||
}
|
||||
|
||||
uint8_t* data = _pk.getData();
|
||||
len = _pk.getLength()/8;
|
||||
|
||||
printf("Header: [");
|
||||
if (data[0] == 0x0f) {
|
||||
for (int i = 2; i < len; i++) {
|
||||
if (data[i] == 0xf0)
|
||||
break;
|
||||
printf("%c", data[i]);
|
||||
}
|
||||
}
|
||||
printf("]\n");
|
||||
|
||||
printf("Data: [");
|
||||
for (int i = 0; i < len -3; i++) {
|
||||
printf("0x%02x ", data[i]);
|
||||
}
|
||||
printf("\b]\n");
|
||||
|
||||
printf("Trailing bytes: [");
|
||||
for (int i = len -3; i < len; i++) {
|
||||
printf("0x%02x ", data[i]);
|
||||
}
|
||||
printf("\b]\n");
|
||||
|
||||
}
|
||||
|
||||
bool Lattice::program_intFlash_MachXO3D()
|
||||
{
|
||||
bool err, ufm_flag;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ class Lattice: public Device, SPIInterface {
|
|||
lattice_flash_sector_t _flash_sector;
|
||||
bool program_intFlash_MachXO3D();
|
||||
bool program_fea_MachXO3D();
|
||||
bool program_pubkey_MachXO3D();
|
||||
bool programFeatureRow_MachXO3D(uint8_t* feature_row);
|
||||
bool programFeabits_MachXO3D(uint32_t feabits);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue