Files
OpenCellular/Makefile.rules
Vincent Palatin fbfd828b9a simple and self-contained EC flashing tool
This produces a host binary running on the application processor and
which is able to re-flash th EC firmware over the AP-to-EC link (either
LPC or I2C).
The payload (ie the EC firmware) to use is embedded inside the flasher
binary.

This is just aimed at testing and developer upgrade. The auto-update
flow is using flashrom.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=build for link/daisy/snow/bds and tests
On Snow, run burn_my_ec from the serial console and see that the EC was
correctly re-flashed.

Change-Id: I7f90e773678a7ef3d8dc6dbacf54e80f3294607b
Reviewed-on: https://gerrit.chromium.org/gerrit/24236
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-05-31 16:28:06 -07:00

135 lines
4.1 KiB
Makefile

# -*- makefile -*-
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Embedded Controller firmware build system - common targets
#
objs := $(all-y)
deps := $(objs:%.o=%.o.d)
build-utils := $(foreach u,$(build-util-bin),$(out)/util/$(u))
host-utils := $(foreach u,$(host-util-bin),$(out)/util/$(u))
# Create output directories if necessary
_dir_create := $(foreach d,$(dirs),$(shell [ -d $(out)/$(d) ] || \
mkdir -p $(out)/$(d)))
_dir_y_create := $(foreach d,$(dirs-y),$(shell [ -d $(out)/$(d) ] || \
mkdir -p $(out)/$(d)))
section = $(subst .,,$(suffix $(1)))
section_is = $(subst .,,SECTION_IS_$(suffix $(1)))
# Decrease verbosity unless you pass V=1
quiet = $(if $(V),,@echo ' $(2)' $(subst $(out)/,,$@) ; )$(cmd_$(1))
silent = $(if $(V),,1>/dev/null)
# commands to build all targets
cmd_lds = $(CPP) -P -C -MMD -MF $@.d -MT $@ $(CPPFLAGS) \
-D$(call section_is,$*) \
-DSECTION=$(call section,$*) $< -o $@
cmd_obj_to_bin = $(OBJCOPY) --gap-fill=0xff -O binary $^ $@
cmd_flat_to_obj = $(CC) -T $(out)/firmware_image.lds -nostdlib $(CPPFLAGS) \
-Wl,--build-id=none -o $@ $<
cmd_elf_to_flat = $(OBJCOPY) -O binary $^ $@
cmd_elf_to_dis = $(OBJDUMP) -D $< > $@
cmd_elf = $(LD) $(LDFLAGS) $(objs) -o $@ -T $< -Map $(out)/$*.map
cmd_c_to_o = $(CC) $(CFLAGS) -MMD -MF $@.d -c $< -o $@
cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) \
-MMD -MF $@.d $< -o $@
cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d $(filter %.c, $^) -o $@
cmd_qemu = ./util/run_qemu_test --image=build/$(BOARD)/$*/$*.bin test/$*.py \
$(silent)
cmd_version = ./util/getversion.sh > $@
cmd_sign = vbutil_ec --sign $@ \
--version 1 \
--keyblock $(VBOOT_DEVKEYS)/ec.keyblock \
--signprivate $(VBOOT_DEVKEYS)/ec_data_key.vbprivk \
--signpubkey $(VBOOT_DEVKEYS)/ec_root_key.vbpubk \
$(silent)
cmd_mv = mv $^ $@
cmd_extractab = cd $(out) && \
dump_fmap -x $(PROJECT).bin.tmp RW_SECTION_A RW_SECTION_B $(silent) && \
mv RW_SECTION_A $(PROJECT).A.bin && mv RW_SECTION_B $(PROJECT).B.bin
cmd_copyab = cd $(out) && cp $(PROJECT).A.flat $(PROJECT).A.bin && \
cp $(PROJECT).B.flat $(PROJECT).B.bin
.PHONY: all tests utils
all: $(out)/$(PROJECT).bin utils
dis: $(foreach s,A B RO,$(out)/$(PROJECT).$(s).dis)
utils: $(build-utils) $(host-utils)
test-targets=$(foreach t,$(test-list),test-$(t))
qemu-test-targets=$(foreach t,$(test-list),qemu-$(t))
.PHONY: $(qemu-test-target) $(test-targets)
$(test-targets): test-%:
@set -e ; \
echo " BUILD $(out)/$*" ; \
$(MAKE) --no-print-directory BOARD=$(BOARD) PROJECT=$* \
V=$(V) out=$(out)/$*
$(qemu-test-targets): qemu-%: test-%
$(call quiet,qemu,TEST )
tests: $(test-targets)
qemu-tests: $(qemu-test-targets)
$(out)/firmware_image.lds: common/firmware_image.lds.S
$(call quiet,lds,LDS )
$(out)/%.lds: core/$(CORE)/ec.lds.S
$(call quiet,lds,LDS )
$(out)/%.bin: $(out)/%.bin.tmp
$(call quiet,mv,MV )
$(out)/%.bin.tmp: $(out)/%.obj
$(call quiet,obj_to_bin,OBJCOPY)
$(if $(sign-y),$(call quiet,sign,SIGN ),)
$(if $(sign-y),$(call quiet,extractab,EXTR_AB), \
$(call quiet,copyab,COPY_AB))
$(out)/%.obj: common/firmware_image.S $(out)/firmware_image.lds \
$(out)/%.RO.flat $(out)/%.A.flat $(out)/%.B.flat
$(call quiet,flat_to_obj,CAT )
$(out)/%.dis: $(out)/%.elf
$(call quiet,elf_to_dis,OBJDUMP)
$(out)/%.flat: $(out)/%.elf
$(call quiet,elf_to_flat,OBJCOPY)
$(out)/%.elf: $(out)/%.lds $(objs)
$(call quiet,elf,LD )
$(out)/%.o:%.c
$(call quiet,c_to_o,CC )
$(out)/vboot/%.o:$(VBOOT_SOURCE)/%.c
$(call quiet,c_to_o,CC )
$(out)/%.o:%.S
$(call quiet,c_to_o,AS )
$(out)/common/version.o: $(out)/ec_version.h
$(out)/ec_version.h: $(filter-out $(out)/common/version.o,$(objs))
$(call quiet,version,VERSION)
$(build-utils): $(out)/%:%.c
$(call quiet,c_to_build,BUILDCC)
$(host-utils): $(out)/%:%.c $(foreach u,$(host-util-common),util/$(u).c)
$(call quiet,c_to_host,HOSTCC )
$(out)/util/burn_my_ec: $(out)/$(PROJECT).bin
.PHONY: clean
clean:
-rm -rf $(out)
.SECONDARY:
-include $(deps)