HAL_FLASH_ERROR_WRP
embedded
config_error
ai_generated
true
错误:扇区 5 闪存写保护违规
Error: flash write protection violation at sector 5
ID: embedded/flash-write-protection-violation
90%修复率
85%置信度
1证据数
2025-01-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| STM32Cube FW_F4 V1.27.1 | active | — | — | — |
| STM32Cube FW_L4 V1.17.2 | active | — | — | — |
| IAR EWARM 8.50.6 | active | — | — | — |
根因分析
通过选项字节或 WRP 寄存器对闪存扇区进行了写保护,阻止了编程或擦除操作。
English
Flash sector is write-protected via option bytes or WRP register, preventing programming or erase operations.
官方文档
https://www.st.com/resource/en/reference_manual/dm00031020.pdf解决方案
-
Disable write protection via option bytes: HAL_FLASH_OB_Unlock(); FLASH_OB_WRPConfig(OB_WRP_SECTOR_5, DISABLE); HAL_FLASH_OB_Launch();
-
Use STM32CubeProgrammer to clear protection: connect to target, go to Option Bytes, disable WRP for sector 5, apply.
无效尝试
常见但无效的做法:
-
Erase entire flash memory using mass erase
80% 失败
Mass erase also respects write protection; protected sectors remain unerased.
-
Change linker script to place data in a different sector
65% 失败
The target sector is still write-protected; linker change only redirects writes but does not remove protection.