Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an erase error in stm32f030 device. #442

Merged
merged 1 commit into from
Jun 25, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,29 @@ static void __attribute__((unused)) clear_flash_cr_per(stlink_t *sl) {
}

static void set_flash_cr_mer(stlink_t *sl) {
uint32_t val, cr_reg, cr_mer;
uint32_t val, cr_reg, cr_mer, cr_pg;

if (sl->flash_type == STLINK_FLASH_TYPE_F4) {
cr_reg = FLASH_F4_CR;
cr_mer = 1 << FLASH_CR_MER;
cr_pg = 1 << FLASH_CR_PG;
} else if (sl->flash_type == STLINK_FLASH_TYPE_L4) {
cr_reg = STM32L4_FLASH_CR;
cr_mer = (1 << STM32L4_FLASH_CR_MER1) | (1 << STM32L4_FLASH_CR_MER2);
cr_pg = 1 << STM32L4_FLASH_CR_PG;
} else {
cr_reg = FLASH_CR;
cr_mer = 1 << FLASH_CR_MER;
cr_pg = 1 << FLASH_CR_PG;
}

stlink_read_debug32(sl, cr_reg, &val);
if (val & cr_pg) {
/* STM32F030 will drop MER bit if PG was set */
val &= ~cr_pg;
stlink_write_debug32(sl, cr_reg, val);
}

val |= cr_mer;
stlink_write_debug32(sl, cr_reg, val);
}
Expand Down