From 89bcc93547212bd915b46a4c6df7f4e754cc4f0f Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Wed, 20 Jan 2016 18:50:25 -0800 Subject: [PATCH] stm32f0: flash: Don't check protect bits for flash that doesn't exist Each pair of protect bits locks 4K, so for parts with 64K flash, don't bother checking STM32_OPTB_WRP23. BUG=chrome-os-partner:49354 TEST=Run flashrom to protect PD MCU (see repro steps on linked crbug), reboot and verify system boots into dev mode with all_at_boot and all_now protect flags set on PD MCU. BRANCH=glados Signed-off-by: Shawn Nematbakhsh Change-Id: Ic375d97c30bfd68940350641c44d5535b0402a2f Reviewed-on: https://chromium-review.googlesource.com/322823 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Vincent Palatin --- chip/stm32/flash-stm32f0.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chip/stm32/flash-stm32f0.c b/chip/stm32/flash-stm32f0.c index 85e65c6ac4..229fd108af 100644 --- a/chip/stm32/flash-stm32f0.c +++ b/chip/stm32/flash-stm32f0.c @@ -21,13 +21,18 @@ uint32_t flash_physical_get_protect_flags(void) { uint32_t flags = 0; uint32_t wrp01 = REG32(STM32_OPTB_BASE + STM32_OPTB_WRP01); +#if CONFIG_FLASH_SIZE > 64 * 1024 uint32_t wrp23 = REG32(STM32_OPTB_BASE + STM32_OPTB_WRP23); +#endif if (STM32_FLASH_WRPR == 0) flags |= EC_FLASH_PROTECT_ALL_NOW; - if (wrp01 == 0xff00ff00 && wrp23 == 0xff00ff00) - flags |= EC_FLASH_PROTECT_ALL_AT_BOOT; + if (wrp01 == 0xff00ff00) +#if CONFIG_FLASH_SIZE > 64 * 1024 + if (wrp23 == 0xff00ff00) +#endif + flags |= EC_FLASH_PROTECT_ALL_AT_BOOT; return flags; }