Skip to content

Commit 26e7c00

Browse files
committed
allow flash detect on flash enable failure
it appears some boards report SpiAttach failed when flash has already been loaded by the stub
1 parent d821980 commit 26e7c00

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

espflash/src/flasher.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,30 @@ impl Flasher {
294294
// Loop over all available SPI parameters until we find one that successfully
295295
// reads the flash size.
296296
for spi_params in TRY_SPI_PARAMS.iter().copied() {
297+
debug!("Attempting flash enable with: {:?}", spi_params);
298+
299+
// Send `SpiAttach` to enable flash, in some instances this command
300+
// may fail while the flash connection succeeds
297301
if let Err(_e) = self.enable_flash(spi_params) {
298-
continue;
302+
debug!("Flash enable failed");
299303
}
304+
300305
if let Some(flash_size) = self.flash_detect()? {
306+
debug!("Flash detect OK!");
307+
301308
// Flash detection was successful, so save the flash size and SPI parameters and
302309
// return.
303310
self.flash_size = flash_size;
304311
self.spi_params = spi_params;
305312

306313
return Ok(());
307314
}
315+
316+
debug!("Flash detect failed");
308317
}
309318

319+
debug!("SPI flash autodetection failed");
320+
310321
// None of the SPI parameters were successful.
311322
Err(Error::FlashConnect)
312323
}

0 commit comments

Comments
 (0)