Skip to content

Commit 3eff88e

Browse files
committed
ice40: fix detect_flash
1 parent 4ab6f22 commit 3eff88e

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/ice40.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,25 @@ void Ice40::program(unsigned int offset, bool unprotect_flash)
148148
post_flash_access();
149149
}
150150

151+
bool Ice40::detect_flash()
152+
{
153+
/* prepare SPI access */
154+
prepare_flash_access();
155+
printInfo("Read Flash ", false);
156+
try {
157+
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose_level);
158+
flash.read_id();
159+
flash.display_status_reg();
160+
} catch (std::exception &e) {
161+
printError("Fail");
162+
printError(std::string(e.what()));
163+
return false;
164+
}
165+
166+
/* release SPI access / reload */
167+
return post_flash_access();
168+
}
169+
151170
bool Ice40::dumpFlash(uint32_t base_addr, uint32_t len)
152171
{
153172
/* prepare SPI access */

src/ice40.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ class Ice40: public Device, SPIInterface {
2424
void program(unsigned int offset, bool unprotect_flash) override;
2525
bool program_cram(const uint8_t *data, uint32_t length);
2626
bool dumpFlash(uint32_t base_addr, uint32_t len) override;
27-
bool detect_flash() override {
28-
return SPIInterface::detect_flash();
29-
}
27+
bool detect_flash() override;
3028
bool protect_flash(uint32_t len) override;
3129
bool unprotect_flash() override;
3230
bool bulk_erase_flash() override;

0 commit comments

Comments
 (0)