|
| 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 | +# Map BOARD to the EC board model |
| 9 | +ifeq "$(BOARD)" "novacustom-v540tu" |
| 10 | + DASHARO_EC_BOARD_MODEL := v540tu |
| 11 | +else ifeq "$(BOARD)" "novacustom-v560tu" |
| 12 | + DASHARO_EC_BOARD_MODEL := 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 | +# Use .built sentinel since the real output is in a dynamic path |
| 22 | +dasharo-ec_output := .built |
| 23 | + |
| 24 | +# No-op configure: submodules are handled by the EC Makefile's canary rule |
| 25 | +# for git repos |
| 26 | +dasharo-ec_configure := |
| 27 | + |
| 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 | + ) |
| 46 | + |
| 47 | +# Ensure coreboot's configure step depends on ec.rom being present |
| 48 | +$(build)/$(coreboot_dir)/.configured: $(build)/$(coreboot_base_dir)/ec.rom |
| 49 | + |
| 50 | +endif |
0 commit comments