all devices / spiInterface / main: added method / infra to detect flash chip with --detect -f

This commit is contained in:
Gwenhael Goavec-Merou
2024-06-09 09:28:52 +02:00
parent d0dd71a28a
commit c468a69fc9
11 changed files with 126 additions and 2 deletions
+40
View File
@@ -123,6 +123,46 @@ void CologneChip::waitCfgDone()
}
}
/**
* Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
*/
bool CologneChip::detect_flash()
{
if (_spi) {
/* enable output and hold reset */
_spi->gpio_clear(_rstn_pin | _oen_pin);
} else if (_ftdi_jtag) {
/* enable output and disable reset */
_ftdi_jtag->gpio_clear(_oen_pin);
_ftdi_jtag->gpio_set(_rstn_pin);
}
/* prepare SPI access */
printInfo("Read Flash ", false);
try {
std::unique_ptr<SPIFlash> flash(_spi ?
new SPIFlash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose):
new SPIFlash(this, false, _verbose));
flash->read_id();
flash->display_status_reg();
} catch (std::exception &e) {
printError("Fail");
printError(std::string(e.what()));
return false;
}
if (_spi) {
/* disable output and release reset */
_spi->gpio_set(_rstn_pin | _oen_pin);
} else if (_ftdi_jtag) {
/* disable output */
_ftdi_jtag->gpio_set(_oen_pin);
}
usleep(SLEEP_US);
return true;
}
/**
* Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
*/