Watchdog is reloaded by HOOK_TICK, not its own task

This reduces memory footprint.

BUG=chrome-os-partner:15714
BRANCH=none
TEST=system still boots; 'waitms 1500' prints watchdog error dump

Change-Id: Ieb0248a34655514b03d919cc36c2b369691da716
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36937
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Randall Spangler
2012-10-30 12:16:54 -07:00
committed by Gerrit
parent a21ea56e76
commit 8b3a242ff0
34 changed files with 42 additions and 52 deletions

View File

@@ -16,6 +16,5 @@
*/
#define CONFIG_TASK_LIST \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(LIGHTBAR, lightbar_task, NULL, TASK_STACK_SIZE) \
TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE)

View File

@@ -16,7 +16,6 @@
*/
#define CONFIG_TASK_LIST \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(POWERLED, power_led_task, NULL, TASK_STACK_SIZE) \
TASK(PMU_TPS65090_CHARGER, pmu_charger_task, NULL, TASK_STACK_SIZE) \

View File

@@ -16,7 +16,6 @@
*/
#define CONFIG_TASK_LIST \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(WATCHDOG, watchdog_task, NULL, WATCHDOG_TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK(LIGHTBAR, lightbar_task, NULL, TASK_STACK_SIZE) \
TASK(CHARGER, charge_state_machine_task, NULL, TASK_STACK_SIZE) \

View File

@@ -16,7 +16,6 @@
*/
#define CONFIG_TASK_LIST \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(WATCHDOG, watchdog_task, NULL, 256) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(POWERLED, power_led_task, NULL, 256) \
TASK(PMU_TPS65090_CHARGER, pmu_charger_task, NULL, TASK_STACK_SIZE) \

View File

@@ -16,7 +16,6 @@
*/
#define CONFIG_TASK_LIST \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(WATCHDOG, watchdog_task, NULL, 256) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(PMU_TPS65090_CHARGER, pmu_charger_task, NULL, TASK_STACK_SIZE) \
TASK(KEYSCAN, keyboard_scan_task, NULL, 256) \

View File

@@ -10,7 +10,7 @@
CORE:=cortex-m
# Required chip modules
chip-y=clock.o gpio.o hwtimer.o jtag.o system.o uart.o watchdog.o
chip-y=clock.o gpio.o hwtimer.o jtag.o system.o uart.o
# Optional chip modules
chip-$(CONFIG_ADC)+=adc.o
@@ -25,3 +25,4 @@ chip-$(CONFIG_TASK_PWM)+=pwm.o
chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_scan.o keyboard_scan_stub.o
chip-$(CONFIG_TASK_SWITCH)+=switch.o
chip-$(CONFIG_TASK_TEMPSENSOR)+=chip_temp_sensor.o
chip-$(CONFIG_WATCHDOG)+=watchdog.o

View File

@@ -29,7 +29,6 @@
/* non-standard task stack sizes */
#define IDLE_TASK_STACK_SIZE 384
#define WATCHDOG_TASK_STACK_SIZE 256
#define LARGER_TASK_STACK_SIZE 640
/* Default task stack size */
@@ -89,6 +88,7 @@
#define CONFIG_FLASH
#define CONFIG_FPU
#define CONFIG_I2C
#define CONFIG_WATCHDOG
/* Compile for running from RAM instead of flash */
/* #define COMPILE_FOR_RAM */

View File

@@ -171,7 +171,7 @@ static int write_buffer(void)
/* Start write operation at page boundary */
LM4_FLASH_FMC2 = 0xa4420001;
#ifdef CONFIG_TASK_WATCHDOG
#ifdef CONFIG_WATCHDOG
/* Reload the watchdog timer, so that writing a large amount of flash
* doesn't cause a watchdog reset. */
watchdog_reload();
@@ -240,7 +240,7 @@ int flash_physical_erase(int offset, int size)
LM4_FLASH_FMA = offset;
#ifdef CONFIG_TASK_WATCHDOG
#ifdef CONFIG_WATCHDOG
/* Reload the watchdog timer, so that erasing many flash pages
* doesn't cause a watchdog reset. May not need this now that
* we're using msleep() below. */

View File

@@ -5,10 +5,8 @@
/* Watchdog driver */
#include "board.h"
#include "clock.h"
#include "common.h"
#include "config.h"
#include "registers.h"
#include "gpio.h"
#include "hooks.h"
@@ -79,6 +77,7 @@ void watchdog_reload(void)
/* Re-lock watchdog registers */
LM4_WATCHDOG_LOCK(0) = 0xdeaddead;
}
DECLARE_HOOK(HOOK_TICK, watchdog_reload, HOOK_PRIO_DEFAULT);
static void watchdog_freq_changed(void)
{

View File

@@ -13,7 +13,7 @@ chip-y=dma.o gpio.o hwtimer.o system.o uart.o
chip-y+=jtag-$(CHIP_VARIANT).o clock-$(CHIP_VARIANT).o gpio-$(CHIP_VARIANT).o
chip-$(CONFIG_SPI)+=spi.o
chip-$(CONFIG_I2C)+=i2c.o
chip-$(CONFIG_TASK_WATCHDOG)+=watchdog.o
chip-$(CONFIG_WATCHDOG)+=watchdog.o
chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_scan.o
chip-$(CONFIG_TASK_POWERLED)+=power_led.o
chip-$(CONFIG_FLASH)+=flash-$(CHIP_VARIANT).o

View File

@@ -33,6 +33,9 @@
/* build with assertions and debug messages */
#define CONFIG_DEBUG
/* Enable watchdog timer */
#define CONFIG_WATCHDOG
/* Compile for running from RAM instead of flash */
/* #define COMPILE_FOR_RAM */

View File

@@ -314,7 +314,7 @@ int flash_physical_write(int offset, int size, const char *data)
STM32_FLASH_CR |= PG;
for ( ; size > 0; size -= sizeof(uint16_t)) {
#ifdef CONFIG_TASK_WATCHDOG
#ifdef CONFIG_WATCHDOG
/* Reload the watchdog timer to avoid watchdog reset when doing
* long writing with interrupt disabled.
*/
@@ -383,7 +383,7 @@ int flash_physical_erase(int offset, int size)
/* set STRT bit : start erase */
STM32_FLASH_CR |= STRT;
#ifdef CONFIG_TASK_WATCHDOG
#ifdef CONFIG_WATCHDOG
/*
* Reload the watchdog timer to avoid watchdog reset during a
* long erase operation.

View File

@@ -189,7 +189,7 @@ int flash_physical_write(int offset, int size, const char *data)
for (address = (uint32_t *)(CONFIG_FLASH_BASE + offset) ;
size > 0; size -= CONFIG_FLASH_WRITE_SIZE) {
#ifdef CONFIG_TASK_WATCHDOG
#ifdef CONFIG_WATCHDOG
/*
* Reload the watchdog timer to avoid watchdog reset when doing
* long writing with interrupt disabled.
@@ -249,7 +249,7 @@ int flash_physical_erase(int offset, int size)
/* Start erase */
*address = 0x00000000;
#ifdef CONFIG_TASK_WATCHDOG
#ifdef CONFIG_WATCHDOG
/*
* Reload the watchdog timer to avoid watchdog reset during
* multi-page erase operations.

View File

@@ -5,12 +5,11 @@
/* Watchdog driver */
#include "board.h"
#include "common.h"
#include "config.h"
#include "registers.h"
#include "gpio.h"
#include "hooks.h"
#include "hwtimer.h"
#include "registers.h"
#include "task.h"
#include "timer.h"
#include "util.h"
@@ -56,6 +55,7 @@ void watchdog_reload(void)
hwtimer_reset_watchdog();
#endif
}
DECLARE_HOOK(HOOK_TICK, watchdog_reload, HOOK_PRIO_DEFAULT);
int watchdog_init(void)
{

View File

@@ -95,7 +95,7 @@ int main(void)
CPRINTF("[Image: %s, %s]\n",
system_get_image_copy_string(), system_get_build_info());
#ifdef CONFIG_TASK_WATCHDOG
#ifdef CONFIG_WATCHDOG
/*
* Intialize watchdog timer. All lengthy operations between now and
* task_start() must periodically call watchdog_reload() to avoid

View File

@@ -14,4 +14,4 @@ CFLAGS_CPU=-mcpu=cortex-m4 -mthumb -Os -mno-sched-prolog
CFLAGS_CPU+=$(CFLAGS_FPU-y)
core-y=cpu.o init.o panic.o switch.o task.o timer.o
core-$(CONFIG_TASK_WATCHDOG)+=watchdog.o
core-$(CONFIG_WATCHDOG)+=watchdog.o

View File

@@ -39,12 +39,3 @@ void watchdog_trace(uint32_t excep_lr, uint32_t excep_sp)
timer_print_info();
task_print_list();
}
/* Low priority task to reload the watchdog */
void watchdog_task(void)
{
while (1) {
msleep(WATCHDOG_RELOAD_MS);
watchdog_reload();
}
}

View File

@@ -8,16 +8,15 @@
#ifndef __CROS_EC_WATCHDOG_H
#define __CROS_EC_WATCHDOG_H
#define WATCHDOG_PERIOD_MS 1100 /* Watchdog period in ms */
/* Watchdog period in ms; must be at least twice HOOK_TICK_INTERVAL */
#define WATCHDOG_PERIOD_MS 1100
/*
* Interval in ms between reloads of the watchdog timer. Should be less
* than half of the watchdog period.
/**
* Initialize the watchdog.
*
* This will cause the CPU to reboot if it has been more than 2 watchdog
* periods since watchdog_reload() has been called.
*/
#define WATCHDOG_RELOAD_MS 500
/* Initialize the watchdog. This will cause the CPU to reboot if it has been
* more than 2 watchdog periods since watchdog_reload() has been called. */
int watchdog_init(void);
/**

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \
TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE)

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE)

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE)

View File

@@ -14,7 +14,7 @@
* 'd' in an opaque parameter passed to the routine at startup
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \
TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \
TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \
TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,5 +15,6 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
TASK(POWERDEMO, power_demo_task, NULL, TASK_STACK_SIZE)

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \
TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(TEMPSENSOR, temp_sensor_task, NULL, TASK_STACK_SIZE) \
TASK(THERMAL, thermal_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(TESTTMR, timer_calib_task, (void *)'T', TASK_STACK_SIZE) \
TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,6 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \

View File

@@ -15,7 +15,7 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL, TASK_STACK_SIZE) \
TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \
TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \
TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \