Brian Silverman | 11db9dd | 2014-01-01 16:29:22 -0800 | [diff] [blame^] | 1 | From 3076652b98d4d33ac50eb546839a47980464c34d Mon Sep 17 00:00:00 2001 |
| 2 | From: Brian <brian@localhost> |
| 3 | Date: Wed, 1 Jan 2014 16:21:50 -0800 |
| 4 | Subject: [PATCH] fixed the page-by-page erase logic |
| 5 | |
| 6 | Previously, it always started at page 0 and erased 1 more page than it |
| 7 | was told to with bootloaders that support the extended erase command. |
| 8 | --- |
| 9 | stm32.c | 8 ++++---- |
| 10 | 1 file changed, 4 insertions(+), 4 deletions(-) |
| 11 | |
| 12 | diff --git a/stm32.c b/stm32.c |
| 13 | index f724722..dee7959 100644 |
| 14 | --- a/stm32.c |
| 15 | +++ b/stm32.c |
| 16 | @@ -430,14 +430,14 @@ char stm32_erase_memory(const stm32_t *stm, uint8_t spage, uint8_t pages) { |
| 17 | uint8_t pg_byte; |
| 18 | uint8_t cs = 0; |
| 19 | |
| 20 | - pg_byte = pages >> 8; |
| 21 | - stm32_send_byte(stm, pg_byte); // Number of pages to be erased, two bytes, MSB first |
| 22 | + pg_byte = (pages - 1) >> 8; |
| 23 | + stm32_send_byte(stm, pg_byte); // Number of pages to be erased - 1, two bytes, MSB first |
| 24 | cs ^= pg_byte; |
| 25 | - pg_byte = pages & 0xFF; |
| 26 | + pg_byte = (pages - 1) & 0xFF; |
| 27 | stm32_send_byte(stm, pg_byte); |
| 28 | cs ^= pg_byte; |
| 29 | |
| 30 | - for (pg_num = 0; pg_num <= pages; pg_num++) { |
| 31 | + for (pg_num = spage; pg_num < spage + pages; pg_num++) { |
| 32 | pg_byte = pg_num >> 8; |
| 33 | cs ^= pg_byte; |
| 34 | stm32_send_byte(stm, pg_byte); |
| 35 | -- |
| 36 | 1.7.10.4 |
| 37 | |