blob: e0f95ba7caf9e44014cfafab6cf538e7aae73387 [file] [log] [blame] [edit]
diff -aruN stm32flash.orig/dev_table.c stm32flash/dev_table.c
--- stm32flash.orig/dev_table.c 2014-10-03 14:35:08.000000000 -0700
+++ stm32flash/dev_table.c 2015-02-02 17:25:20.752854394 -0800
@@ -57,9 +57,10 @@
/* L0 */
{0x417, "L05xxx/06xxx" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 32, 128, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000},
/* L1 */
- {0x416, "L1xxx6(8/B)" , 0x20000800, 0x20004000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000},
- {0x429, "L1xxx6(8/B)A" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000},
- {0x427, "L1xxxC" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF02000},
+ {0x416, "Medium-density ULP", 0x20000800, 0x20004000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000},
+ {0x429, "Medium-density ULP Shrink", 0x20000800, 0x20004000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000},
+ {0x427, "Medium+-density ULP", 0x20001000, 0x20008000, 0x08000000, 0x08040000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000},
+
{0x436, "L1xxxD" , 0x20001000, 0x2000C000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000},
{0x437, "L1xxxE" , 0x20001000, 0x20014000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000},
/* These are not (yet) in AN2606: */
diff -aruN stm32flash.orig/stm32.c stm32flash/stm32.c
--- stm32flash.orig/stm32.c 2014-10-02 00:20:26.000000000 -0700
+++ stm32flash/stm32.c 2015-02-02 17:25:20.752854394 -0800
@@ -96,6 +96,7 @@
static const uint32_t stm_reset_code_length = sizeof(stm_reset_code);
extern const stm32_dev_t devices[];
+extern char reset_flag;
static void stm32_warn_stretching(const char *f)
{
@@ -698,7 +699,16 @@
return STM32_ERR_OK;
}
-stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage, uint8_t pages)
+int supports_mass_erase(uint16_t chip_id)
+{
+ int retval = 1;
+ if(chip_id == 0x416 || chip_id == 0x417 || chip_id == 0x427 || chip_id == 0x429) {
+ retval = 0;
+ }
+ return retval;
+}
+
+stm32_err_t stm32_erase_memory(const stm32_t *stm, uint16_t spage, uint16_t pages)
{
struct port_interface *port = stm->port;
stm32_err_t s_err;
@@ -725,8 +735,11 @@
/* Currently known as not supporting mass erase is the Ultra Low Power STM32L15xx range */
/* So if someone has not overridden the default, but uses one of these chips, take it out of */
/* mass erase mode, so it will be done page by page. This maximum might not be correct either! */
- if (stm->pid == 0x416 && pages == 0xFF)
+
+ if (!supports_mass_erase(stm->pid) && pages == 0xFF) {
pages = 0xF8; /* works for the STM32L152RB with 128Kb flash */
+ reset_flag = 1; /* To mimic earlier behavior*/
+ }
if (pages == 0xFF) {
uint8_t buf[3];
@@ -756,6 +769,12 @@
uint8_t *buf;
int i = 0;
+ if (pages == 0xF8) {
+ /* Erase the whole flash */
+ pages = (stm->dev->fl_end - stm->dev->fl_start) / stm->dev->fl_ps;
+ fprintf(stderr, "Erase 0x%x pages\n", pages);
+ }
+
buf = malloc(2 + 2 * pages + 1);
if (!buf)
return STM32_ERR_UNKNOWN;
diff -aruN stm32flash.orig/stm32.h stm32flash/stm32.h
--- stm32flash.orig/stm32.h 2014-10-02 00:20:26.000000000 -0700
+++ stm32flash/stm32.h 2015-02-02 17:25:20.752854394 -0800
@@ -68,8 +68,8 @@
const uint8_t data[], unsigned int len);
stm32_err_t stm32_wunprot_memory(const stm32_t *stm);
stm32_err_t stm32_wprot_memory(const stm32_t *stm);
-stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage,
- uint8_t pages);
+stm32_err_t stm32_erase_memory(const stm32_t *stm, uint16_t spage,
+ uint16_t pages);
stm32_err_t stm32_go(const stm32_t *stm, uint32_t address);
stm32_err_t stm32_reset_device(const stm32_t *stm);
stm32_err_t stm32_readprot_memory(const stm32_t *stm);