From f5dfd39ac76f4f70a798a199cdbfdc179b1bb23c Mon Sep 17 00:00:00 2001 From: Julien Viard de Galbert Date: Tue, 8 Jan 2019 15:24:32 +0100 Subject: [PATCH] Allow to use utk. Based on branch 'ganshun/use-utk' with the following changes Makefile: - Added missing ./dxe/linuxboot.ffs while resolving conflict. - Copying utk from $GOPATH - Make utk optional Signed-off-by: Julien Viard de Galbert --- Makefile | 20 +++++++++++++++++--- Makefile.utk | 28 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 Makefile.utk diff --git a/Makefile b/Makefile index 8f47245..dcd610a 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # # This requires the vendor firmware image, a Linux kernel and an initrd.cpio.xz file. # -# +# all: linuxboot -include .config @@ -36,6 +36,10 @@ include boards/$(BOARD)/Makefile.board # If they don't define a vendor ROM file ROM ?= boards/$(BOARD)/$(BOARD).rom +ifdef USE_UTK +include Makefile.utk +endif + linuxboot: $(BUILD)/linuxboot.rom # Create a .config file based on the current parameters @@ -64,7 +68,6 @@ edk2.force: edk2/.git edk2/.git: git clone --depth 1 --branch UDK2018 https://github.com/linuxboot/edk2 - $(BUILD)/Linux.ffs: $(KERNEL) $(BUILD)/Initrd.ffs: $(INITRD) @@ -133,8 +136,19 @@ $(dxe-files): $(BUILD)/$(BOARD).txt dxe/%.ffs: $(MAKE) -C dxe $(notdir $@) +ifndef USE_UTK $(BUILD)/linuxboot.rom: $(FVS) - +else +$(BUILD)/linuxboot.rom: bin/utk ./dxe/linuxboot.ffs $(BUILD)/Linux.ffs $(BUILD)/Initrd.ffs + $< \ + $(ROM) \ + remove_dxes_except boards/$(BOARD)/image-files.txt \ + insert_dxe ./dxe/linuxboot.ffs \ + insert_dxe $(BUILD)/Linux.ffs \ + insert_dxe $(BUILD)/Initrd.ffs \ + save $@ +endif clean: $(RM) $(BUILD)/{*.ffs,*.rom,*.vol,*.tmp} + $(RM) ./bin/utk diff --git a/Makefile.utk b/Makefile.utk new file mode 100644 index 0000000..1c31abf --- /dev/null +++ b/Makefile.utk @@ -0,0 +1,28 @@ +# +# Rules for using UTK to manipulate the flash image +# + +# Check go version. We need go 1.11 or newer +GOVERSION:=$(shell go version | grep ^go | cut -d ' ' -f 3 | cut -c 3-) +GOMAJOR:=$(shell echo $(GOVERSION) | cut -d '.' -f 1) +GOMINOR:=$(shell echo $(GOVERSION) | cut -d '.' -f 2) +GOVERSIONREQ:=1.11 +GOMAJORREQ:=1 +GOMINORREQ:=11 + +$(shell \ + if [ "$(GOMAJOR)" -lt "$(GOMAJORREQ)" ]; then \ + echo >&2 "Go version $(GOVERSION) too old, please install go $(GOVERSIONREQ) or newer"; \ + exit 1; \ + elif [ "$(GOMAJOR)" -eq "$(GOMAJORREQ)" ]; then \ + if [ "$(GOMINOR)" -lt "$(GOMINORREQ)" ]; then \ + echo >&2 "Go version $(GOVERSION) too old, please install go $(GOVERSIONREQ) or newer"; \ + exit 1; \ + fi; \ + fi; \ +) + +bin/utk: + go get github.com/linuxboot/fiano/cmds/utk + cp $(GOPATH)/bin/utk $@ +