While trying to enable and disable write protect the problem arises that on a stm32f071 only the first 16 sectors can be enabled/disabled the latter 16 sectors cannot be changed.
Furthermore, "flash info 0" shows a sector size of 8KB (which is wrong, it should be 4KB according to the stm32f0x reference manual - see https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf page 54)
The root cause is the wrongly configured ppage_size (1 sector is 2 pages for stmf07/9x)
The following patch solves the issue for me, but I only have stm32f072 to test.
@@ -863,7 +863,7 @@ static int stm32x_probe(struct flash_bank bank)
break;
case 0x448: / stm32f07x /
page_size = 2048;
- stm32x_info->ppage_size = 4;
+ stm32x_info->ppage_size = 2;
max_flash_size_in_kb = 128;
stm32x_info->user_data_offset = 16;
stm32x_info->option_offset = 6;
@@ -872,7 +872,7 @@ static int stm32x_probe(struct flash_bank bank)
break;
case 0x442: / stm32f09x /
page_size = 2048;
- stm32x_info->ppage_size = 4;
+ stm32x_info->ppage_size = 2;
max_flash_size_in_kb = 256;
stm32x_info->user_data_offset = 16;
stm32x_info->option_offset = 6;