2021-02-10 13:52:34 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2020-03-20 10:10:55 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2006-2020 OpenWrt.org
|
2021-02-10 13:52:34 +00:00
|
|
|
|
2006-06-21 03:13:25 +00:00
|
|
|
include $(TOPDIR)/rules.mk
|
2006-06-21 02:32:39 +00:00
|
|
|
include $(INCLUDE_DIR)/image.mk
|
2005-07-25 15:40:23 +00:00
|
|
|
|
2020-03-20 10:10:54 +00:00
|
|
|
GRUB2_VARIANT =
|
2010-02-17 00:59:41 +00:00
|
|
|
GRUB_TERMINALS =
|
|
|
|
GRUB_SERIAL_CONFIG =
|
|
|
|
GRUB_TERMINAL_CONFIG =
|
|
|
|
GRUB_CONSOLE_CMDLINE =
|
|
|
|
|
2014-01-07 10:18:55 +00:00
|
|
|
ifneq ($(CONFIG_GRUB_CONSOLE),)
|
armsr: use console=tty1 to make console more readily available
Like x86, armsr is frequently virtualized, and is used for development
and debugging. Kernel messages should be more readily apparent by
default. This can be achieved by adding console=tty1 to the kernel
command line, enabling the console on a (possibly virtual) display and
keyboard, in addition to a serial port.
This also enables failsafe on tty1. Failsafe mode operates on consoles
known by the kernel, without regard to /etc/inittab.
armsr's /etc/inittab is also updated to specify tty1 instead of tty0.
tty1 is technically more correct: tty1 is the first virtual console,
where tty0 reflects the current active virtual console (which is likely
to be tty1).
This configuration matches x86, which is another target commonly used
for virtualization, development, and debugging in the same way. x86's
kernel command line had specified console=tty0, although console=tty1 is
more correct for the reasons given above. This also brings x86's kernel
command line console= into agreement with its /etc/inittab, which
already used tty1.
Signed-off-by: Mark Mentovai <mark@mentovai.com>
Link: https://github.com/openwrt/openwrt/pull/16213
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-06-28 17:14:59 +00:00
|
|
|
GRUB_CONSOLE_CMDLINE += console=tty1
|
2010-04-29 00:47:05 +00:00
|
|
|
GRUB_TERMINALS += console
|
2010-02-17 00:59:41 +00:00
|
|
|
endif
|
|
|
|
|
2023-11-26 22:04:04 +00:00
|
|
|
GRUB_SERIAL:=$(call qstrip,$(CONFIG_TARGET_SERIAL))
|
2013-08-10 18:35:29 +00:00
|
|
|
|
2023-09-13 16:09:43 +00:00
|
|
|
GRUB_CONSOLE_CMDLINE += console=$(GRUB_SERIAL),$(CONFIG_GRUB_BAUDRATE)n8$(if $(CONFIG_GRUB_FLOWCONTROL),r,)
|
|
|
|
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
|
2010-02-17 00:59:41 +00:00
|
|
|
|
2023-09-13 16:09:43 +00:00
|
|
|
GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
|
2010-02-12 19:04:12 +00:00
|
|
|
|
2010-05-05 02:07:38 +00:00
|
|
|
ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
|
2019-11-04 20:55:23 +00:00
|
|
|
ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(IMG_PART_SIGNATURE)-02)
|
2020-03-26 06:05:33 +00:00
|
|
|
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/'))
|
2010-02-12 19:04:12 +00:00
|
|
|
|
2014-01-07 10:18:55 +00:00
|
|
|
GRUB_TIMEOUT:=$(call qstrip,$(CONFIG_GRUB_TIMEOUT))
|
2018-06-05 13:47:05 +00:00
|
|
|
GRUB_TITLE:=$(call qstrip,$(CONFIG_GRUB_TITLE))
|
2012-01-19 01:14:45 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
BOOTOPTS:=$(call qstrip,$(CONFIG_GRUB_BOOTOPTS))
|
2012-10-07 23:01:52 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
define Build/combined
|
|
|
|
$(CP) $(KDIR)/$(KERNEL_NAME) $@.boot/boot/vmlinuz
|
|
|
|
-$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/
|
2020-04-07 09:11:46 +00:00
|
|
|
$(CP) $(STAGING_DIR_IMAGE)/grub2/boot.img $@.boot/boot/grub/
|
|
|
|
$(CP) $(STAGING_DIR_IMAGE)/grub2/$(if $(filter $(1),efi),gpt,$(GRUB2_VARIANT))-core.img \
|
|
|
|
$@.boot/boot/grub/core.img
|
2020-03-26 06:05:33 +00:00
|
|
|
$(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 \
|
2020-03-20 10:10:55 +00:00
|
|
|
$@ \
|
|
|
|
$(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
|
|
|
|
$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
|
|
|
|
256
|
|
|
|
endef
|
2010-04-29 00:47:05 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
define Build/grub-config
|
|
|
|
rm -fR $@.boot
|
|
|
|
$(INSTALL_DIR) $@.boot/boot/grub
|
2012-09-22 20:10:42 +00:00
|
|
|
sed \
|
|
|
|
-e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
|
|
|
|
-e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
|
2020-03-20 10:10:55 +00:00
|
|
|
-e 's#@ROOTPART@#root=$(ROOTPART) rootwait#g' \
|
2020-03-26 06:05:33 +00:00
|
|
|
-e 's#@GPT_ROOTPART@#root=$(GPT_ROOTPART) rootwait#g' \
|
2020-03-20 10:10:55 +00:00
|
|
|
-e 's#@CMDLINE@#$(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE)#g' \
|
2012-09-22 20:10:42 +00:00
|
|
|
-e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
|
2018-06-05 13:47:05 +00:00
|
|
|
-e 's#@TITLE@#$(GRUB_TITLE)#g' \
|
2020-03-20 10:10:55 +00:00
|
|
|
./grub-$(1).cfg > $@.boot/boot/grub/grub.cfg
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/grub-install
|
|
|
|
rm -fR $@.grub2
|
|
|
|
$(INSTALL_DIR) $@.grub2
|
2020-03-26 05:51:32 +00:00
|
|
|
$(CP) $(STAGING_DIR_IMAGE)/grub2/boot.img $@.grub2/
|
2020-03-26 06:05:33 +00:00
|
|
|
$(CP) $(STAGING_DIR_IMAGE)/grub2/$(if $(filter $(1),efi),gpt,$(GRUB2_VARIANT))-core.img $@.grub2/core.img
|
2020-03-20 10:10:55 +00:00
|
|
|
echo '(hd0) $@' > $@.grub2/device.map
|
|
|
|
$(STAGING_DIR_HOST)/bin/grub-bios-setup \
|
|
|
|
-m "$@.grub2/device.map" \
|
|
|
|
-d "$@.grub2" \
|
2020-03-26 06:05:33 +00:00
|
|
|
-r "hd0,$(if $(filter $(1),efi),gpt1,msdos1)" \
|
2020-03-20 10:10:55 +00:00
|
|
|
$@
|
|
|
|
endef
|
2008-05-30 16:50:37 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
define Build/iso
|
|
|
|
$(CP) $(KDIR)/$(KERNEL_NAME) $@.boot/boot/vmlinuz
|
|
|
|
cat \
|
2020-03-26 05:51:32 +00:00
|
|
|
$(STAGING_DIR_IMAGE)/grub2/cdboot.img \
|
|
|
|
$(STAGING_DIR_IMAGE)/grub2/eltorito.img \
|
2020-03-20 10:10:55 +00:00
|
|
|
> $@.boot/boot/grub/eltorito.img
|
|
|
|
-$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/
|
2020-03-26 06:05:33 +00:00
|
|
|
$(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
|
|
|
|
)
|
2012-10-07 23:01:52 +00:00
|
|
|
mkisofs -R -b boot/grub/eltorito.img -no-emul-boot -boot-info-table \
|
2020-03-26 06:05:33 +00:00
|
|
|
$(if $(filter $(1),efi),-boot-load-size 4 -c boot.cat -eltorito-alt-boot -b boot/grub/isoboot.img -no-emul-boot) \
|
2020-03-20 10:10:55 +00:00
|
|
|
-o $@ $@.boot $(TARGET_DIR)
|
2012-10-07 23:01:56 +00:00
|
|
|
endef
|
2007-10-08 18:53:19 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
DEVICE_VARS += GRUB2_VARIANT
|
|
|
|
define Device/Default
|
|
|
|
ARTIFACT/image.iso := grub-config iso | iso
|
2020-04-10 09:54:52 +00:00
|
|
|
IMAGE/combined.img := grub-config pc | combined | grub-install | append-metadata
|
|
|
|
IMAGE/combined.img.gz := grub-config pc | combined | grub-install | gzip | append-metadata
|
2020-03-25 07:06:57 +00:00
|
|
|
IMAGE/combined.vdi := grub-config pc | combined | grub-install | qemu-image vdi
|
|
|
|
IMAGE/combined.vmdk := grub-config pc | combined | grub-install | qemu-image vmdk
|
2021-01-09 21:23:09 +00:00
|
|
|
IMAGE/combined.vhdx := grub-config pc | combined | grub-install | qemu-image vhdx -o subformat=dynamic
|
2020-04-25 10:47:43 +00:00
|
|
|
IMAGE/rootfs.img := append-rootfs | pad-to $(ROOTFS_PARTSIZE)
|
|
|
|
IMAGE/rootfs.img.gz := append-rootfs | pad-to $(ROOTFS_PARTSIZE) | gzip
|
2020-03-26 06:05:33 +00:00
|
|
|
ARTIFACT/image-efi.iso := grub-config iso | iso efi
|
2020-04-10 09:54:52 +00:00
|
|
|
IMAGE/combined-efi.img := grub-config efi | combined efi | grub-install efi | append-metadata
|
|
|
|
IMAGE/combined-efi.img.gz := grub-config efi | combined efi | grub-install efi | gzip | append-metadata
|
2020-03-26 06:05:33 +00:00
|
|
|
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
|
2021-01-09 21:23:09 +00:00
|
|
|
IMAGE/combined-efi.vhdx := grub-config efi | combined efi | grub-install efi | qemu-image vhdx -o subformat=dynamic
|
2020-03-20 10:10:58 +00:00
|
|
|
ifeq ($(CONFIG_TARGET_IMAGES_GZIP),y)
|
2020-03-26 06:05:33 +00:00
|
|
|
IMAGES-y := rootfs.img.gz
|
|
|
|
IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img.gz
|
|
|
|
IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img.gz
|
2020-03-20 10:10:58 +00:00
|
|
|
else
|
2020-03-26 06:05:33 +00:00
|
|
|
IMAGES-y := rootfs.img
|
|
|
|
IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img
|
|
|
|
IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img
|
2020-03-20 10:10:58 +00:00
|
|
|
endif
|
2020-03-20 10:10:55 +00:00
|
|
|
KERNEL := kernel-bin
|
|
|
|
KERNEL_INSTALL := 1
|
|
|
|
KERNEL_NAME := bzImage
|
|
|
|
ifeq ($(CONFIG_ISO_IMAGES),y)
|
2020-03-26 06:05:33 +00:00
|
|
|
ARTIFACTS-$$(CONFIG_GRUB_IMAGES) += image.iso
|
|
|
|
ARTIFACTS-$$(CONFIG_GRUB_EFI_IMAGES) += image-efi.iso
|
2020-03-20 10:10:55 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(CONFIG_VDI_IMAGES),y)
|
2020-03-26 06:05:33 +00:00
|
|
|
IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.vdi
|
|
|
|
IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.vdi
|
2020-03-20 10:10:55 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(CONFIG_VMDK_IMAGES),y)
|
2020-03-26 06:05:33 +00:00
|
|
|
IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.vmdk
|
|
|
|
IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.vmdk
|
2020-03-20 10:10:55 +00:00
|
|
|
endif
|
2021-01-09 21:23:09 +00:00
|
|
|
ifeq ($(CONFIG_VHDX_IMAGES),y)
|
|
|
|
IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.vhdx
|
|
|
|
IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.vhdx
|
|
|
|
endif
|
2020-03-26 06:05:33 +00:00
|
|
|
IMAGES := $$(IMAGES-y)
|
|
|
|
ARTIFACTS := $$(ARTIFACTS-y)
|
2021-01-23 21:09:27 +00:00
|
|
|
SUPPORTED_DEVICES :=
|
2012-02-16 17:53:57 +00:00
|
|
|
endef
|
|
|
|
|
2020-06-07 11:11:15 +00:00
|
|
|
include $(SUBTARGET).mk
|
2005-07-25 15:40:23 +00:00
|
|
|
|
2006-06-04 21:57:59 +00:00
|
|
|
$(eval $(call BuildImage))
|
2020-03-20 10:10:55 +00:00
|
|
|
|