Skip to contentSkip to conversation

Subject: [U-BOOT] [PATCH] In stmicro_erase() correctly calculate the high byte of the sector address.

U-Boot Gary Jennejohn 2 participants 2 messages Nov 11, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

In stmicro_erase() correctly calculate the high byte of the sector address.

---
 drivers/mtd/spi/stmicro.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/mtd/spi/stmicro.c +7 -1
index 9b910c1..b5808c5 100644
@@ -281,7 +281,13 @@ int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len)
 
 	ret = 0;
 	for (actual = 0; actual < len; actual++) {
-		cmd[1] = (offset / sector_size) + actual;
+		/*
+		 * Correctly calculate the high byte of the address.
+		 *
+		 * Note that the new code basically does what the
+		 * Linux driver does.
+		 */
+		cmd[1] = ((offset + actual * sector_size) >> 16) & 0xff;
 
 		ret = spi_flash_cmd(flash->spi, CMD_M25PXX_WREN, NULL, 0);
 		if (ret < 0) {
Signature · 9 lines
1.6.2.5

---
Gary Jennejohn
*********************************************************************
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: [email protected]
*********************************************************************
#1 lore raw
Quoted 1 line · On Wednesday 11 November 2009 08:40:41 Gary Jennejohn wrote:

In stmicro_erase() correctly calculate the high byte of the sector address.

ive already posted a fix for it;
sf: fix stmicro offset setup while erasing

see if that works for you
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20091111/6c1728e8/attachment.pgp