All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] arm: stm32f4: fix a bug when only first sector gets erased
@ 2015-10-19 23:41 Vadzim Dambrouski
  2015-10-19 23:41 ` [U-Boot] [PATCH 2/2] arm: stm32f4: fix a bug when a random " Vadzim Dambrouski
  2015-10-22  6:13 ` [U-Boot] [PATCH 1/2] arm: stm32f4: fix a bug when only first " Albert ARIBAUD
  0 siblings, 2 replies; 3+ messages in thread
From: Vadzim Dambrouski @ 2015-10-19 23:41 UTC (permalink / raw
  To: u-boot

flash_lock call is inside a for cycle, so after the first iteration flash
is locked and no more sectors can be erased.

Signed-off-by: Vadzim Dambrouski <pftbest@gmail.com>
---

 arch/arm/cpu/armv7m/stm32f4/flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7m/stm32f4/flash.c b/arch/arm/cpu/armv7m/stm32f4/flash.c
index e5c6111..ae63790 100644
--- a/arch/arm/cpu/armv7m/stm32f4/flash.c
+++ b/arch/arm/cpu/armv7m/stm32f4/flash.c
@@ -114,9 +114,9 @@ int flash_erase(flash_info_t *info, int first, int last)
 			;
 
 		clrbits_le32(&STM32_FLASH->cr, STM32_FLASH_CR_SER);
-		stm32f4_flash_lock(1);
 	}
 
+	stm32f4_flash_lock(1);
 	return 0;
 }
 
-- 
2.6.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 2/2] arm: stm32f4: fix a bug when a random sector gets erased
  2015-10-19 23:41 [U-Boot] [PATCH 1/2] arm: stm32f4: fix a bug when only first sector gets erased Vadzim Dambrouski
@ 2015-10-19 23:41 ` Vadzim Dambrouski
  2015-10-22  6:13 ` [U-Boot] [PATCH 1/2] arm: stm32f4: fix a bug when only first " Albert ARIBAUD
  1 sibling, 0 replies; 3+ messages in thread
From: Vadzim Dambrouski @ 2015-10-19 23:41 UTC (permalink / raw
  To: u-boot

Old sector number is not being cleared from FLASH_CR register. For example
when first erased sector was 001 and then you want to erase sector 010,
sector 011 gets erased instead.
This patch clears old sector number from FLASH_CR register before a new
one is written.

Signed-off-by: Vadzim Dambrouski <pftbest@gmail.com>
---

 arch/arm/cpu/armv7m/stm32f4/flash.c       | 3 +++
 arch/arm/include/asm/arch-stm32f4/stm32.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/arch/arm/cpu/armv7m/stm32f4/flash.c b/arch/arm/cpu/armv7m/stm32f4/flash.c
index ae63790..dd058bd 100644
--- a/arch/arm/cpu/armv7m/stm32f4/flash.c
+++ b/arch/arm/cpu/armv7m/stm32f4/flash.c
@@ -97,6 +97,9 @@ int flash_erase(flash_info_t *info, int first, int last)
 		while (readl(&STM32_FLASH->sr) & STM32_FLASH_SR_BSY)
 			;
 
+		/* clear old sector number before writing a new one */
+		clrbits_le32(&STM32_FLASH->cr, STM32_FLASH_CR_SNB_MASK);
+
 		if (bank == 0) {
 			setbits_le32(&STM32_FLASH->cr,
 				     (i << STM32_FLASH_CR_SNB_OFFSET));
diff --git a/arch/arm/include/asm/arch-stm32f4/stm32.h b/arch/arm/include/asm/arch-stm32f4/stm32.h
index 3ed3801..7ca6dc3 100644
--- a/arch/arm/include/asm/arch-stm32f4/stm32.h
+++ b/arch/arm/include/asm/arch-stm32f4/stm32.h
@@ -104,6 +104,7 @@ struct stm32_flash_regs {
 #define STM32_FLASH_CR_STRT		(1 << 16)
 #define STM32_FLASH_CR_LOCK		(1 << 31)
 #define STM32_FLASH_CR_SNB_OFFSET	3
+#define STM32_FLASH_CR_SNB_MASK		(15 << STM32_FLASH_CR_SNB_OFFSET)
 
 enum clock {
 	CLOCK_CORE,
-- 
2.6.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/2] arm: stm32f4: fix a bug when only first sector gets erased
  2015-10-19 23:41 [U-Boot] [PATCH 1/2] arm: stm32f4: fix a bug when only first sector gets erased Vadzim Dambrouski
  2015-10-19 23:41 ` [U-Boot] [PATCH 2/2] arm: stm32f4: fix a bug when a random " Vadzim Dambrouski
@ 2015-10-22  6:13 ` Albert ARIBAUD
  1 sibling, 0 replies; 3+ messages in thread
From: Albert ARIBAUD @ 2015-10-22  6:13 UTC (permalink / raw
  To: u-boot

Hello Vadzim,

On Tue, 20 Oct 2015 02:41:44 +0300, Vadzim Dambrouski
<pftbest@gmail.com> wrote:
> flash_lock call is inside a for cycle, so after the first iteration flash
> is locked and no more sectors can be erased.

Nitpick: the commit summary explains the problem well, but not the
(admittedly) trivial solution; just add it:

	flash_lock call is inside a for cycle, so after the first
	iteration flash is locked and no more sectors can be erased.
	Move flash_lock out of the loop.

> Signed-off-by: Vadzim Dambrouski <pftbest@gmail.com>

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-22  6:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 23:41 [U-Boot] [PATCH 1/2] arm: stm32f4: fix a bug when only first sector gets erased Vadzim Dambrouski
2015-10-19 23:41 ` [U-Boot] [PATCH 2/2] arm: stm32f4: fix a bug when a random " Vadzim Dambrouski
2015-10-22  6:13 ` [U-Boot] [PATCH 1/2] arm: stm32f4: fix a bug when only first " Albert ARIBAUD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.