X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fstm32f1x.c;h=ab6cca9c1171701c3f2945d76fd7cd8ceeb51f11;hp=58b7ba16acf7f24e3f288d50010bd9c0eaae65bb;hb=aebe7596f647d1d5a37cf5668063b74376d7c253;hpb=b9dbf569b4a8f7fae227f93dd21cd305b4efc16b;ds=sidebyside diff --git a/src/flash/nor/stm32f1x.c b/src/flash/nor/stm32f1x.c index 58b7ba16ac..ab6cca9c11 100644 --- a/src/flash/nor/stm32f1x.c +++ b/src/flash/nor/stm32f1x.c @@ -110,6 +110,7 @@ struct stm32x_options { uint16_t RDP; uint16_t user_options; + uint16_t user_data; uint16_t protection[4]; }; @@ -121,6 +122,7 @@ struct stm32x_flash_bank { bool has_dual_banks; /* used to access dual flash bank stm32xl */ uint32_t register_base; + int user_data_offset; }; static int stm32x_mass_erase(struct flash_bank *bank); @@ -229,6 +231,7 @@ static int stm32x_read_options(struct flash_bank *bank) return retval; stm32x_info->option_bytes.user_options = (uint16_t)0xFFF8 | ((optiondata >> 2) & 0x07); + stm32x_info->option_bytes.user_data = (optiondata >> stm32x_info->user_data_offset) & 0xffff; stm32x_info->option_bytes.RDP = (optiondata & (1 << OPT_READOUT)) ? 0xFFFF : 0x5AA5; if (optiondata & (1 << OPT_READOUT)) @@ -325,8 +328,8 @@ static int stm32x_write_options(struct flash_bank *bank) target_buffer_set_u16(target, opt_bytes, stm32x_info->option_bytes.RDP); target_buffer_set_u16(target, opt_bytes + 2, stm32x_info->option_bytes.user_options); - target_buffer_set_u16(target, opt_bytes + 4, 0x00FF); - target_buffer_set_u16(target, opt_bytes + 6, 0x00FF); + target_buffer_set_u16(target, opt_bytes + 4, stm32x_info->option_bytes.user_data & 0xff); + target_buffer_set_u16(target, opt_bytes + 6, (stm32x_info->option_bytes.user_data >> 8) & 0xff); target_buffer_set_u16(target, opt_bytes + 8, stm32x_info->option_bytes.protection[0]); target_buffer_set_u16(target, opt_bytes + 10, stm32x_info->option_bytes.protection[1]); target_buffer_set_u16(target, opt_bytes + 12, stm32x_info->option_bytes.protection[2]); @@ -852,6 +855,7 @@ static int stm32x_probe(struct flash_bank *bank) stm32x_info->probed = 0; stm32x_info->register_base = FLASH_REG_BASE_B0; + stm32x_info->user_data_offset = 10; /* read stm32 device id register */ int retval = stm32x_get_device_id(bank, &device_id); @@ -891,6 +895,7 @@ static int stm32x_probe(struct flash_bank *bank) page_size = 2048; stm32x_info->ppage_size = 2; max_flash_size_in_kb = 256; + stm32x_info->user_data_offset = 16; break; case 0x428: /* value line High density */ page_size = 2048; @@ -907,11 +912,13 @@ static int stm32x_probe(struct flash_bank *bank) page_size = 2048; stm32x_info->ppage_size = 2; max_flash_size_in_kb = 256; + stm32x_info->user_data_offset = 16; break; case 0x440: /* stm32f0x */ page_size = 1024; stm32x_info->ppage_size = 4; max_flash_size_in_kb = 64; + stm32x_info->user_data_offset = 16; break; default: LOG_WARNING("Cannot identify target as a STM32 family."); @@ -1338,6 +1345,11 @@ COMMAND_HANDLER(stm32x_handle_options_read_command) command_print(CMD_CTX, "Boot: Bank 1"); } + command_print(CMD_CTX, "User Option0: 0x%02" PRIx8, + (optionbyte >> stm32x_info->user_data_offset) & 0xff); + command_print(CMD_CTX, "User Option1: 0x%02" PRIx8, + (optionbyte >> (stm32x_info->user_data_offset + 8)) & 0xff); + return ERROR_OK; }