summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile22
-rw-r--r--Makefile.rules2
-rw-r--r--board/bds/build.mk2
-rw-r--r--board/bds/ec.tasklist2
-rw-r--r--board/link/build.mk2
-rw-r--r--board/link/ec.tasklist2
-rw-r--r--chip/lm4/build.mk7
-rw-r--r--chip/lm4/ec.lds.S1
-rw-r--r--chip/lm4/lpc.c4
-rw-r--r--chip/lm4/watchdog.c19
-rw-r--r--common/build.mk9
-rw-r--r--common/main.c20
-rw-r--r--test/build.mk8
-rw-r--r--test/hello.py1
-rw-r--r--test/hello.tasklist7
-rw-r--r--test/pingpong.tasklist8
-rw-r--r--test/powerdemo.tasklist2
-rw-r--r--test/timer_calib.tasklist8
-rw-r--r--test/timer_dos.tasklist8
19 files changed, 70 insertions, 64 deletions
diff --git a/Makefile b/Makefile
index 7f98ebc02b..c382b9407a 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,19 @@ PROJECT?=ec
# output directory for build objects
out?=build/$(BOARD)
+include Makefile.toolchain
+
+# Get CHIP name
+include board/$(BOARD)/build.mk
+
+# Transform the configuration into make variables
+_tsk_lst:=$(shell echo "CONFIG_TASK_LIST" | $(CPP) -P -Iboard/$(BOARD) -Itest \
+ -D"TASK(n, r, d)=n" -imacros $(PROJECT).tasklist)
+_tsk_cfg:=$(foreach t,$(_tsk_lst),CONFIG_TASK_$(t))
+_flag_cfg:=$(shell $(CPP) -P -dN chip/$(CHIP)/config.h | grep -o "CONFIG_.*")
+$(foreach c,$(_tsk_cfg) $(_flag_cfg),$(eval $(c)=y))
+CPPFLAGS+=$(foreach t,$(_tsk_cfg),-D$(t))
+
# Get build configuration from sub-directories
include board/$(BOARD)/build.mk
include chip/$(CHIP)/build.mk
@@ -22,12 +35,11 @@ include util/build.mk
objs_from_dir=$(foreach obj,$(2), $(out)/$(1)/$(obj))
# Get all sources to build
-all-objs=$(call objs_from_dir,chip/$(CHIP),$(chip-objs))
-all-objs+=$(call objs_from_dir,board/$(BOARD),$(board-objs))
-all-objs+=$(call objs_from_dir,common,$(common-objs))
-all-objs+=$(call objs_from_dir,test,$($(PROJECT)-objs))
+all-y=$(call objs_from_dir,chip/$(CHIP),$(chip-y))
+all-y+=$(call objs_from_dir,board/$(BOARD),$(board-y))
+all-y+=$(call objs_from_dir,common,$(common-y))
+all-y+=$(call objs_from_dir,test,$($(PROJECT)-y))
dirs=chip/$(CHIP) board/$(BOARD) common test util
includes=include $(dirs)
-include Makefile.toolchain
include Makefile.rules
diff --git a/Makefile.rules b/Makefile.rules
index bd2472e22c..096c886304 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -5,7 +5,7 @@
# Embedded Controller firmware build system - common targets
#
-objs := $(all-objs)
+objs := $(all-y)
deps := $(objs:%.o=%.o.d)
build-utils := $(foreach u,$(build-util-bin),$(out)/util/$(u))
host-utils := $(foreach u,$(host-util-bin),$(out)/util/$(u))
diff --git a/board/bds/build.mk b/board/bds/build.mk
index 94a6a3e3ac..d026221342 100644
--- a/board/bds/build.mk
+++ b/board/bds/build.mk
@@ -4,4 +4,4 @@
# the IC is TI Stellaris LM4
CHIP:=lm4
-board-objs=board.o
+board-y=board.o
diff --git a/board/bds/ec.tasklist b/board/bds/ec.tasklist
index fca1be2f40..a56e6769e1 100644
--- a/board/bds/ec.tasklist
+++ b/board/bds/ec.tasklist
@@ -14,7 +14,7 @@
* 'd' in an opaque parameter passed to the routine at startup
*/
#define CONFIG_TASK_LIST \
- TASK(BLINK, UserLedBlink, NULL) \
+ TASK(WATCHDOG, watchdog_task, NULL) \
TASK(KEYSCAN, keyboard_scan_task, NULL) \
TASK(POWERBTN, power_button_task, NULL) \
TASK(X86POWER, x86_power_task, NULL) \
diff --git a/board/link/build.mk b/board/link/build.mk
index 94e29df4bc..faf9968a45 100644
--- a/board/link/build.mk
+++ b/board/link/build.mk
@@ -8,4 +8,4 @@
# the IC is TI Stellaris LM4
CHIP:=lm4
-board-objs=board.o
+board-y=board.o
diff --git a/board/link/ec.tasklist b/board/link/ec.tasklist
index fca1be2f40..a56e6769e1 100644
--- a/board/link/ec.tasklist
+++ b/board/link/ec.tasklist
@@ -14,7 +14,7 @@
* 'd' in an opaque parameter passed to the routine at startup
*/
#define CONFIG_TASK_LIST \
- TASK(BLINK, UserLedBlink, NULL) \
+ TASK(WATCHDOG, watchdog_task, NULL) \
TASK(KEYSCAN, keyboard_scan_task, NULL) \
TASK(POWERBTN, power_button_task, NULL) \
TASK(X86POWER, x86_power_task, NULL) \
diff --git a/chip/lm4/build.mk b/chip/lm4/build.mk
index 585528f820..093b052e01 100644
--- a/chip/lm4/build.mk
+++ b/chip/lm4/build.mk
@@ -8,6 +8,7 @@
# CPU specific compilation flags
CFLAGS_CPU=-mcpu=cortex-m4 -mthumb -Os -mno-sched-prolog
-chip-objs=init.o panic.o switch.o task.o timer.o pwm.o i2c.o adc.o jtag.o
-chip-objs+=clock.o gpio.o system.o lpc.o uart.o power_button.o
-chip-objs+=flash.o watchdog.o eeprom.o keyboard_scan.o temp_sensor.o
+chip-y=init.o panic.o switch.o task.o timer.o pwm.o i2c.o adc.o jtag.o
+chip-y+=clock.o gpio.o system.o lpc.o uart.o power_button.o
+chip-y+=flash.o watchdog.o eeprom.o temp_sensor.o
+chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_scan.o
diff --git a/chip/lm4/ec.lds.S b/chip/lm4/ec.lds.S
index 5750967e3d..b64dea8398 100644
--- a/chip/lm4/ec.lds.S
+++ b/chip/lm4/ec.lds.S
@@ -30,6 +30,7 @@ SECTIONS
__irqprio = .;
*(.rodata.irqprio)
__irqprio_end = .;
+ . = ALIGN(4);
__cmds = .;
*(.rodata.cmds)
__cmds_end = .;
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c
index 00fdca02a2..5155befb3e 100644
--- a/chip/lm4/lpc.c
+++ b/chip/lm4/lpc.c
@@ -174,6 +174,7 @@ static void lpc_interrupt(void)
/* Clear the interrupt bits we're handling */
LM4_LPC_LPCIC = mis;
+#ifdef CONFIG_TASK_HOSTCMD
/* Handle host kernel/user command writes */
if (mis & LM4_LPC_INT_MASK(LPC_CH_KERNEL, 4)) {
/* Set the busy bit and clear the status */
@@ -193,11 +194,13 @@ static void lpc_interrupt(void)
* This clears the FRMH bit in the status byte. */
host_command_received(1, LPC_POOL_USER[0]);
}
+#endif
/* Handle port 80 writes (CH0MIS1) */
if (mis & LM4_LPC_INT_MASK(LPC_CH_PORT80, 2))
port_80_write(LPC_POOL_PORT80[0]);
+#ifdef CONFIG_TASK_I8042CMD
/* Handle port 60 command (CH3MIS2) and data (CH3MIS1) */
if (mis & LM4_LPC_INT_MASK(LPC_CH_KEYBOARD, 2)) {
/* Read the data byte and pass to the i8042 handler.
@@ -213,6 +216,7 @@ static void lpc_interrupt(void)
/* Host picks up the data, try to send remaining bytes */
task_send_msg(TASK_ID_I8042CMD, TASK_ID_I8042CMD, 0);
}
+#endif
/* Handle COMx */
if (mis & LM4_LPC_INT_MASK(LPC_CH_COMX, 2)) {
diff --git a/chip/lm4/watchdog.c b/chip/lm4/watchdog.c
index b0aa258bfd..ccc6e63b72 100644
--- a/chip/lm4/watchdog.c
+++ b/chip/lm4/watchdog.c
@@ -11,7 +11,9 @@
#include "common.h"
#include "config.h"
#include "registers.h"
+#include "gpio.h"
#include "task.h"
+#include "timer.h"
#include "uart.h"
#include "util.h"
@@ -135,3 +137,20 @@ int watchdog_init(int period_ms)
return EC_SUCCESS;
}
+
+/* Low priority task to reload the watchdog */
+void watchdog_task(void)
+{
+ while (1) {
+#ifdef BOARD_bds
+ gpio_set_level(GPIO_DEBUG_LED, 1);
+#endif
+ usleep(500000);
+ watchdog_reload();
+#ifdef BOARD_bds
+ gpio_set_level(GPIO_DEBUG_LED, 0);
+#endif
+ usleep(500000);
+ watchdog_reload();
+ }
+}
diff --git a/common/build.mk b/common/build.mk
index 28d454bf10..1024a8a0ad 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -5,6 +5,9 @@
# Common files build
#
-common-objs=main.o util.o console.o vboot.o x86_power.o pwm_commands.o
-common-objs+=flash_commands.o host_command.o port80.o keyboard.o i8042.o
-common-objs+=memory_commands.o shared_mem.o temp_sensor_commands.o usb_charge.o
+common-y=main.o util.o console.o vboot.o pwm_commands.o
+common-y+=flash_commands.o port80.o
+common-y+=memory_commands.o shared_mem.o temp_sensor_commands.o usb_charge.o
+common-$(CONFIG_TASK_HOSTCMD)+=host_command.o
+common-$(CONFIG_TASK_I8042CMD)+=i8042.o keyboard.o
+common-$(CONFIG_TASK_X86POWER)+=x86_power.o
diff --git a/common/main.c b/common/main.c
index 15a2547665..9fa1c0e7d6 100644
--- a/common/main.c
+++ b/common/main.c
@@ -34,24 +34,6 @@
#include "watchdog.h"
#include "usb_charge.h"
-/* example task blinking the user LED */
-/* TODO: This also kicks the watchdog, so MUST be present! */
-void UserLedBlink(void)
-{
- while (1) {
-#ifdef BOARD_bds
- gpio_set_level(GPIO_DEBUG_LED, 1);
-#endif
- usleep(500000);
- watchdog_reload();
-#ifdef BOARD_bds
- gpio_set_level(GPIO_DEBUG_LED, 0);
-#endif
- usleep(500000);
- watchdog_reload();
- }
-}
-
int main(void)
{
@@ -75,7 +57,9 @@ int main(void)
task_init();
+#ifdef CONFIG_TASK_WATCHDOG
watchdog_init(1100);
+#endif
timer_init();
uart_init();
system_init();
diff --git a/test/build.mk b/test/build.mk
index 20df88c04b..44739752a0 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -5,7 +5,7 @@
test-list=hello pingpong timer_calib timer_dos
#disable: powerdemo
-pingpong-objs=pingpong.o
-powerdemo-objs=powerdemo.o
-timer_calib-objs=timer_calib.o
-timer_dos-objs=timer_dos.o
+pingpong-y=pingpong.o
+powerdemo-y=powerdemo.o
+timer_calib-y=timer_calib.o
+timer_dos-y=timer_dos.o
diff --git a/test/hello.py b/test/hello.py
index 861cbf0bb4..a717185fd0 100644
--- a/test/hello.py
+++ b/test/hello.py
@@ -7,7 +7,6 @@
def test(helper):
helper.wait_output("--- Chrome EC initialized! ---")
- helper.wait_prompt()
helper.ec_command("version")
ro = helper.wait_output("RO version:\s*(?P<ro>\S+)", use_re=True)["ro"]
wa = helper.wait_output("RW-A version:\s*(?P<a>\S+)", use_re=True)["a"]
diff --git a/test/hello.tasklist b/test/hello.tasklist
index 923f91989e..7f07c8a959 100644
--- a/test/hello.tasklist
+++ b/test/hello.tasklist
@@ -14,9 +14,6 @@
* 'd' in an opaque parameter passed to the routine at startup
*/
#define CONFIG_TASK_LIST \
- TASK(BLINK, UserLedBlink, NULL) \
- TASK(GPIOISR, gpio_task, NULL) \
- TASK(KEYSCAN, keyboard_scan_task, NULL) \
+ TASK(WATCHDOG, watchdog_task, NULL) \
TASK(CONSOLE, console_task, NULL) \
- TASK(HOSTCMD, host_command_task, NULL) \
- TASK(I8042CMD, i8042_command_task, NULL)
+ TASK(HOSTCMD, host_command_task, NULL)
diff --git a/test/pingpong.tasklist b/test/pingpong.tasklist
index 6a5f528a1c..dd95534238 100644
--- a/test/pingpong.tasklist
+++ b/test/pingpong.tasklist
@@ -5,13 +5,9 @@
* The first one has the lowest priority.
*/
#define CONFIG_TASK_LIST \
- TASK(BLINK, UserLedBlink, NULL) \
- TASK(KEYSCAN, keyboard_scan_task, NULL) \
- TASK(GPIOISR, gpio_task, NULL) \
+ TASK(WATCHDOG, watchdog_task, NULL) \
TASK(CONSOLE, console_task, NULL) \
TASK(TESTA, TaskAbc, (void *)'A') \
TASK(TESTB, TaskAbc, (void *)'B') \
TASK(TESTC, TaskAbc, (void *)'C') \
- TASK(TESTT, TaskTick, (void *)'T')\
- TASK(HOSTCMD, host_command_task, NULL) \
- TASK(I8042CMD, i8042_command_task, NULL)
+ TASK(TESTT, TaskTick, (void *)'T')
diff --git a/test/powerdemo.tasklist b/test/powerdemo.tasklist
index 60c77a8285..e0f7466954 100644
--- a/test/powerdemo.tasklist
+++ b/test/powerdemo.tasklist
@@ -1,6 +1,4 @@
#define CONFIG_TASK_LIST \
TASK(CONSOLE, console_task, NULL) \
- TASK(HOSTCMD, host_command_task, NULL) \
- TASK(I8042CMD, i8042_command_task, NULL) \
TASK(POWERDEMO, power_demo_task, NULL)
diff --git a/test/timer_calib.tasklist b/test/timer_calib.tasklist
index ca184fb22c..eee74b4df7 100644
--- a/test/timer_calib.tasklist
+++ b/test/timer_calib.tasklist
@@ -5,10 +5,6 @@
* The first one has the lowest priority.
*/
#define CONFIG_TASK_LIST \
- TASK(BLINK, UserLedBlink, NULL) \
- TASK(KEYSCAN, keyboard_scan_task, NULL) \
- TASK(GPIOISR, gpio_task, NULL) \
+ TASK(WATCHDOG, watchdog_task, NULL) \
TASK(TESTTMR, timer_calib_task, (void *)'T')\
- TASK(CONSOLE, console_task, NULL) \
- TASK(HOSTCMD, host_command_task, NULL) \
- TASK(I8042CMD, i8042_command_task, NULL)
+ TASK(CONSOLE, console_task, NULL)
diff --git a/test/timer_dos.tasklist b/test/timer_dos.tasklist
index 8212088351..7fced26663 100644
--- a/test/timer_dos.tasklist
+++ b/test/timer_dos.tasklist
@@ -5,13 +5,9 @@
* The first one has the lowest priority.
*/
#define CONFIG_TASK_LIST \
- TASK(BLINK, UserLedBlink, NULL) \
- TASK(KEYSCAN, keyboard_scan_task, NULL) \
- TASK(GPIOISR, gpio_task, NULL) \
+ TASK(WATCHDOG, watchdog_task, NULL) \
TASK(CONSOLE, console_task, NULL) \
TASK(TMRA, TaskTimer, (void *)1234) \
TASK(TMRB, TaskTimer, (void *)5678) \
TASK(TMRC, TaskTimer, (void *)8462) \
- TASK(TMRD, TaskTimer, (void *)3719) \
- TASK(HOSTCMD, host_command_task, NULL)\
- TASK(I8042CMD, i8042_command_task, NULL)
+ TASK(TMRD, TaskTimer, (void *)3719)