ice40: fix detect_flash

This commit is contained in:
Gwenhael Goavec-Merou 2026-03-09 19:39:35 +01:00
parent 4ab6f220b9
commit 3eff88e331
2 changed files with 20 additions and 3 deletions

View File

@ -148,6 +148,25 @@ void Ice40::program(unsigned int offset, bool unprotect_flash)
post_flash_access(); post_flash_access();
} }
bool Ice40::detect_flash()
{
/* prepare SPI access */
prepare_flash_access();
printInfo("Read Flash ", false);
try {
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose_level);
flash.read_id();
flash.display_status_reg();
} catch (std::exception &e) {
printError("Fail");
printError(std::string(e.what()));
return false;
}
/* release SPI access / reload */
return post_flash_access();
}
bool Ice40::dumpFlash(uint32_t base_addr, uint32_t len) bool Ice40::dumpFlash(uint32_t base_addr, uint32_t len)
{ {
/* prepare SPI access */ /* prepare SPI access */

View File

@ -24,9 +24,7 @@ class Ice40: public Device, SPIInterface {
void program(unsigned int offset, bool unprotect_flash) override; void program(unsigned int offset, bool unprotect_flash) override;
bool program_cram(const uint8_t *data, uint32_t length); bool program_cram(const uint8_t *data, uint32_t length);
bool dumpFlash(uint32_t base_addr, uint32_t len) override; bool dumpFlash(uint32_t base_addr, uint32_t len) override;
bool detect_flash() override { bool detect_flash() override;
return SPIInterface::detect_flash();
}
bool protect_flash(uint32_t len) override; bool protect_flash(uint32_t len) override;
bool unprotect_flash() override; bool unprotect_flash() override;
bool bulk_erase_flash() override; bool bulk_erase_flash() override;