[U-Boot] Between 2015.10 and 2016.01, SPI flash changed erase size, and saveenv stopped working

Pavel Machek pavel at denx.de
Mon May 30 10:52:39 CEST 2016


Hi!

> Commit c3c016cf75360c2a0d0a065b64b438aaf7720576 is a part of the problem:
> 
> offset 0x40000 is protected and cannot be erased
> => sf help
> No SPI flash selected. Please run `sf probe'
> => sf probe
> ...
> SF: Detected N25Q512 with page size 256 Bytes, erase size 4 KiB, total
> 64 MiB
> cadence_spi_set_speed: speed=1000000
> => sf protect unlock 0x40000 0x20000
> cadence_spi_xfer: len=1 [bytes]
> cadence_spi_xfer: len=1 [bytes]
> => saveenv
> Saving Environment to SPI Flash...

Disabling flash locking like this seems to do the trick:

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 907067b..b75e66a 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -1131,14 +1131,16 @@ int spi_flash_scan(struct spi_flash *flash)
 
 	/* lock hooks are flash specific - assign them based on idcode0 */
 	switch (idcode[0]) {
+#if 0
 #if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST)
 	case SPI_FLASH_CFI_MFR_STMICRO:
 	case SPI_FLASH_CFI_MFR_SST:
 		flash->flash_lock = stm_lock;
 		flash->flash_unlock = stm_unlock;
 		flash->flash_is_locked = stm_is_locked;
-#endif
 		break;
+#endif
+#endif
 	default:
 		debug("SF: Lock ops not supported for %02x flash\n", idcode[0]);
 	}

and if someone is watching, the #endif should be moved. switch (...) {
break;  } is strange kind of C.

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


More information about the U-Boot mailing list