Skip to content

Commit

Permalink
enable EFI+GPT grub2 images for x86/x64 platforms (such as Atom N2600)
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed Mar 29, 2018
1 parent d0589e6 commit 2881c86
Show file tree
Hide file tree
Showing 18 changed files with 1,100 additions and 61 deletions.
34 changes: 21 additions & 13 deletions config/Config-images.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ menu "Target Images"

config TARGET_ROOTFS_TARGZ
bool "tar.gz"
default y if USES_TARGZ
default n
help
Build a compressed tar archive of the root filesystem.

comment "Root filesystem images"

menuconfig TARGET_ROOTFS_EXT4FS
bool "ext4"
default y if USES_EXT4
default n
help
Build an ext4 root filesystem.

Expand Down Expand Up @@ -185,22 +185,30 @@ menu "Target Images"
depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_ISO || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS
select PACKAGE_grub2
default y

config EFI_IMAGES
bool "Build EFI GRUB images (Linux x86 or x86_64 host only)"
depends on TARGET_x86
depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_ISO || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS
select PACKAGE_grub2
select PACKAGE_grub2-efi
default y

config GRUB_CONSOLE
bool "Use Console Terminal (in addition to Serial)"
depends on GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES
default n if (TARGET_x86_generic_Soekris45xx || TARGET_x86_generic_Soekris48xx || TARGET_x86_net5501 || TARGET_x86_geos || TARGET_x86_alix2)
default y

config GRUB_SERIAL
string "Serial port device"
depends on GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES
default "hvc0" if TARGET_x86_xen_domu
default "ttyS0" if ! TARGET_x86_xen_domu

config GRUB_BAUDRATE
int "Serial port baud rate"
depends on GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES
default 38400 if TARGET_x86_generic
default 115200

Expand All @@ -211,36 +219,36 @@ menu "Target Images"

config GRUB_BOOTOPTS
string "Extra kernel boot options"
depends on GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES
default "xencons=hvc" if TARGET_x86_xen_domu
help
If you don't know, just leave it blank.

config GRUB_TIMEOUT
string "Seconds to wait before booting the default entry"
depends on GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES
default "0"
help
If you don't know, 5 seconds is a reasonable default.

config VDI_IMAGES
bool "Build VirtualBox image files (VDI)"
depends on TARGET_x86 || TARGET_x86_64
select GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES
select TARGET_IMAGES_PAD
select PACKAGE_kmod-e1000

config VMDK_IMAGES
bool "Build VMware image files (VMDK)"
depends on TARGET_x86 || TARGET_x86_64
default y
select GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES
select TARGET_IMAGES_PAD
select PACKAGE_kmod-e1000

config TARGET_IMAGES_PAD
bool "Pad images to filesystem size (for JFFS2)"
depends on GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES

config TARGET_IMAGES_GZIP
bool "GZip images"
Expand All @@ -253,19 +261,19 @@ menu "Target Images"

config TARGET_KERNEL_PARTSIZE
int "Kernel partition size (in MB)"
depends on GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES
default 16

config TARGET_ROOTFS_PARTSIZE
int "Root filesystem partition size (in MB)"
depends on GRUB_IMAGES || TARGET_ROOTFS_EXT4FS || TARGET_rb532 || TARGET_mvebu || TARGET_uml
depends on GRUB_IMAGES || EFI_IMAGES || TARGET_ROOTFS_EXT4FS || TARGET_rb532 || TARGET_mvebu || TARGET_uml
default 90
help
Select the root filesystem partition size.

config TARGET_ROOTFS_PARTNAME
string "Root partition on target device"
depends on GRUB_IMAGES
depends on GRUB_IMAGES || EFI_IMAGES
help
Override the root partition on the final device. If left empty,
it will be mounted by PARTUUID which makes the kernel find the
Expand Down
18 changes: 18 additions & 0 deletions package/base-files/files/lib/upgrade/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ export_bootdevice() {
esac

case "$disk" in
PARTUUID=[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]-[A-F0-9][A-F0-9][A-F0-9][A-F0-9]-[A-F0-9][A-F0-9][A-F0-9][A-F0-9]-[A-F0-9][A-F0-9][A-F0-9][A-F0-9]-[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]0002)
uuid="${disk#PARTUUID=}"
uuid="${uuid%0002}0002"
for disk in $(find /dev -type b); do
set -- $(dd if=$disk bs=1 skip=$((2*51225612816)) count=16 2>/dev/null | hexdump -v -e '4/1 "%02x"' | awk '{ \
for(i=1;i<9;i=i2) first=substr($0,i,1) substr($0,i1,1) first; \
for(i=9;i<13;i=i2) second=substr($0,i,1) substr($0,i1,1) second; \
for(i=13;i<16;i=i2) third=substr($0,i,1) substr($0,i1,1) third; \
fourth = substr($0,17,4); \
five = substr($0,21,12); \
} END { print toupper(first"-"second"-"third"-"fourth"-"five) }')
if [ "$1" = "$uuid" ]; then
uevent="/sys/class/block/${disk##*/}/uevent"
export SAVE_PARTITIONS=0
break
fi
done
;;
PARTUUID=[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]-02)
uuid="${disk#PARTUUID=}"
uuid="${uuid%-02}"
Expand Down
41 changes: 5 additions & 36 deletions package/boot/grub2/Makefile → package/boot/grub2/common.mk
Original file line number Diff line number Diff line change
@@ -1,54 +1,31 @@
#
# Copyright (C) 2006-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=grub
PKG_CPE_ID:=cpe:/a:gnu:grub2
PKG_VERSION:=2.02
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE:=grub-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@GNU/grub
PKG_HASH:=810b3798d316394f94096ec2797909dbf23c858e48f7b3830826b8daa06b7b0f

PKG_FIXUP:=autoreconf
HOST_BUILD_PARALLEL:=1
PKG_BUILD_DEPENDS:=grub2/host

PKG_SSP:=0

PKG_FLAGS:=nonshared

PATCH_DIR := ../patches
HOST_PATCH_DIR := ../patches

include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk

define Package/grub2
define Package/grub2/Default
CATEGORY:=Boot Loaders
SECTION:=boot
TITLE:=GRand Unified Bootloader
URL:=http://www.gnu.org/software/grub/
DEPENDS:=@TARGET_x86||TARGET_x86_64
endef

define Package/grub2-editenv
CATEGORY:=Utilities
SECTION:=utils
SUBMENU:=Boot Loaders
TITLE:=Grub2 Environment editor
URL:=http://www.gnu.org/software/grub/
DEPENDS:=@TARGET_x86||TARGET_x86_64
endef

define Package/grub2-editenv/description
Edit grub2 environment files.
endef

HOST_BUILD_PREFIX := $(STAGING_DIR_HOST)

CONFIGURE_VARS += \
Expand Down Expand Up @@ -82,11 +59,3 @@ define Host/Configure
$(Host/Configure/Default)
endef

define Package/grub2-editenv/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/grub-editenv $(1)/usr/sbin/
endef

$(eval $(call HostBuild))
$(eval $(call BuildPackage,grub2))
$(eval $(call BuildPackage,grub2-editenv))
22 changes: 22 additions & 0 deletions package/boot/grub2/grub2-efi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=grub-efi

include ../common.mk

TAR_OPTIONS:= --transform 's/grub-${PKG_VERSION}/${PKG_NAME}-${PKG_VERSION}/' $(TAR_OPTIONS)

PKG_BUILD_DEPENDS:=grub2-efi/host

CONFIGURE_ARGS += --with-platform=efi
HOST_CONFIGURE_ARGS += --with-platform=efi --program-suffix=-efi

define Package/grub2-efi
$(call Package/grub2/Default)
HIDDEN:=1
TITLE += (with EFI support)
endef

$(eval $(call HostBuild))
$(eval $(call BuildPackage,grub2-efi))
33 changes: 33 additions & 0 deletions package/boot/grub2/grub2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=grub

include ../common.mk

PKG_BUILD_DEPENDS:=grub2/host

define Package/grub2
$(call Package/grub2/Default)
endef

define Package/grub2-editenv
CATEGORY:=Utilities
SECTION:=utils
TITLE:=Grub2 Environment editor
URL:=http://www.gnu.org/software/grub/
DEPENDS:=@TARGET_x86||TARGET_x86_64
endef

define Package/grub2-editenv/description
Edit grub2 environment files.
endef

define Package/grub2-editenv/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/grub-editenv $(1)/usr/sbin/
endef

$(eval $(call HostBuild))
$(eval $(call BuildPackage,grub2))
$(eval $(call BuildPackage,grub2-editenv))
Loading

0 comments on commit 2881c86

Please sign in to comment.