From 15312eb86c422b89b83df8f113d7df3cd8c154b5 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Thu, 15 Mar 2018 22:21:55 +0100 Subject: [PATCH] stm32f4: Honor parallelism also for erase. --- src/target/stm32f4.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/target/stm32f4.c b/src/target/stm32f4.c index 2701cef..265fb7c 100644 --- a/src/target/stm32f4.c +++ b/src/target/stm32f4.c @@ -369,9 +369,15 @@ static int stm32f4_flash_erase(struct target_flash *f, target_addr addr, uint8_t sector = sf->base_sector + (addr - f->start)/f->blocksize; stm32f4_flash_unlock(t); + enum align psize = ALIGN_WORD; + for (struct target_flash *f = t->flash; f; f = f->next) { + if (f->write == stm32f4_flash_write) { + psize = ((struct stm32f4_flash *)f)->psize; + } + } while(len) { uint32_t cr = FLASH_CR_EOPIE | FLASH_CR_ERRIE | FLASH_CR_SER | - (sector << 3); + (psize * FLASH_CR_PSIZE16) | (sector << 3); /* Flash page erase instruction */ target_mem_write32(t, FLASH_CR, cr); /* write address to FMA */