summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2018-04-26 11:41:42 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-05-14 12:28:05 -0700
commit361f3a74ba1112683b1c3acb50ea2ad9b29f090f (patch)
treeaf6099f490e0195a1638e6f44611e570a0774362
parent69d0740bd451a3bc0759a644e21b6844fe6d829c (diff)
downloadchrome-ec-361f3a74ba1112683b1c3acb50ea2ad9b29f090f.tar.gz
make: add size calculations
Room remaining in flash is an ever important property of many EC images. This patch adds a makefile rule with will calculate how much free room is left in the RW partition with the current image. The calculation uses two variables set by the linker: 'FLASH' which shows how much room is allocated to the image and '__image_size' which shows how much room is actually taken. The difference is how much room is still available. Wnen building with V=0, size is not reported. BRANCH=cr50, cr50-mp BUG=b:65253310 TEST=observed reported values: $ make BOARD=cr50 -j ... *** 7864 bytes still available in flash on cr50 **** $ rm -rf build/cr50/ $ make BOARD=cr50 CR50_DEV=1 -j *** 4488 bytes still available in flash on cr50 **** Change-Id: I66e23dc72905988b21666c5dc9608d92e3fead50 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1030909 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--Makefile2
-rw-r--r--Makefile.rules19
2 files changed, 20 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index ef57275455..4460c2f045 100644
--- a/Makefile
+++ b/Makefile
@@ -264,7 +264,7 @@ deps := $(ro-deps) $(rw-deps) $(deps-y)
$(config): $(out)/$(PROJECT).bin
@printf '%s=y\n' $(_tsk_cfg) $(_flag_cfg) > $@
-def_all_deps:=utils ro rw notice $(config) $(PROJECT_EXTRA)
+def_all_deps:=utils ro rw notice $(config) $(PROJECT_EXTRA) size
all_deps?=$(def_all_deps)
all: $(all_deps)
diff --git a/Makefile.rules b/Makefile.rules
index 442a71861e..a46006c51e 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -271,6 +271,20 @@ cmd_lcov=flock /tmp/ec-lcov-lock -c "lcov -q -o $@ -c -d build/host/$*"
cmd_report_cov=genhtml -q -o build/host/coverage_rpt -t \
"EC Unittest "$(bldversion) $^
+# Unless V is set to 0 we always want the 'size:' target to report its output,
+# there is no point in generating a short form command trace when calculating
+# size.
+ifeq ($(V),0)
+cmd_size=
+else
+cmd_size=$(Q)awk '\
+ /__image_size =/ {image_size = strtonum($$1)} \
+ /^FLASH/ {flash_size = strtonum($$3)} \
+ END {room_left = flash_size - image_size; \
+ printf (" *** %s bytes still available in flash on $(BOARD) ****\n", \
+ room_left)}' $(out)/RW/$(PROJECT).RW.map
+endif
+
build/host/%.info: run-%
$(call quiet,lcov,COV )
@@ -594,6 +608,11 @@ analyzestack: $(out)/util/export_taskinfo.so
--annotation $(ANNOTATION) \
--export_taskinfo "$$EXPORT_TASKINFO" "$$ELF"
+# Calculate size of remaining room in flash, using variables generated by
+# linker.
+size: $(out)/$(PROJECT).bin
+ $(call cmd_size)
+
.SECONDARY:
-include $(deps)