{
  "id": "embedded/flash-write-protection-violation",
  "signature": "Error: flash write protection violation at sector 5",
  "signature_zh": "错误：扇区 5 闪存写保护违规",
  "regex": "Error: flash write protection violation at sector \\d+",
  "domain": "embedded",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Flash sector is write-protected via option bytes or WRP register, preventing programming or erase operations.",
  "root_cause_type": "generic",
  "root_cause_zh": "通过选项字节或 WRP 寄存器对闪存扇区进行了写保护，阻止了编程或擦除操作。",
  "versions": [
    {
      "version": "STM32Cube FW_F4 V1.27.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "STM32Cube FW_L4 V1.17.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "IAR EWARM 8.50.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Erase entire flash memory using mass erase",
      "why_fails": "Mass erase also respects write protection; protected sectors remain unerased.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Change linker script to place data in a different sector",
      "why_fails": "The target sector is still write-protected; linker change only redirects writes but does not remove protection.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Disable write protection via option bytes: HAL_FLASH_OB_Unlock(); FLASH_OB_WRPConfig(OB_WRP_SECTOR_5, DISABLE); HAL_FLASH_OB_Launch();",
      "success_rate": 0.9,
      "how": "Disable write protection via option bytes: HAL_FLASH_OB_Unlock(); FLASH_OB_WRPConfig(OB_WRP_SECTOR_5, DISABLE); HAL_FLASH_OB_Launch();",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use STM32CubeProgrammer to clear protection: connect to target, go to Option Bytes, disable WRP for sector 5, apply.",
      "success_rate": 0.95,
      "how": "Use STM32CubeProgrammer to clear protection: connect to target, go to Option Bytes, disable WRP for sector 5, apply.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.st.com/resource/en/reference_manual/dm00031020.pdf",
  "official_doc_section": null,
  "error_code": "HAL_FLASH_ERROR_WRP",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2025-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}