colognechip integration: introduce waitCfgDone() and check for raw data
This commit is contained in:
parent
e252e713dd
commit
1e1b93c27a
|
|
@ -84,7 +84,7 @@ void CologneChip::reset()
|
||||||
* Obtain CFG_DONE and ~CFG_FAILED signals. Configuration is successfull iff
|
* Obtain CFG_DONE and ~CFG_FAILED signals. Configuration is successfull iff
|
||||||
* CFG_DONE=true and ~CFG_FAILED=false.
|
* CFG_DONE=true and ~CFG_FAILED=false.
|
||||||
*/
|
*/
|
||||||
bool CologneChip::waitCfgDone()
|
bool CologneChip::cfgDone()
|
||||||
{
|
{
|
||||||
uint16_t status = 0;
|
uint16_t status = 0;
|
||||||
if (_spi) {
|
if (_spi) {
|
||||||
|
|
@ -97,6 +97,25 @@ bool CologneChip::waitCfgDone()
|
||||||
return (done && !fail);
|
return (done && !fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints information if configuration was successfull.
|
||||||
|
*/
|
||||||
|
void CologneChip::waitCfgDone()
|
||||||
|
{
|
||||||
|
uint32_t timeout = 1000;
|
||||||
|
|
||||||
|
printInfo("Wait for CFG_DONE ", false);
|
||||||
|
do {
|
||||||
|
timeout--;
|
||||||
|
usleep(SLEEP_US);
|
||||||
|
} while (!cfgDone() && timeout > 0);
|
||||||
|
if (timeout == 0) {
|
||||||
|
printError("FAIL");
|
||||||
|
} else {
|
||||||
|
printSuccess("DONE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
|
* Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
|
||||||
*/
|
*/
|
||||||
|
|
@ -149,10 +168,16 @@ bool CologneChip::dumpFlash(const std::string &filename, uint32_t base_addr,
|
||||||
void CologneChip::program(unsigned int offset)
|
void CologneChip::program(unsigned int offset)
|
||||||
{
|
{
|
||||||
ConfigBitstreamParser *cfg;
|
ConfigBitstreamParser *cfg;
|
||||||
if (_file_extension == "bit") {
|
if (_file_extension == "cfg") {
|
||||||
cfg = new RawParser(_filename, false);
|
|
||||||
} else if (_file_extension == "cfg") {
|
|
||||||
cfg = new CologneChipCfgParser(_filename);
|
cfg = new CologneChipCfgParser(_filename);
|
||||||
|
} else if (_file_extension == "bit") {
|
||||||
|
cfg = new RawParser(_filename, false);
|
||||||
|
} else { /* unknown type: */
|
||||||
|
if (_mode == Device::FLASH_MODE) {
|
||||||
|
cfg = new RawParser(_filename, false);
|
||||||
|
} else {
|
||||||
|
throw std::runtime_error("incompatible file format");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg->parse();
|
cfg->parse();
|
||||||
|
|
@ -184,8 +209,6 @@ void CologneChip::program(unsigned int offset)
|
||||||
*/
|
*/
|
||||||
void CologneChip::programSPI_sram(uint8_t *data, int length)
|
void CologneChip::programSPI_sram(uint8_t *data, int length)
|
||||||
{
|
{
|
||||||
uint32_t timeout = 1000;
|
|
||||||
|
|
||||||
/* hold device in reset for a moment */
|
/* hold device in reset for a moment */
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
|
@ -193,16 +216,7 @@ void CologneChip::programSPI_sram(uint8_t *data, int length)
|
||||||
_spi->gpio_set(_rstn_pin);
|
_spi->gpio_set(_rstn_pin);
|
||||||
_spi->spi_put(data, recv, length); // TODO _spi->spi_put(data, null, length) does not work?
|
_spi->spi_put(data, recv, length); // TODO _spi->spi_put(data, null, length) does not work?
|
||||||
|
|
||||||
printInfo("Wait for CFG_DONE ", false);
|
waitCfgDone();
|
||||||
do {
|
|
||||||
timeout--;
|
|
||||||
usleep(SLEEP_US);
|
|
||||||
} while (!waitCfgDone() && timeout > 0);
|
|
||||||
if (timeout == 0) {
|
|
||||||
printError("FAIL");
|
|
||||||
} else {
|
|
||||||
printSuccess("DONE");
|
|
||||||
}
|
|
||||||
|
|
||||||
_spi->gpio_set(_oen_pin);
|
_spi->gpio_set(_oen_pin);
|
||||||
delete [] recv;
|
delete [] recv;
|
||||||
|
|
@ -215,8 +229,6 @@ void CologneChip::programSPI_sram(uint8_t *data, int length)
|
||||||
*/
|
*/
|
||||||
void CologneChip::programSPI_flash(unsigned int offset, uint8_t *data, int length)
|
void CologneChip::programSPI_flash(unsigned int offset, uint8_t *data, int length)
|
||||||
{
|
{
|
||||||
uint32_t timeout = 1000;
|
|
||||||
|
|
||||||
/* hold device in reset during flash write access */
|
/* hold device in reset during flash write access */
|
||||||
_spi->gpio_clear(_rstn_pin | _oen_pin);
|
_spi->gpio_clear(_rstn_pin | _oen_pin);
|
||||||
usleep(SLEEP_US);
|
usleep(SLEEP_US);
|
||||||
|
|
@ -236,16 +248,7 @@ void CologneChip::programSPI_flash(unsigned int offset, uint8_t *data, int lengt
|
||||||
_spi->gpio_set(_rstn_pin);
|
_spi->gpio_set(_rstn_pin);
|
||||||
usleep(SLEEP_US);
|
usleep(SLEEP_US);
|
||||||
|
|
||||||
printInfo("Wait for CFG_DONE ", false);
|
waitCfgDone();
|
||||||
do {
|
|
||||||
timeout--;
|
|
||||||
usleep(SLEEP_US);
|
|
||||||
} while (!waitCfgDone() && timeout > 0);
|
|
||||||
if (timeout == 0) {
|
|
||||||
printError("FAIL");
|
|
||||||
} else {
|
|
||||||
printSuccess("DONE");
|
|
||||||
}
|
|
||||||
|
|
||||||
_spi->gpio_set(_oen_pin);
|
_spi->gpio_set(_oen_pin);
|
||||||
}
|
}
|
||||||
|
|
@ -256,8 +259,6 @@ void CologneChip::programSPI_flash(unsigned int offset, uint8_t *data, int lengt
|
||||||
*/
|
*/
|
||||||
void CologneChip::programJTAG_sram(uint8_t *data, int length)
|
void CologneChip::programJTAG_sram(uint8_t *data, int length)
|
||||||
{
|
{
|
||||||
uint32_t timeout = 1000;
|
|
||||||
|
|
||||||
/* hold device in reset for a moment */
|
/* hold device in reset for a moment */
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
|
@ -284,16 +285,7 @@ void CologneChip::programJTAG_sram(uint8_t *data, int length)
|
||||||
progress.done();
|
progress.done();
|
||||||
_jtag->set_state(Jtag::RUN_TEST_IDLE);
|
_jtag->set_state(Jtag::RUN_TEST_IDLE);
|
||||||
|
|
||||||
printInfo("Wait for CFG_DONE ", false);
|
waitCfgDone();
|
||||||
do {
|
|
||||||
timeout--;
|
|
||||||
usleep(SLEEP_US);
|
|
||||||
} while (!waitCfgDone() && timeout > 0);
|
|
||||||
if (timeout == 0) {
|
|
||||||
printError("FAIL");
|
|
||||||
} else {
|
|
||||||
printSuccess("DONE");
|
|
||||||
}
|
|
||||||
|
|
||||||
_ftdi_jtag->gpio_set(_oen_pin);
|
_ftdi_jtag->gpio_set(_oen_pin);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ class CologneChip: public Device, SPIInterface {
|
||||||
bool verify, int8_t verbose);
|
bool verify, int8_t verbose);
|
||||||
~CologneChip() {}
|
~CologneChip() {}
|
||||||
|
|
||||||
bool waitCfgDone();
|
bool cfgDone();
|
||||||
|
void waitCfgDone();
|
||||||
bool dumpFlash(const std::string &filename, uint32_t base_addr, uint32_t len);
|
bool dumpFlash(const std::string &filename, uint32_t base_addr, uint32_t len);
|
||||||
void program(unsigned int offset = 0) override;
|
void program(unsigned int offset = 0) override;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue