lattice: erase and update only mandatories area
This commit is contained in:
parent
d93bc79329
commit
ab0d3169a8
67
lattice.cpp
67
lattice.cpp
|
|
@ -121,6 +121,10 @@ bool Lattice::checkStatus(uint32_t val, uint32_t mask)
|
||||||
void Lattice::program(unsigned int offset)
|
void Lattice::program(unsigned int offset)
|
||||||
{
|
{
|
||||||
(void) offset;
|
(void) offset;
|
||||||
|
uint64_t featuresRow;
|
||||||
|
uint16_t feabits;
|
||||||
|
uint8_t eraseMode;
|
||||||
|
vector<string> ufm_data, cfg_data;
|
||||||
|
|
||||||
if (_mode != FLASH_MODE)
|
if (_mode != FLASH_MODE)
|
||||||
return;
|
return;
|
||||||
|
|
@ -139,7 +143,7 @@ void Lattice::program(unsigned int offset)
|
||||||
/* ISC Enable 0xC6 */
|
/* ISC Enable 0xC6 */
|
||||||
printInfo("Enable configuration: ", false);
|
printInfo("Enable configuration: ", false);
|
||||||
if (!EnableISC(0x00)) {
|
if (!EnableISC(0x00)) {
|
||||||
printError("FAIL");// << endl;
|
printError("FAIL");
|
||||||
displayReadReg(readStatusReg());
|
displayReadReg(readStatusReg());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -147,7 +151,7 @@ void Lattice::program(unsigned int offset)
|
||||||
}
|
}
|
||||||
/* ISC ERASE */
|
/* ISC ERASE */
|
||||||
printInfo("SRAM erase: ", false);
|
printInfo("SRAM erase: ", false);
|
||||||
if (flashErase(0x01) == false) {
|
if (flashErase(FLASH_ERASE_SRAM) == false) {
|
||||||
printError("FAIL");
|
printError("FAIL");
|
||||||
displayReadReg(readStatusReg());
|
displayReadReg(readStatusReg());
|
||||||
return;
|
return;
|
||||||
|
|
@ -166,9 +170,30 @@ void Lattice::program(unsigned int offset)
|
||||||
} else {
|
} else {
|
||||||
printSuccess("DONE");
|
printSuccess("DONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i = 0; i < _jed.nb_section(); i++) {
|
||||||
|
string note = _jed.noteForSection(i);
|
||||||
|
if (note == "TAG DATA") {
|
||||||
|
eraseMode |= FLASH_ERASE_UFM;
|
||||||
|
ufm_data = _jed.data_for_section(i);
|
||||||
|
} else if (note == "END CONFIG DATA") {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
cfg_data = _jed.data_for_section(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if feature area must be updated */
|
||||||
|
featuresRow = _jed.featuresRow();
|
||||||
|
feabits = _jed.feabits();
|
||||||
|
eraseMode = FLASH_ERASE_CFG;
|
||||||
|
if (featuresRow != readFeaturesRow() || feabits != readFeabits())
|
||||||
|
eraseMode |= FLASH_ERASE_FEATURE;
|
||||||
|
|
||||||
/* ISC ERASE */
|
/* ISC ERASE */
|
||||||
printInfo("Flash erase: ", false);
|
printInfo("Flash erase: ", false);
|
||||||
if (flashErase(0x0e) == false) {
|
if (flashErase(eraseMode) == false) {
|
||||||
printError("FAIL");
|
printError("FAIL");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -181,7 +206,7 @@ void Lattice::program(unsigned int offset)
|
||||||
_jtag->toggleClk(1000);
|
_jtag->toggleClk(1000);
|
||||||
|
|
||||||
/* flash UFM */
|
/* flash UFM */
|
||||||
if (false == flashProg(_jed.offset_for_section(0), _jed.data_for_section(0)))
|
if (false == flashProg(0, cfg_data))
|
||||||
return;
|
return;
|
||||||
if (Verify(_jed) == false)
|
if (Verify(_jed) == false)
|
||||||
return;
|
return;
|
||||||
|
|
@ -192,22 +217,26 @@ void Lattice::program(unsigned int offset)
|
||||||
wr_rd(0x46, NULL, 0, NULL, 0);
|
wr_rd(0x46, NULL, 0, NULL, 0);
|
||||||
_jtag->set_state(FtdiJtag::RUN_TEST_IDLE);
|
_jtag->set_state(FtdiJtag::RUN_TEST_IDLE);
|
||||||
_jtag->toggleClk(1000);
|
_jtag->toggleClk(1000);
|
||||||
/* write feature row */
|
|
||||||
printInfo("Program features Row: ", false);
|
if ((eraseMode & FLASH_ERASE_FEATURE) != 0) {
|
||||||
if (writeFeaturesRow(_jed.featuresRow(), true) == false) {
|
/* write feature row */
|
||||||
printError("FAIL");
|
printInfo("Program features Row: ", false);
|
||||||
return;
|
if (writeFeaturesRow(_jed.featuresRow(), true) == false) {
|
||||||
} else {
|
printError("FAIL");
|
||||||
printSuccess("DONE");
|
return;
|
||||||
}
|
} else {
|
||||||
/* write feabits */
|
printSuccess("DONE");
|
||||||
printInfo("Program feabitss: ", false);
|
}
|
||||||
if (writeFeabits(_jed.feabits(), true) == false) {
|
/* write feabits */
|
||||||
printError("FAIL");
|
printInfo("Program feabits: ", false);
|
||||||
return;
|
if (writeFeabits(_jed.feabits(), true) == false) {
|
||||||
} else {
|
printError("FAIL");
|
||||||
printSuccess("DONE");
|
return;
|
||||||
|
} else {
|
||||||
|
printSuccess("DONE");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ISC program done 0x5E */
|
/* ISC program done 0x5E */
|
||||||
printInfo("Write program Done: ", false);
|
printInfo("Write program Done: ", false);
|
||||||
if (writeProgramDone() == false) {
|
if (writeProgramDone() == false) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue