@@ -7,42 +7,45 @@ dasharo-ec_commit_hash := d198b641195e60e13afc17be9464e4f402d1c2fa
77
88# Map BOARD to the EC board model
99ifeq "$(BOARD)" "novacustom-v540tu"
10- DASHARO_EC_BOARD_MODEL := v540tu
10+ DASHARO_EC_BOARD_MODEL := v540tu
1111else ifeq "$(BOARD)" "novacustom-v560tu"
12- DASHARO_EC_BOARD_MODEL := v560tu
12+ DASHARO_EC_BOARD_MODEL := v560tu
1313else
14- $(error "$(BOARD): no Dasharo EC board model mapping defined")
14+ $(error "$(BOARD): no Dasharo EC board model mapping defined")
1515endif
1616
1717dasharo-ec_version := $(dasharo-ec_commit_hash)
18- dasharo-ec_base_dir := dasharo-ec-$(dasharo-ec_version)
19- dasharo-ec_dir := dasharo-ec-$(dasharo-ec_version)
18+ dasharo-ec_base_dir := dasharo-ec-$(dasharo-ec_version)-$(BOARD)
19+ dasharo-ec_dir := dasharo-ec-$(dasharo-ec_version)-$(BOARD)
2020
21- # Use .built sentinel since the real output is in a dynamic path
22- dasharo-ec_output := .built
21+ # ec.rom is copied to a stable path by the explicit rule below
22+ dasharo-ec_output := ec.rom
2323
2424# No-op configure: submodules are handled by the EC Makefile's canary rule
2525# for git repos
2626dasharo-ec_configure :=
2727
28- # Build the EC firmware following the upstream build.sh process:
29- # 1. make BOARD=novacustom/<model> (compile with SDCC)
30- # 2. Copy ec.rom from the dynamic output path to a known location
31- # 3. Extend ec.rom to 128KB (zero-padded) as required by coreboot
32- # Note: the && chain after make -C runs in the parent cwd, so use
33- # absolute paths. Use sh -c so the shell expands the glob.
34- dasharo-ec_target := \
35- BOARD=novacustom/$(DASHARO_EC_BOARD_MODEL) \
36- && sh -c 'cp $(build)/$(dasharo-ec_dir)/build/novacustom/$(DASHARO_EC_BOARD_MODEL)/*/ec.rom $(build)/$(dasharo-ec_dir)/ec.rom' \
37- && dd if=/dev/zero of=$(build)/$(dasharo-ec_dir)/ec.rom bs=1 seek=128k count=0 \
38- && touch $(build)/$(dasharo-ec_dir)/.built
39-
40- # Copy ec.rom into the coreboot source tree before coreboot configures.
41- # coreboot expects ec.rom in its root directory.
42- $(build)/$(coreboot_base_dir)/ec.rom: $(build)/$(dasharo-ec_dir)/.build
43- $(call do,COPY,ec.rom -> coreboot, \
44- cp "$(build)/$(dasharo-ec_dir)/ec.rom" "$@" \
45- )
28+ # Build the EC firmware: only pass make arguments; post-build steps are
29+ # handled by the explicit rule below.
30+ dasharo-ec_target := BOARD=novacustom/$(DASHARO_EC_BOARD_MODEL)
31+
32+ # Copy ec.rom from the dynamic build path to a stable location and pad to
33+ # 128KB as required by coreboot. Runs after the module make completes.
34+ $(build)/$(dasharo-ec_dir)/ec.rom: $(build)/$(dasharo-ec_dir)/.build
35+ sh -c 'cp $(build)/$(dasharo-ec_dir)/build/novacustom/$(DASHARO_EC_BOARD_MODEL)/*/ec.rom $@'
36+ dd if=/dev/zero of=$@ bs=1 seek=128k count=0
37+
38+ # Copy ec.rom into the coreboot source tree before coreboot builds.
39+ # coreboot_base_dir (coreboot-dasharo) is shared between v540tu and v560tu, so
40+ # a plain timestamp-based rule is racy: whichever board built last wins the mtime
41+ # race and the other board silently keeps the wrong binary. Adding FORCE makes the
42+ # recipe always run so we can do a content check; the actual cp (and the mtime
43+ # update that triggers downstream rebuilds) only happens when the content differs.
44+ $(build)/$(coreboot_base_dir)/ec.rom: $(build)/$(dasharo-ec_dir)/ec.rom FORCE
45+ @if ! cmp -s "$(build)/$(dasharo-ec_dir)/ec.rom" "$@" 2>/dev/null; then \
46+ echo "$(DATE) COPY $(DASHARO_EC_BOARD_MODEL) ec.rom -> coreboot"; \
47+ cp "$(build)/$(dasharo-ec_dir)/ec.rom" "$@"; \
48+ fi
4649
4750# Ensure coreboot's configure step depends on ec.rom being present
4851$(build)/$(coreboot_dir)/.configured: $(build)/$(coreboot_base_dir)/ec.rom
0 commit comments