projects
/
fw
/
altos
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f7e6cbe
)
altos/samd21: Automatically erase flash when writing
author
Keith Packard
<keithp@keithp.com>
Mon, 26 Sep 2022 00:34:11 +0000
(17:34 -0700)
committer
Keith Packard
<keithp@keithp.com>
Thu, 27 Oct 2022 23:59:11 +0000
(16:59 -0700)
Need to erase pages before writing them.
Signed-off-by: Keith Packard <keithp@keithp.com>
src/samd21/ao_flash_samd21.c
patch
|
blob
|
history
diff --git
a/src/samd21/ao_flash_samd21.c
b/src/samd21/ao_flash_samd21.c
index c1cee3f876e75e95b493e24866cd41e48a8cfee9..b0d91c5cdee2e1f482880907cdbf5eea0475661f 100644
(file)
--- a/
src/samd21/ao_flash_samd21.c
+++ b/
src/samd21/ao_flash_samd21.c
@@
-101,6
+101,9
@@
ao_flash_erase_page(uint32_t *page)
uint32_t row_size = samd21_nvmctrl_row_size();
uint32_t rows = (row_size + 255) / 256;
+ if ((uintptr_t) page & (row_size - 1))
+ return;
+
ao_arch_block_interrupts();
if (((uintptr_t) row & (row_size - 1)) == 0) {
@@
-121,6
+124,8
@@
ao_flash_page(uint32_t *page, uint32_t *src)
uint32_t i;
uint32_t per_page = page_size / sizeof(uint32_t);
+ ao_flash_erase_page(page);
+
ao_arch_block_interrupts();
while(pages--) {