aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/armvirt/image/Makefile
diff options
context:
space:
mode:
authorMathew McBride <matt@traverse.com.au>2022-01-19 02:25:23 +0000
committerPetr Štetiar <ynezz@true.cz>2023-06-13 14:12:23 +0200
commit7c223a881f93cb5e8e68fe8b92693b48d4609002 (patch)
treecede82ccb1ac128576c19bd6a771c0e1a07feefa /target/linux/armvirt/image/Makefile
parent1e7fa539ae6e94bfdb5d9e503f0c103e15b408a1 (diff)
downloadupstream-7c223a881f93cb5e8e68fe8b92693b48d4609002.tar.gz
upstream-7c223a881f93cb5e8e68fe8b92693b48d4609002.tar.bz2
upstream-7c223a881f93cb5e8e68fe8b92693b48d4609002.zip
armvirt: add EFI support
EFI booting is used on newer machines compatible with the Arm SystemReady specifications. This commit restructures armvirt into a more 'generic' target similar to x86. See https://github.com/openwrt/openwrt/pull/4956 for a history of this port. Signed-off-by: Mathew McBride <matt@traverse.com.au> (23.05 version of e0f06ddc23b2503a1791ae7e97b02e2647e8a70d)
Diffstat (limited to 'target/linux/armvirt/image/Makefile')
-rw-r--r--target/linux/armvirt/image/Makefile109
1 files changed, 95 insertions, 14 deletions
diff --git a/target/linux/armvirt/image/Makefile b/target/linux/armvirt/image/Makefile
index 5f9ef21d65..bd75f85996 100644
--- a/target/linux/armvirt/image/Makefile
+++ b/target/linux/armvirt/image/Makefile
@@ -5,28 +5,109 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
-define Image/BuildKernel
- $(foreach k,$(filter zImage Image,$(KERNELNAME)), \
- cp $(KDIR)/$(KERNELNAME) $(BIN_DIR)/$(IMG_PREFIX)-$(k) \
+GRUB2_VARIANT =
+GRUB_TERMINALS =
+GRUB_SERIAL_CONFIG =
+GRUB_TERMINAL_CONFIG =
+GRUB_CONSOLE_CMDLINE = earlycon
+
+ifneq ($(CONFIG_GRUB_CONSOLE),)
+ GRUB_TERMINALS += console
+endif
+
+GRUB_SERIAL:=$(call qstrip,$(CONFIG_GRUB_SERIAL))
+
+ifneq ($(GRUB_SERIAL),)
+ GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_GRUB_BAUDRATE) --word=8 --parity=no --stop=1 --rtscts=$(if $(CONFIG_GRUB_FLOWCONTROL),on,off)
+ GRUB_TERMINALS += serial
+endif
+
+ifneq ($(GRUB_TERMINALS),)
+ GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
+endif
+
+ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
+ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(IMG_PART_SIGNATURE)-02)
+GPT_ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
+GPT_ROOTPART:=$(if $(GPT_ROOTPART),$(GPT_ROOTPART),PARTUUID=$(shell echo $(IMG_PART_DISKGUID) | sed 's/00$$/02/'))
+
+GRUB_TIMEOUT:=$(call qstrip,$(CONFIG_GRUB_TIMEOUT))
+GRUB_TITLE:=$(call qstrip,$(CONFIG_GRUB_TITLE))
+
+BOOTOPTS:=$(call qstrip,$(CONFIG_GRUB_BOOTOPTS))
+
+define Build/combined
+ $(INSTALL_DIR) $@.boot/
+ $(CP) $(KDIR)/$(KERNEL_NAME) $@.boot/efi/openwrt/
+ -$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/
+ $(if $(filter $(1),efi),
+ $(INSTALL_DIR) $@.boot/efi/boot
+ $(CP) $(STAGING_DIR_IMAGE)/grub2/boot$(if $(CONFIG_aarch64),aa64,arm).efi $@.boot/efi/openwrt/
+ $(CP) $(STAGING_DIR_IMAGE)/grub2/boot$(if $(CONFIG_aarch64),aa64,arm).efi $@.boot/efi/boot/
)
+ FAT_TYPE="32" PADDING="1" SIGNATURE="$(IMG_PART_SIGNATURE)" \
+ $(if $(filter $(1),efi),GUID="$(IMG_PART_DISKGUID)") $(SCRIPT_DIR)/gen_image_generic.sh \
+ $@ \
+ $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
+ $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
+ 256
endef
-define Image/Build/Initramfs
- $(foreach k,$(filter zImage Image,$(KERNELNAME)), \
- cp $(KDIR)/$(k)-initramfs $(BIN_DIR)/$(IMG_PREFIX)-$(k)-initramfs \
- )
+define Build/grub-config
+ rm -fR $@.boot
+ $(INSTALL_DIR) $@.boot/efi/openwrt/
+ sed \
+ -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
+ -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
+ -e 's#@ROOTPART@#root=$(ROOTPART) rootwait#g' \
+ -e 's#@GPT_ROOTPART@#root=$(GPT_ROOTPART) rootwait#g' \
+ -e 's#@CMDLINE@#$(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE)#g' \
+ -e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
+ -e 's#@TITLE@#$(GRUB_TITLE)#g' \
+ -e 's#@KERNEL_NAME@#$(KERNEL_NAME)#g' \
+ ./grub-$(1).cfg > $@.boot/efi/openwrt/grub.cfg
endef
-define Image/Build/gzip
- gzip -f9n $(BIN_DIR)/$(IMG_ROOTFS)-$(1).img
+define Build/grub-install
+ rm -fR $@.grub2
+ $(INSTALL_DIR) $@.grub2
endef
-$(eval $(call Image/gzip-ext4-padded-squashfs))
+DEVICE_VARS += GRUB2_VARIANT
+define Device/efi-default
+ IMAGE/rootfs.img := append-rootfs | pad-to $(ROOTFS_PARTSIZE)
+ IMAGE/rootfs.img.gz := append-rootfs | pad-to $(ROOTFS_PARTSIZE) | gzip
+ IMAGE/combined.img := grub-config efi | combined efi | grub-install efi | append-metadata
+ IMAGE/combined.img.gz := grub-config efi | combined efi | grub-install efi | gzip | append-metadata
+ IMAGE/combined.vmdk := grub-config efi | combined efi | grub-install efi | qemu-image vmdk
+ ifeq ($(CONFIG_TARGET_IMAGES_GZIP),y)
+ IMAGES-y := rootfs.img.gz
+ IMAGES-y += combined.img.gz
+ else
+ IMAGES-y := rootfs.img
+ IMAGES-y += combined.img
+ endif
+ ifeq ($(CONFIG_VMDK_IMAGES),y)
+ IMAGES-y += combined.vmdk
+ endif
+ KERNEL := kernel-bin
+ KERNEL_INSTALL := 1
+ IMAGES := $$(IMAGES-y)
+ ARTIFACTS := $$(ARTIFACTS-y)
+ SUPPORTED_DEVICES :=
+ ifeq ($(CONFIG_arm),y)
+ KERNEL_NAME = zImage
+ endif
+endef
-define Image/Build
- $(call Image/Build/$(1))
- $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_ROOTFS)-$(1).img
- $(call Image/Build/gzip/$(1))
+define Device/generic
+ $(call Device/efi-default)
+ DEVICE_TITLE := Generic EFI Boot
+ GRUB2_VARIANT := generic
+ FILESYSTEMS := ext4 squashfs
+ DEVICE_PACKAGES += kmod-amazon-ena kmod-e1000e kmod-vmxnet3 kmod-rtc-rx8025 \
+ kmod-i2c-mux-pca954x kmod-gpio-pca953x partx-utils
endef
+TARGET_DEVICES += generic
$(eval $(call BuildImage))