summaryrefslogtreecommitdiff
path: root/Makefile.rules
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-08-22 20:23:23 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-25 21:31:33 +0000
commit9005ddd4bc79e01206899b31b85fce589dbba0b1 (patch)
treee9918eb83e61a57da574d49a919f312ef8dca58d /Makefile.rules
parentd9a614826b524c212b1ce449141a8af047178b38 (diff)
downloadchrome-ec-9005ddd4bc79e01206899b31b85fce589dbba0b1.tar.gz
cr50: add plumbing for signing CR50 RO images
The signer utility needs to be built and the flat image needs to be signed. The signer utility is written in C++, supporting this required adding a new make command to Makefile.rules and a build file for the utility. The signing now needs to be a part of generating the .flat file. To achieve this an alternative set of rules is defined in Makfile.rules for targets where RO image needs to be signed. Rules for converting elf to hex have been consolidated as there is no need to omit the --set-section-flags when it does not apply. BRANCH=none BUG=chrome-os-partner:43025 TEST=as follows: - ran 'rm build/cr50; make BOARD=cr50' - observed that both build/cr50/ec.bin and build/cr50/RO/ec.RO.flat have the required signature header in the first 1024 bytes. - verified that the cr50 board can be booted over SPI using the image in build/cr50/RO/ec.RO.flat Change-Id: Iacc22561de67fadfaf8e049bf9578cbd08cfad86 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295291 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'Makefile.rules')
-rw-r--r--Makefile.rules29
1 files changed, 20 insertions, 9 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 5682f47ec9..7503884197 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -42,10 +42,11 @@ cmd_lds = $(CPP) -P -C -MMD -MF $@.d -MT $@ $(CPPFLAGS) \
cmd_obj_to_bin ?= $(OBJCOPY) --gap-fill=0xff -O binary $^ $(out)/$*.bin.tmp
cmd_flat_to_obj = $(CC) -T $(out)/firmware_image.lds -nostdlib $(CPPFLAGS) \
-Wl,--build-id=none -o $@ $<
-cmd_elf_to_flat = $(OBJCOPY) -O binary $(patsubst %.flat,%.elf,$@) $@
# Allow the .roshared section to overlap other sections (itself)
cmd_ec_elf_to_flat ?= $(OBJCOPY) --set-section-flags .roshared=share \
- -O binary $(patsubst %.flat,%.elf,$@) $@
+ -O binary $< $@
+cmd_raw_to_flat ?= $(out)/util/signer util/signer/rom-testkey.pem $< \
+ && mv $<.signed $@
cmd_elf_to_dis = $(OBJDUMP) -D $< > $@
cmd_elf_to_hex = $(OBJCOPY) -O ihex $< $@
cmd_bin_to_hex = $(OBJCOPY) -I binary -O ihex \
@@ -61,6 +62,8 @@ cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) \
-MMD -MF $@.d -o $@
cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d -o $@ \
$(sort $(foreach c,$($(*F)-objs),util/$(c:%.o=%.c)) $*.c)
+cmd_cxx_to_host = $(HOSTCXX) -std=c++0x $(COMMON_WARN) \
+ -I ./$($(notdir $@)_ROOT) -o $@ $(filter %.cc,$^) $($(notdir $@)_LIBS)
cmd_host_test = ./util/run_host_test $* $(silent)
cmd_date = $(if $(USE_GIT_DATE),cat /dev/null,./util/getdate.sh) > $@
cmd_version = ./util/getversion.sh > $@
@@ -190,19 +193,27 @@ $(out)/$(PROJECT).obj: common/firmware_image.S $(out)/firmware_image.lds \
$(out)/%.dis: $(out)/%.elf
$(call quiet,elf_to_dis,OBJDUMP)
-$(out)/%.flat: $(out)/%.elf $(out)/%.smap
- $(call quiet,elf_to_flat,OBJCOPY)
+$(out)/RW/%.hex: $(out)/RW/%.elf $(out)/RW/%.smap
+ $(call quiet,elf_to_hex,OBJCOPY)
-$(out)/RW/ec.RW.flat: $(out)/RW/ec.RW.elf $(out)/RW/ec.RW.smap
- $(call quiet,ec_elf_to_flat,OBJCOPY)
-$(out)/RO/ec.RO.flat: $(out)/RO/ec.RO.elf $(out)/RO/ec.RO.smap
+ifeq ($(SIGNED_RO_IMAGE),)
+$(out)/%.flat: $(out)/%.elf $(out)/%.smap
$(call quiet,ec_elf_to_flat,OBJCOPY)
-$(out)/RW/%.hex: $(out)/RW/%.elf $(out)/RW/%.smap
- $(call quiet,elf_to_hex,OBJCOPY)
$(out)/RO/%.hex: $(out)/RO/%.elf $(out)/RO/%.smap
$(call quiet,elf_to_hex,OBJCOPY)
+else
+$(out)/RW/ec.RW.flat: $(out)/RW/ec.RW.elf
+ $(call quiet,ec_elf_to_flat,OBJCOPY)
+$(out)/RO/ec.RO.flat.raw: $(out)/RO/ec.RO.elf $(out)/RO/ec.RO.smap
+ $(call quiet,ec_elf_to_flat,OBJCOPY)
+$(out)/RO/ec.RO.flat: $(out)/RO/ec.RO.flat.raw
+ $(call quiet,raw_to_flat,RO_SIGN)
+
+$(out)/RO/%.hex: $(out)/RO/%.flat
+ $(call quiet,bin_to_hex,OBJCOPY)
+endif
$(out)/$(PROJECT).hex: $(out)/$(PROJECT).bin
$(call quiet,bin_to_hex,OBJCOPY)