summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2018-03-07 17:03:10 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-15 15:27:31 -0700
commit514c3b3e26edb3b05b466c5569894808cfdc4a91 (patch)
treeaa423d8e1a0a6827330aedf000f1b532425e40c7 /Makefile
parentabde1bca995f018f4c1df8dc24a0a33c18557871 (diff)
downloadchrome-ec-514c3b3e26edb3b05b466c5569894808cfdc4a91.tar.gz
ec: Add /baseboard to EC project
This CL introduces /baseboard to the EC project which can contain config options and code which is specific to certain family, but can be shared among the board derivatives of that family. Only the infrastructure changes are included with an empty baseboard.c/.h for octopus. BRANCH=none BUG=b:74358864 TEST='make buildall' and ensure that all boards build successfully. In addition, temporarily moved config options for USB-C and charger to baseboard.h and tested that 'make BOARD=yorp' is successful. Change-Id: I16656574f835c56598a9d2bf49bc1e946d71fe76 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/954444 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile41
1 files changed, 30 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 82932b6b93..5c311a0640 100644
--- a/Makefile
+++ b/Makefile
@@ -58,12 +58,25 @@ not_cfg = $(subst ro rw,y,$(filter-out $(1:y=ro rw),ro rw))
# The board makefile sets $CHIP and the chip makefile sets $CORE.
# Include those now, since they must be defined for _flag_cfg below.
include $(BDIR)/build.mk
+# Baseboard directory
+ifneq (,$(BASEBOARD))
+BASEDIR:=baseboard/$(BASEBOARD)
+CFLAGS_BASEBOARD=-DHAS_BASEBOARD -DBASEBOARD_$(UC_BASEBOARD)
+include $(BASEDIR)/build.mk
+else
+# If BASEBOARD is not defined, then assign BASEDIR to BDIR. This avoids
+# the need to have so many conditional checks wherever BASEDIR is used
+# below.
+BASEDIR:=$(BDIR)
+CFLAGS_BASEBOARD=
+endif
include chip/$(CHIP)/build.mk
# Create uppercase config variants, to avoid mixed case constants.
# Also translate '-' to '_', so 'cortex-m' turns into 'CORTEX_M'. This must
# be done before evaluating config.h.
uppercase = $(shell echo $(1) | tr '[:lower:]-' '[:upper:]_')
+UC_BASEBOARD:=$(call uppercase,$(BASEBOARD))
UC_BOARD:=$(call uppercase,$(BOARD))
UC_CHIP:=$(call uppercase,$(CHIP))
UC_CHIP_FAMILY:=$(call uppercase,$(CHIP_FAMILY))
@@ -72,8 +85,8 @@ UC_CORE:=$(call uppercase,$(CORE))
UC_PROJECT:=$(call uppercase,$(PROJECT))
# Transform the configuration into make variables. This must be done after
-# the board/project/chip/core variables are defined, since some of the configs
-# are dependent on particular configurations.
+# the board/baseboard/project/chip/core variables are defined, since some of
+# the configs are dependent on particular configurations.
includes=include core/$(CORE)/include $(dirs) $(out) test
ifdef CTS_MODULE
includes+=cts/$(CTS_MODULE) cts
@@ -90,7 +103,8 @@ else
_tsk_lst_flags:=
endif
-_tsk_lst_flags+=-I$(BDIR) -DBOARD_$(UC_BOARD) -D_MAKEFILE \
+_tsk_lst_flags+=-I$(BDIR) -DBOARD_$(UC_BOARD) -I$(BASEDIR) \
+ -DBASEBOARD_$(UC_BASEBOARD) -D_MAKEFILE \
-imacros $(_tsk_lst_file)
_tsk_lst_ro:=$(shell $(CPP) -P -DSECTION_IS_RO \
@@ -112,10 +126,10 @@ CPPFLAGS_RW+=$(foreach t,$(_tsk_cfg_rw),-D$(t)) \
CPPFLAGS+=$(foreach t,$(_tsk_cfg),-D$(t))
_flag_cfg_ro:=$(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) \
- -I$(BDIR) -DSECTION_IS_RO include/config.h | \
+ -I$(BASEDIR) -I$(BDIR) -DSECTION_IS_RO include/config.h | \
grep -o "\#define CONFIG_[A-Z0-9_]*" | cut -c9- | sort)
_flag_cfg_rw:=$(_tsk_cfg_rw) $(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) \
- -I$(BDIR) -DSECTION_IS_RW include/config.h | \
+ -I$(BASEDIR) -I$(BDIR) -DSECTION_IS_RW include/config.h | \
grep -o "\#define CONFIG_[A-Z0-9_]*" | cut -c9- | sort)
_flag_cfg:= $(filter $(_flag_cfg_ro), $(_flag_cfg_rw))
@@ -127,8 +141,9 @@ $(foreach c,$(_tsk_cfg_ro) $(_flag_cfg_ro),$(eval $(c)=ro))
$(foreach c,$(_tsk_cfg) $(_flag_cfg),$(eval $(c)=y))
ifneq "$(CONFIG_COMMON_RUNTIME)" "y"
- _irq_list:=$(shell $(CPP) $(CPPFLAGS) -P -Ichip/$(CHIP) -I$(BDIR) \
- -D"ENABLE_IRQ(x)=EN_IRQ x" -imacros chip/$(CHIP)/registers.h \
+ _irq_list:=$(shell $(CPP) $(CPPFLAGS) -P -Ichip/$(CHIP) -I$(BASEDIR) \
+ -I$(BDIR) -D"ENABLE_IRQ(x)=EN_IRQ x" \
+ -imacros chip/$(CHIP)/registers.h \
$(BDIR)/ec.irqlist | grep "EN_IRQ .*" | cut -c8-)
CPPFLAGS+=$(foreach irq,$(_irq_list),\
-D"irq_$(irq)_handler_optional=irq_$(irq)_handler")
@@ -136,16 +151,17 @@ endif
# Compute RW firmware size and offset
_rw_off_str:=$(shell echo "CONFIG_RW_MEM_OFF" | $(CPP) $(CPPFLAGS) -P \
- -Ichip/$(CHIP) -I$(BDIR) -imacros include/config.h)
+ -Ichip/$(CHIP) -I$(BASEDIR) -I$(BDIR) -imacros include/config.h)
_rw_off:=$(shell echo "$$(($(_rw_off_str)))")
_rw_size_str:=$(shell echo "CONFIG_RW_SIZE" | $(CPP) $(CPPFLAGS) -P \
- -Ichip/$(CHIP) -I$(BDIR) -imacros include/config.h)
+ -Ichip/$(CHIP) -I$(BASEDIR) -I$(BDIR) -imacros include/config.h)
_rw_size:=$(shell echo "$$(($(_rw_size_str)))")
_program_memory_base_str:=$(shell echo "CONFIG_PROGRAM_MEMORY_BASE" | \
$(CPP) $(CPPFLAGS) -P \
- -Ichip/$(CHIP) -I$(BDIR) -imacros include/config.h)
+ -Ichip/$(CHIP) -I$(BDIR) -I$(BASEDIR) -imacros include/config.h)
_program_memory_base=$(shell echo "$$(($(_program_memory_base_str)))")
+$(eval BASEBOARD_$(UC_BASEBOARD)=y)
$(eval BOARD_$(UC_BOARD)=y)
$(eval CHIP_$(UC_CHIP)=y)
$(eval CHIP_VARIANT_$(UC_CHIP_VARIANT)=y)
@@ -165,6 +181,7 @@ objs_from_dir=$(call objs_from_dir_p,$(1),$(2),y)
ifdef CTS_MODULE
include cts/build.mk
endif
+include $(BASEDIR)/build.mk
include $(BDIR)/build.mk
include chip/$(CHIP)/build.mk
include core/$(CORE)/build.mk
@@ -190,6 +207,7 @@ define get_sources =
# Get sources to build for this target
all-obj-$(1)+=$(call objs_from_dir_p,core/$(CORE),core,$(1))
all-obj-$(1)+=$(call objs_from_dir_p,chip/$(CHIP),chip,$(1))
+all-obj-$(1)+=$(call objs_from_dir_p,$(BASEDIR),baseboard,$(1))
all-obj-$(1)+=$(call objs_from_dir_p,$(BDIR),board,$(1))
all-obj-$(1)+=$(call objs_from_dir_p,private,private,$(1))
ifneq ($(PDIR),)
@@ -208,7 +226,8 @@ endef
$(eval $(call get_sources,y))
$(eval $(call get_sources,ro))
-dirs=core/$(CORE) chip/$(CHIP) $(BDIR) common power test cts/common cts/$(CTS_MODULE)
+dirs=core/$(CORE) chip/$(CHIP) $(BASEDIR) $(BDIR) common power test \
+ cts/common cts/$(CTS_MODULE)
dirs+= private $(PDIR)
dirs+=$(shell find common -type d)
dirs+=$(shell find driver -type d)