summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-05-14 12:09:54 +0800
committerVincent Palatin <vpalatin@chromium.org>2013-05-16 09:24:25 -0700
commitbbb45119ad1e05d1734dc037273ce9173b13926d (patch)
tree3e7bd4c9e37159235ca0604be72aa596061e5ba0 /chip
parenta7b1510f24ab1986d72b0a8a10a0227ac5f7aa60 (diff)
downloadchrome-ec-bbb45119ad1e05d1734dc037273ce9173b13926d.tar.gz
Add console command to force enable console
When system is locked, the console is disabled. However, we need console for debugging and testing. This CL uses a bit from back-up register to indicate if the console should always be enabled. (This bit is currently used by fake WP, which is removed in this CL.) With this, we can set this bit with console command 'forceen 1' to ensure console is never disabled. To prevent device shipped in this state, the chip name is postfixed with '-unsafe' so that the device is not able to pass HWID check. BUG=chrome-os-partner:19293 TEST=Manual BRANCH=spring Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/51086 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit c8b7b430fe5e4aa3d5f27fbd160dfee31254e36d) Change-Id: I095c5e2ac548d6dbc825ac7a141065ec2b8588c1 Reviewed-on: https://gerrit.chromium.org/gerrit/51474 Tested-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/stm32/flash-stm32f100.c31
-rw-r--r--chip/stm32/system.c34
2 files changed, 17 insertions, 48 deletions
diff --git a/chip/stm32/flash-stm32f100.c b/chip/stm32/flash-stm32f100.c
index 7932a85df4..45ce7e4bfc 100644
--- a/chip/stm32/flash-stm32f100.c
+++ b/chip/stm32/flash-stm32f100.c
@@ -81,10 +81,6 @@ struct flash_wp_state {
int entire_flash_locked;
};
-/* Functions defined in system.c to access backup registers */
-int system_set_fake_wp(int val);
-int system_get_fake_wp(void);
-
static int write_optb(int byte, uint8_t value);
static int wait_busy(void)
@@ -604,7 +600,7 @@ uint32_t flash_get_protect(void)
int i;
int not_protected[2] = {0};
- if (system_get_fake_wp() || !gpio_get_level(GPIO_WRITE_PROTECTn))
+ if (!gpio_get_level(GPIO_WRITE_PROTECTn))
flags |= EC_FLASH_PROTECT_GPIO_ASSERTED;
/* Read the current persist state from flash */
@@ -677,31 +673,6 @@ int flash_set_protect(uint32_t mask, uint32_t flags)
}
/*****************************************************************************/
-/* Console commands */
-
-static int command_set_fake_wp(int argc, char **argv)
-{
- int val;
- char *e;
-
- if (argc < 2)
- return EC_ERROR_PARAM_COUNT;
-
- val = strtoi(argv[1], &e, 0);
- if (*e)
- return EC_ERROR_PARAM1;
-
- system_set_fake_wp(val);
- ccprintf("Fake write protect = %d\n", val);
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(fakewp, command_set_fake_wp,
- "<0 | 1>",
- "Set fake write protect pin",
- NULL);
-
-/*****************************************************************************/
/* Hooks */
static void flash_preserve_state(void)
diff --git a/chip/stm32/system.c b/chip/stm32/system.c
index 56028ee923..b973a9592f 100644
--- a/chip/stm32/system.c
+++ b/chip/stm32/system.c
@@ -13,10 +13,7 @@
#include "version.h"
#include "watchdog.h"
-/*
- * TODO: Fake WP is stored at most significant bit of saved reset flags to save
- * space. Remove it when we have real write protect pin
- */
+#define CONSOLE_BIT_MASK 0x8000
enum bkpdata_index {
BKPDATA_INDEX_SCRATCHPAD, /* General-purpose scratchpad */
@@ -64,15 +61,15 @@ static void check_reset_cause(void)
uint32_t raw_cause = STM32_RCC_CSR;
uint32_t pwr_status = STM32_PWR_CSR;
- uint32_t fake_wp = flags & 0x8000;
- flags &= ~0x8000;
+ uint32_t console_en = flags & CONSOLE_BIT_MASK;
+ flags &= ~CONSOLE_BIT_MASK;
/* Clear the hardware reset cause by setting the RMVF bit */
STM32_RCC_CSR |= 1 << 24;
/* Clear SBF in PWR_CSR */
STM32_PWR_CR |= 1 << 3;
/* Clear saved reset flags */
- bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, 0 | fake_wp);
+ bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, 0 | console_en);
if (raw_cause & 0x60000000) {
/*
@@ -148,8 +145,8 @@ void system_reset(int flags)
{
uint32_t save_flags = 0;
- uint32_t fake_wp =
- bkpdata_read(BKPDATA_INDEX_SAVED_RESET_FLAGS) & 0x8000;
+ uint32_t console_en = bkpdata_read(BKPDATA_INDEX_SAVED_RESET_FLAGS) &
+ CONSOLE_BIT_MASK;
/* Disable interrupts to avoid task swaps during reboot */
interrupt_disable();
@@ -171,7 +168,7 @@ void system_reset(int flags)
if (flags & SYSTEM_RESET_HARD)
save_flags |= RESET_FLAG_HARD;
- bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, save_flags | fake_wp);
+ bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, save_flags | console_en);
if (flags & SYSTEM_RESET_HARD) {
/* Ask the watchdog to trigger a hard reboot */
@@ -210,7 +207,10 @@ const char *system_get_chip_vendor(void)
const char *system_get_chip_name(void)
{
- return STRINGIFY(CHIP_VARIANT);
+ if (system_get_console_force_enabled())
+ return STRINGIFY(CHIP_VARIANT-unsafe);
+ else
+ return STRINGIFY(CHIP_VARIANT);
}
const char *system_get_chip_revision(void)
@@ -251,23 +251,21 @@ int system_set_vbnvcontext(const uint8_t *block)
return EC_SUCCESS;
}
-/* TODO: crosbug.com/p/12036 */
-int system_set_fake_wp(int val)
+int system_set_console_force_enabled(int val)
{
uint16_t flags = bkpdata_read(BKPDATA_INDEX_SAVED_RESET_FLAGS);
if (val)
- flags |= 0x8000;
+ flags |= CONSOLE_BIT_MASK;
else
- flags &= ~0x8000;
+ flags &= ~CONSOLE_BIT_MASK;
return bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, flags);
}
-/* TODO: crosbug.com/p/12036 */
-int system_get_fake_wp(void)
+int system_get_console_force_enabled(void)
{
- if (bkpdata_read(BKPDATA_INDEX_SAVED_RESET_FLAGS) & 0x8000)
+ if (bkpdata_read(BKPDATA_INDEX_SAVED_RESET_FLAGS) & CONSOLE_BIT_MASK)
return 1;
else
return 0;