|
| 1 | +ifeq "$(CONFIG_DASHARO_EC)" "y" |
| 2 | + |
| 3 | +modules-y += dasharo-ec |
| 4 | + |
| 5 | +dasharo-ec_repo := https://github.com/Dasharo/ec |
| 6 | +dasharo-ec_commit_hash := d198b641195e60e13afc17be9464e4f402d1c2fa |
| 7 | + |
| 8 | +# system76/ec uses slash-separated BOARD paths (src/board/novacustom/v540tu/) |
| 9 | +ifeq "$(BOARD)" "novacustom-v540tu" |
| 10 | +DASHARO_EC_BOARD_MODEL := novacustom/v540tu |
| 11 | +else ifeq "$(BOARD)" "novacustom-v560tu" |
| 12 | +DASHARO_EC_BOARD_MODEL := novacustom/v560tu |
| 13 | +else |
| 14 | +$(error "$(BOARD): no Dasharo EC board model mapping defined") |
| 15 | +endif |
| 16 | + |
| 17 | +dasharo-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) |
| 20 | + |
| 21 | +# definemodule checks that this file exists after _target runs |
| 22 | +dasharo-ec_output := .built |
| 23 | + |
| 24 | +# definemodule runs: ( echo "..." ; $(MAKE) -C $(build)/$(dasharo-ec_dir) $(dasharo-ec_target) ) | tee log |
| 25 | +# The whole expansion is a subshell, so && is valid shell inside it. |
| 26 | +# BOARD=... is passed to the upstream EC Makefile as a variable override. |
| 27 | +# Touch .built so definemodule's output sentinel is satisfied. |
| 28 | +dasharo-ec_target := \ |
| 29 | + BOARD=$(DASHARO_EC_BOARD_MODEL) \ |
| 30 | + && touch "$(build)/$(dasharo-ec_dir)/.built" |
| 31 | + |
| 32 | +# After dasharo-ec/.build sentinel is touched by definemodule, copy ec.rom into |
| 33 | +# the per-board coreboot build dir. The datestamped subdir is matched with glob. |
| 34 | +# $(coreboot_dir) = coreboot-dasharo/$(BOARD) — defined in modules/coreboot. |
| 35 | +$(build)/$(coreboot_dir)/ec.rom: $(build)/$(dasharo-ec_dir)/.build |
| 36 | + $(call do,EC-ROM,$(DASHARO_EC_BOARD_MODEL) -> $(coreboot_dir)/ec.rom, \ |
| 37 | + mkdir -p "$(build)/$(coreboot_dir)" \ |
| 38 | + && sh -c 'cp "$(build)/$(dasharo-ec_dir)/build/$(DASHARO_EC_BOARD_MODEL)"/*/ec.rom \ |
| 39 | + "$(build)/$(coreboot_dir)/ec.rom"' \ |
| 40 | + ) |
| 41 | + |
| 42 | +# Append ec.rom as prerequisite to coreboot configure without redefining recipe. |
| 43 | +# Guarantees coreboot configure runs only after ec.rom is in place. |
| 44 | +$(build)/$(coreboot_dir)/.configured: $(build)/$(coreboot_dir)/ec.rom |
| 45 | + |
| 46 | +endif |
0 commit comments