diff options
author | 李国 <uxgood.org@gmail.com> | 2020-03-26 14:05:33 +0800 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2020-03-31 16:20:47 +0200 |
commit | a6b7c3e672764858fd294998406ae791f5964b4a (patch) | |
tree | 9174e7c3b9338a87b700cbd6e266f975361de1fb /target/linux/x86/image/Makefile | |
parent | d9228514ccecfb9d1500e3a82470f66f2ea41a39 (diff) | |
download | upstream-a6b7c3e672764858fd294998406ae791f5964b4a.tar.gz upstream-a6b7c3e672764858fd294998406ae791f5964b4a.tar.bz2 upstream-a6b7c3e672764858fd294998406ae791f5964b4a.zip |
x86: generate EFI platform bootable images
Add EFI platform bootable images for x86 platforms. These images can
also boot from legacy BIOS platform.
EFI System Partition need to be fat12/fat16/fat32 (not need to load
filesystem drivers), so the first partition of EFI images are not ext4
filesystem any more.
GPT partition table has an alternate partition table, we did not
generate it. This may cause problems when use these images as qemu disk
(kernel can not find rootfs), we pad enough sectors will be ok.
Signed-off-by: 李国 <uxgood.org@gmail.com>
[part_magic_* refactoring, removed genisoimage checks]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'target/linux/x86/image/Makefile')
-rw-r--r-- | target/linux/x86/image/Makefile | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile index 4915f639fa..7864dfa1f8 100644 --- a/target/linux/x86/image/Makefile +++ b/target/linux/x86/image/Makefile @@ -38,6 +38,8 @@ 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)) @@ -47,7 +49,12 @@ BOOTOPTS:=$(call qstrip,$(CONFIG_GRUB_BOOTOPTS)) define Build/combined $(CP) $(KDIR)/$(KERNEL_NAME) $@.boot/boot/vmlinuz -$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/ - PADDING="1" SIGNATURE="$(IMG_PART_SIGNATURE)" $(SCRIPT_DIR)/gen_image_generic.sh \ + $(if $(filter $(1),efi), + $(INSTALL_DIR) $@.boot/efi/boot + $(CP) $(STAGING_DIR_IMAGE)/grub2/boot$(if $(CONFIG_x86_64),x64,ia32).efi $@.boot/efi/boot/ + ) + 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) \ @@ -61,6 +68,7 @@ define Build/grub-config -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' \ @@ -71,12 +79,12 @@ define Build/grub-install rm -fR $@.grub2 $(INSTALL_DIR) $@.grub2 $(CP) $(STAGING_DIR_IMAGE)/grub2/boot.img $@.grub2/ - $(CP) $(STAGING_DIR_IMAGE)/grub2/$(GRUB2_VARIANT)-core.img $@.grub2/core.img + $(CP) $(STAGING_DIR_IMAGE)/grub2/$(if $(filter $(1),efi),gpt,$(GRUB2_VARIANT))-core.img $@.grub2/core.img echo '(hd0) $@' > $@.grub2/device.map $(STAGING_DIR_HOST)/bin/grub-bios-setup \ -m "$@.grub2/device.map" \ -d "$@.grub2" \ - -r "hd0,msdos1" \ + -r "hd0,$(if $(filter $(1),efi),gpt1,msdos1)" \ $@ endef @@ -87,7 +95,15 @@ define Build/iso $(STAGING_DIR_IMAGE)/grub2/eltorito.img \ > $@.boot/boot/grub/eltorito.img -$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/ + $(if $(filter $(1),efi), + mkfs.fat -C $@.boot/boot/grub/isoboot.img -S 512 1440 + mmd -i $@.boot/boot/grub/isoboot.img ::/efi ::/efi/boot + mcopy -i $@.boot/boot/grub/isoboot.img \ + $(STAGING_DIR_IMAGE)/grub2/iso-boot$(if $(CONFIG_x86_64),x64,ia32).efi \ + ::/efi/boot/boot$(if $(CONFIG_x86_64),x64,ia32).efi + ) mkisofs -R -b boot/grub/eltorito.img -no-emul-boot -boot-info-table \ + $(if $(filter $(1),efi),-boot-load-size 4 -c boot.cat -eltorito-alt-boot -b boot/grub/isoboot.img -no-emul-boot) \ -o $@ $@.boot $(TARGET_DIR) endef @@ -100,23 +116,37 @@ define Device/Default IMAGE/combined.vmdk := grub-config pc | combined | grub-install | qemu-image vmdk IMAGE/rootfs.img := append-rootfs IMAGE/rootfs.img.gz := append-rootfs | gzip + ARTIFACT/image-efi.iso := grub-config iso | iso efi + IMAGE/combined-efi.img := grub-config efi | combined efi | grub-install efi + IMAGE/combined-efi.img.gz := grub-config efi | combined efi | grub-install efi | gzip + IMAGE/combined-efi.vdi := grub-config efi | combined efi | grub-install efi | qemu-image vdi + IMAGE/combined-efi.vmdk := grub-config efi | combined efi | grub-install efi | qemu-image vmdk ifeq ($(CONFIG_TARGET_IMAGES_GZIP),y) - IMAGES := combined.img.gz rootfs.img.gz + IMAGES-y := rootfs.img.gz + IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img.gz + IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img.gz else - IMAGES := combined.img rootfs.img + IMAGES-y := rootfs.img + IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img + IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img endif KERNEL := kernel-bin KERNEL_INSTALL := 1 KERNEL_NAME := bzImage ifeq ($(CONFIG_ISO_IMAGES),y) - ARTIFACTS := image.iso + ARTIFACTS-$$(CONFIG_GRUB_IMAGES) += image.iso + ARTIFACTS-$$(CONFIG_GRUB_EFI_IMAGES) += image-efi.iso endif ifeq ($(CONFIG_VDI_IMAGES),y) - IMAGES += combined.vdi + IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.vdi + IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.vdi endif ifeq ($(CONFIG_VMDK_IMAGES),y) - IMAGES += combined.vmdk + IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.vmdk + IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.vmdk endif + IMAGES := $$(IMAGES-y) + ARTIFACTS := $$(ARTIFACTS-y) endef $(eval $(call Image/gzip-ext4-padded-squashfs)) |