diff options
author | Olivier Fourdan <olivier.fourdan@intel.com> | 2013-04-05 18:19:56 +0200 |
---|---|---|
committer | Patrick Tjin <pattjin@google.com> | 2014-07-21 20:22:40 -0700 |
commit | f1a78db5623b3459b220eab9c306c54b0b2ee0f1 (patch) | |
tree | a863a77b4dada97f120ce3cc25dbf6cca1b44d10 | |
parent | 0784d1dcd61531482a528fe157b36e9ffb90ca57 (diff) | |
download | bootstub-f1a78db5623b3459b220eab9c306c54b0b2ee0f1.tar.gz |
Bootstub: Build $(PRODUCT_OUT)/bootstub from sources
BZ: 98212
Build the bootstub from the available sources and place the result in
out/target/product/*/bootstub for use by the mkbootimg.
Optimize code generation for size to fit into the 4096 bytes and check
for actual size to avoid silently truncating the code.
Change-Id: I1b93b08a55ebcc1dc6e4ddfcbc2939c1a52b581c
Signed-off-by: Olivier Fourdan <olivier.fourdan@intel.com>
Reviewed-on: http://android.intel.com:8080/100248
Reviewed-by: Fert, Laurent <laurent.fert@intel.com>
Reviewed-by: Tinelli, Vincent <vincent.tinelli@intel.com>
Reviewed-by: cactus <cactus@intel.com>
Tested-by: cactus <cactus@intel.com>
-rw-r--r-- | Android.mk | 55 |
1 files changed, 49 insertions, 6 deletions
@@ -1,9 +1,52 @@ LOCAL_PATH := $(call my-dir) - include $(CLEAR_VARS) -bootstub: $(PRODUCT_OUT)/boot/bootstub -$(PRODUCT_OUT)/boot/bootstub: - cd vendor/intel/boot/bootstub/ && CC=$(ANDROID_BUILD_TOP)/$($(my_prefix)CC) CMDLINE_SIZE=$(BOARD_KERNEL_CMDLINE_SIZE) make - mkdir -p $(PRODUCT_OUT)/boot - mv vendor/intel/boot/bootstub/bootstub $(PRODUCT_OUT)/boot +# First compile bootstub.bin + +CMDLINE_SIZE ?= 0x400 +BOOTSTUB_SIZE ?= 4096 + +LOCAL_SRC_FILES := bootstub.c spi-uart.c head.S sfi.c e820_bios.S ssp-uart.c +ANDROID_TOOLCHAIN_FLAGS := -m32 -mno-android -ffreestanding +LOCAL_CFLAGS := $(ANDROID_TOOLCHAIN_FLAGS) -Wall -O1 -DCMDLINE_SIZE=${CMDLINE_SIZE} +LOCAL_MODULE := bootstub.bin +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_PATH := $(PRODUCT_OUT) + +LOCAL_MODULE_CLASS := EXECUTABLES +LOCAL_FORCE_STATIC_EXECUTABLE := true + +include $(BUILD_SYSTEM)/binary.mk + +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(LOCAL_CFLAGS) +$(LOCAL_BUILT_MODULE) : PRIVATE_ELF_FILE := $(intermediates)/$(PRIVATE_MODULE).elf +$(LOCAL_BUILT_MODULE) : PRIVATE_LINK_SCRIPT := $(LOCAL_PATH)/bootstub.lds +$(LOCAL_BUILT_MODULE) : BOOTSTUB_OBJS := $(patsubst %.c, %.o , $(LOCAL_SRC_FILES)) +$(LOCAL_BUILT_MODULE) : BOOTSTUB_OBJS := $(patsubst %.S, %.o , $(BOOTSTUB_OBJS)) +$(LOCAL_BUILT_MODULE) : BOOTSTUB_OBJS := $(addprefix $(intermediates)/, $(BOOTSTUB_OBJS)) + +$(LOCAL_BUILT_MODULE): $(all_objects) + @$(mkdir -p $(dir $@) + @echo "Generating bootstub.bin: $@" + $(hide) $(TARGET_LD) \ + -m elf_i386 \ + -T $(PRIVATE_LINK_SCRIPT) \ + $(BOOTSTUB_OBJS) \ + -o $(PRIVATE_ELF_FILE) + $(hide) $(TARGET_OBJCOPY) -O binary -R .note -R .comment -S $(PRIVATE_ELF_FILE) $@ + +# Then assemble the final bootstub file + +bootstub_bin := $(PRODUCT_OUT)/bootstub.bin +bootstub_full := $(PRODUCT_OUT)/bootstub + +CHECK_BOOTSTUB_SIZE : $(bootstub_bin) + $(hide) ACTUAL_SIZE=`$(call get-file-size,$(bootstub_bin))`; \ + if [ "$$ACTUAL_SIZE" -gt "$(BOOTSTUB_SIZE)" ]; then \ + echo "$(bootstub_bin): $$ACTUAL_SIZE exceeds size limit of $(BOOTSTUB_SIZE) bytes, aborting."; \ + exit 1; \ + fi + +$(bootstub_full) : CHECK_BOOTSTUB_SIZE + @echo "Generating bootstub: $@" + $(hide) cat $(bootstub_bin) /dev/zero | dd bs=$(BOOTSTUB_SIZE) count=1 > $@ |