X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fstm32f1x.c;h=601417a956e6b83fcf113da0231e936da7a81582;hp=ce0708f65952da0921f417c4d89e01fcea820455;hb=76ea15cce78111d5628b5177cd22e69f6bf08db3;hpb=242649c81c4528d80fa4643b550349e567139875 diff --git a/src/flash/nor/stm32f1x.c b/src/flash/nor/stm32f1x.c index ce0708f659..601417a956 100644 --- a/src/flash/nor/stm32f1x.c +++ b/src/flash/nor/stm32f1x.c @@ -130,7 +130,7 @@ struct stm32x_flash_bank { static int stm32x_mass_erase(struct flash_bank *bank); static int stm32x_get_device_id(struct flash_bank *bank, uint32_t *device_id); -static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, +static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count); /* flash bank stm32x 0 0 @@ -561,7 +561,7 @@ static int stm32x_protect(struct flash_bank *bank, int set, int first, int last) return stm32x_write_options(bank); } -static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, +static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) { struct stm32x_flash_bank *stm32x_info = bank->driver_priv; @@ -692,7 +692,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, return retval; } -static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, +static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) { struct target *target = bank->target; @@ -720,7 +720,7 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, } LOG_INFO("odd number of bytes to write, padding with 0xff"); buffer = memcpy(new_buffer, buffer, count); - buffer[count++] = 0xff; + new_buffer[count++] = 0xff; } uint32_t words_remaining = count / 2; @@ -921,8 +921,17 @@ static int stm32x_probe(struct flash_bank *bank) stm32x_info->option_offset = 6; stm32x_info->default_rdp = 0x55AA; break; - case 0x440: /* stm32f0x */ - case 0x444: + case 0x438: /* stm32f33x */ + page_size = 2048; + stm32x_info->ppage_size = 2; + max_flash_size_in_kb = 64; + stm32x_info->user_data_offset = 16; + stm32x_info->option_offset = 6; + stm32x_info->default_rdp = 0x55AA; + break; + case 0x440: /* stm32f05x */ + case 0x444: /* stm32f03x */ + case 0x445: /* stm32f04x */ page_size = 1024; stm32x_info->ppage_size = 4; max_flash_size_in_kb = 64; @@ -930,6 +939,14 @@ static int stm32x_probe(struct flash_bank *bank) stm32x_info->option_offset = 6; stm32x_info->default_rdp = 0x55AA; break; + case 0x448: /* stm32f07x */ + page_size = 2048; + stm32x_info->ppage_size = 4; + max_flash_size_in_kb = 128; + stm32x_info->user_data_offset = 16; + stm32x_info->option_offset = 6; + stm32x_info->default_rdp = 0x55AA; + break; default: LOG_WARNING("Cannot identify target as a STM32 family."); return ERROR_FAIL; @@ -1167,9 +1184,60 @@ static int get_stm32x_info(struct flash_bank *bank, char *buf, int buf_size) } break; - case 0x440: + case 0x438: + device_str = "STM32F33x"; + + switch (rev_id) { + case 0x1000: + rev_str = "A"; + break; + } + break; + case 0x444: - device_str = "STM32F0xx"; + device_str = "STM32F03x"; + + switch (rev_id) { + case 0x1000: + rev_str = "1.0"; + break; + + case 0x2000: + rev_str = "2.0"; + break; + } + break; + + case 0x440: + device_str = "STM32F05x"; + + switch (rev_id) { + case 0x1000: + rev_str = "1.0"; + break; + + case 0x2000: + rev_str = "2.0"; + break; + } + break; + + case 0x445: + device_str = "STM32F04x"; + + switch (rev_id) { + case 0x1000: + rev_str = "1.0"; + break; + + case 0x2000: + rev_str = "2.0"; + break; + } + break; + + case 0x448: + device_str = "STM32F07x"; switch (rev_id) { case 0x1000: @@ -1347,9 +1415,9 @@ COMMAND_HANDLER(stm32x_handle_options_read_command) } command_print(CMD_CTX, "User Option0: 0x%02" PRIx8, - (user_data >> stm32x_info->user_data_offset) & 0xff); + (uint8_t)((user_data >> stm32x_info->user_data_offset) & 0xff)); command_print(CMD_CTX, "User Option1: 0x%02" PRIx8, - (user_data >> (stm32x_info->user_data_offset + 8)) & 0xff); + (uint8_t)((user_data >> (stm32x_info->user_data_offset + 8)) & 0xff)); return ERROR_OK; } @@ -1398,12 +1466,12 @@ COMMAND_HANDLER(stm32x_handle_options_write_command) else if (strcmp("HWWDG", CMD_ARGV[0]) == 0) optionbyte &= ~(1 << 0); else if (strcmp("NORSTSTOP", CMD_ARGV[0]) == 0) - optionbyte &= ~(1 << 1); - else if (strcmp("RSTSTNDBY", CMD_ARGV[0]) == 0) + optionbyte |= (1 << 1); + else if (strcmp("RSTSTOP", CMD_ARGV[0]) == 0) optionbyte &= ~(1 << 1); else if (strcmp("NORSTSTNDBY", CMD_ARGV[0]) == 0) - optionbyte &= ~(1 << 2); - else if (strcmp("RSTSTOP", CMD_ARGV[0]) == 0) + optionbyte |= (1 << 2); + else if (strcmp("RSTSTNDBY", CMD_ARGV[0]) == 0) optionbyte &= ~(1 << 2); else if (stm32x_info->has_dual_banks) { if (strcmp("BOOT0", CMD_ARGV[0]) == 0)