diff options
author | Bill Richardson <wfrichar@chromium.org> | 2016-09-29 23:48:45 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-10-02 15:19:21 -0700 |
commit | fd88db3e9a9b922fd73ebb4a446f0289bd7ab8f5 (patch) | |
tree | 355b43f6038165ee0a7590b1105972aefe7a5a47 | |
parent | 0a4bb34bcdde39f1cd21dd555d7284a8b1ce9cca (diff) | |
download | chrome-ec-fd88db3e9a9b922fd73ebb4a446f0289bd7ab8f5.tar.gz |
g: CONFIG_FLASH should be optional
The application may need to read/write/erase the flash memory,
but we not want console users to do so. This CL adds
CONFIG_FLASH_PHYSICAL, which allows the higher-level CONFIG_FLASH
to be undefined while still providing the chip-specific
flash_physical_* accessor functions.
There aren't many board.h files that needed changes, since
CONFIG_FLASH_PHYSICAL is enabled by default, just like CONFIG_FLASH.
BUG=chrome-os-partner:57408
BRANCH=none
TEST=make buildall; try on Gru with and without CR50_DEV=1
See that it still boots, updates, wipes, restores, etc. without
linking common/flash.o in the production image; and that the
flash commands are still there in the dev build.
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I7eb1bbcb414b1c70ee427c4fcb5cea899dbb9e93
Reviewed-on: https://chromium-review.googlesource.com/391188
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r-- | board/hadoken/board.h | 1 | ||||
-rw-r--r-- | board/stm32l476g-eval/board.h | 1 | ||||
-rw-r--r-- | board/zinger/board.h | 1 | ||||
-rw-r--r-- | chip/g/build.mk | 2 | ||||
-rw-r--r-- | chip/g/upgrade_fw.c | 4 | ||||
-rw-r--r-- | chip/it83xx/build.mk | 2 | ||||
-rw-r--r-- | chip/lm4/build.mk | 2 | ||||
-rw-r--r-- | chip/mec1322/build.mk | 2 | ||||
-rw-r--r-- | chip/npcx/build.mk | 2 | ||||
-rw-r--r-- | chip/stm32/build.mk | 4 | ||||
-rw-r--r-- | common/main.c | 2 | ||||
-rw-r--r-- | include/config.h | 5 |
12 files changed, 16 insertions, 12 deletions
diff --git a/board/hadoken/board.h b/board/hadoken/board.h index f844013f15..d644f649fa 100644 --- a/board/hadoken/board.h +++ b/board/hadoken/board.h @@ -11,6 +11,7 @@ #ifndef __ASSEMBLER__ #undef CONFIG_FLASH /* TODO: implement me */ +#undef CONFIG_FLASH_PHYSICAL /* TODO: implement me */ #undef CONFIG_FMAP /* TODO: implement me */ #undef CONFIG_WATCHDOG #undef CONFIG_LID_SWITCH diff --git a/board/stm32l476g-eval/board.h b/board/stm32l476g-eval/board.h index 7ce7875ac6..5cfc5b0870 100644 --- a/board/stm32l476g-eval/board.h +++ b/board/stm32l476g-eval/board.h @@ -38,6 +38,7 @@ #ifndef __ASSEMBLER__ #undef CONFIG_FLASH +#undef CONFIG_FLASH_PHYSICAL /* Timer selection */ #define TIM_CLOCK32 5 diff --git a/board/zinger/board.h b/board/zinger/board.h index dcd1f8bcc1..5945d6c639 100644 --- a/board/zinger/board.h +++ b/board/zinger/board.h @@ -38,6 +38,7 @@ #undef CONFIG_DEBUG_EXCEPTIONS #undef CONFIG_DEBUG_STACK_OVERFLOW #undef CONFIG_FLASH +#undef CONFIG_FLASH_PHYSICAL #undef CONFIG_FMAP /* Not using pstate but keep some space for the public key */ #undef CONFIG_FW_PSTATE_SIZE diff --git a/chip/g/build.mk b/chip/g/build.mk index 184184abea..6e71d6f210 100644 --- a/chip/g/build.mk +++ b/chip/g/build.mk @@ -66,7 +66,7 @@ chip-$(CONFIG_I2C_SLAVE)+= i2cs.o chip-$(CONFIG_LOW_POWER_IDLE)+=idle.o -chip-$(CONFIG_FLASH)+=flash.o +chip-$(CONFIG_FLASH_PHYSICAL) += flash.o dirs-y += chip/g/dcrypto ifneq ($(CONFIG_CUSTOMIZED_RO),) diff --git a/chip/g/upgrade_fw.c b/chip/g/upgrade_fw.c index a1c52cb56a..25da3b060a 100644 --- a/chip/g/upgrade_fw.c +++ b/chip/g/upgrade_fw.c @@ -101,7 +101,7 @@ static uint8_t check_update_chunk(uint32_t block_offset, size_t body_size) * be erased. */ if (block_offset == valid_sections.rw_base_offset) { - if (flash_erase(base, size) != EC_SUCCESS) { + if (flash_physical_erase(base, size) != EC_SUCCESS) { CPRINTF("%s:%d erase failure of 0x%x..+0x%x\n", __func__, __LINE__, base, size); return UPGRADE_ERASE_FAILURE; @@ -128,7 +128,7 @@ static uint8_t check_update_chunk(uint32_t block_offset, size_t body_size) valid_sections.ro_base_offset; /* backup RO area write access needs to be enabled. */ open_ro_window(base, size); - if (flash_erase(base, size) != EC_SUCCESS) { + if (flash_physical_erase(base, size) != EC_SUCCESS) { CPRINTF("%s:%d erase failure of 0x%x..+0x%x\n", __func__, __LINE__, base, size); return UPGRADE_ERASE_FAILURE; diff --git a/chip/it83xx/build.mk b/chip/it83xx/build.mk index 9d4191aad4..47820aba34 100644 --- a/chip/it83xx/build.mk +++ b/chip/it83xx/build.mk @@ -17,7 +17,7 @@ chip-y=hwtimer.o uart.o gpio.o system.o jtag.o clock.o irq.o intc.o # Optional chip modules chip-$(CONFIG_WATCHDOG)+=watchdog.o chip-$(CONFIG_FANS)+=fan.o pwm.o -chip-$(CONFIG_FLASH)+=flash.o +chip-$(CONFIG_FLASH_PHYSICAL)+=flash.o chip-$(CONFIG_PWM)+=pwm.o chip-$(CONFIG_ADC)+=adc.o chip-$(CONFIG_EC2I)+=ec2i.o diff --git a/chip/lm4/build.mk b/chip/lm4/build.mk index 279f15c65d..3253ebd478 100644 --- a/chip/lm4/build.mk +++ b/chip/lm4/build.mk @@ -18,7 +18,7 @@ chip-y=clock.o gpio.o hwtimer.o jtag.o system.o uart.o chip-$(CONFIG_ADC)+=adc.o chip_temp_sensor.o chip-$(CONFIG_EEPROM)+=eeprom.o chip-$(CONFIG_FANS)+=fan.o -chip-$(CONFIG_FLASH)+=flash.o +chip-$(CONFIG_FLASH_PHYSICAL)+=flash.o chip-$(CONFIG_I2C)+=i2c.o chip-$(CONFIG_LPC)+=lpc.o chip-$(CONFIG_PECI)+=peci.o diff --git a/chip/mec1322/build.mk b/chip/mec1322/build.mk index f2c5cf80a0..615697be0b 100644 --- a/chip/mec1322/build.mk +++ b/chip/mec1322/build.mk @@ -20,7 +20,7 @@ endif chip-y=clock.o gpio.o hwtimer.o system.o uart.o jtag.o port80.o chip-$(CONFIG_ADC)+=adc.o chip-$(CONFIG_FANS)+=fan.o -chip-$(CONFIG_FLASH)+=flash.o +chip-$(CONFIG_FLASH_PHYSICAL)+=flash.o chip-$(CONFIG_I2C)+=i2c.o chip-$(CONFIG_LPC)+=lpc.o chip-$(CONFIG_PWM)+=pwm.o diff --git a/chip/npcx/build.mk b/chip/npcx/build.mk index bf0ddf69d7..2814366ffb 100644 --- a/chip/npcx/build.mk +++ b/chip/npcx/build.mk @@ -17,7 +17,7 @@ chip-y=header.o clock.o gpio.o hwtimer.o jtag.o system.o uart.o # Optional chip modules chip-$(CONFIG_ADC)+=adc.o chip-$(CONFIG_FANS)+=fan.o -chip-$(CONFIG_FLASH)+=flash.o +chip-$(CONFIG_FLASH_PHYSICAL)+=flash.o chip-$(CONFIG_I2C)+=i2c.o chip-$(CONFIG_LPC)+=lpc.o chip-$(CONFIG_ESPI)+=espi.o diff --git a/chip/stm32/build.mk b/chip/stm32/build.mk index 3e1e11ab32..52749e1d16 100644 --- a/chip/stm32/build.mk +++ b/chip/stm32/build.mk @@ -47,8 +47,8 @@ chip-$(CONFIG_WATCHDOG)+=watchdog.o chip-$(HAS_TASK_CONSOLE)+=uart.o chip-$(HAS_TASK_KEYSCAN)+=keyboard_raw.o chip-$(HAS_TASK_POWERLED)+=power_led.o -chip-$(CONFIG_FLASH)+=flash-$(CHIP_FAMILY).o -ifdef CONFIG_FLASH +chip-$(CONFIG_FLASH_PHYSICAL)+=flash-$(CHIP_FAMILY).o +ifdef CONFIG_FLASH_PHYSICAL chip-$(CHIP_FAMILY_STM32F0)+=flash-f.o chip-$(CHIP_FAMILY_STM32F3)+=flash-f.o endif diff --git a/common/main.c b/common/main.c index 4b537a79da..4c5d580ddd 100644 --- a/common/main.c +++ b/common/main.c @@ -79,7 +79,7 @@ test_mockable __keep int main(void) system_pre_init(); system_common_pre_init(); -#ifdef CONFIG_FLASH +#if defined(CONFIG_FLASH_PHYSICAL) /* * Initialize flash and apply write protect if necessary. Requires * the reset flags calculated by system initialization. diff --git a/include/config.h b/include/config.h index 291c9e934e..ec60514cc4 100644 --- a/include/config.h +++ b/include/config.h @@ -868,9 +868,10 @@ /*****************************************************************************/ /* Flash configuration */ -/* Support programming on-chip flash */ +/* This enables console commands and higher-level features */ #define CONFIG_FLASH - +/* This enables chip-specific access functions */ +#define CONFIG_FLASH_PHYSICAL #undef CONFIG_FLASH_BANK_SIZE #undef CONFIG_FLASH_ERASED_VALUE32 #undef CONFIG_FLASH_ERASE_SIZE |