summaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-09-22 20:10:42 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-09-22 20:10:42 +0000
commite2b0f224fbb795628a78b165103cf575c150fbc4 (patch)
tree422b06e50a14aa871883343d7f6aedef560864bd /target/linux
parentc6b9735d685d4cf56cc3c7fa8351a7ad3073b06d (diff)
x86: add support for building grub2 images
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33513 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/x86/image/Config.in7
-rw-r--r--target/linux/x86/image/Makefile38
-rw-r--r--target/linux/x86/image/grub-early.cfg1
-rw-r--r--target/linux/x86/image/grub.cfg13
4 files changed, 56 insertions, 3 deletions
diff --git a/target/linux/x86/image/Config.in b/target/linux/x86/image/Config.in
index 9a1317bb6..08880e580 100644
--- a/target/linux/x86/image/Config.in
+++ b/target/linux/x86/image/Config.in
@@ -17,9 +17,14 @@ config X86_GRUB_IMAGES
bool "Build GRUB images (Linux x86 or x86_64 host only)"
depends TARGET_x86 && !TARGET_x86_olpc
depends TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_ISO || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS
- select PACKAGE_grub
+ select PACKAGE_grub if !X86_USE_GRUB2
default y
+config X86_USE_GRUB2
+ bool "Use grub2"
+ depends X86_GRUB_IMAGES
+ select PACKAGE_grub2
+
config X86_GRUB_CONSOLE
bool "Use Console Terminal (in addition to Serial)"
depends X86_GRUB_IMAGES
diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
index 1ff436b20..ebe078859 100644
--- a/target/linux/x86/image/Makefile
+++ b/target/linux/x86/image/Makefile
@@ -9,6 +9,7 @@ include $(INCLUDE_DIR)/image.mk
export PATH=$(TARGET_PATH):/sbin
+GRUB2_MODULES = at_keyboard biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga
GRUB_TERMINALS =
GRUB_SERIAL_CONFIG =
GRUB_TERMINAL_CONFIG =
@@ -26,7 +27,11 @@ ifneq ($(CONFIG_X86_GRUB_SERIAL),)
endif
ifneq ($(GRUB_TERMINALS),)
- GRUB_TERMINAL_CONFIG := terminal --timeout=2 $(GRUB_TERMINALS)
+ ifneq ($(CONFIG_X86_USE_GRUB2),)
+ GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
+ else
+ GRUB_TERMINAL_CONFIG := terminal --timeout=2 $(GRUB_TERMINALS)
+ endif
endif
ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
@@ -85,6 +90,35 @@ ifneq ($(CONFIG_X86_GRUB_IMAGES),)
$(KDIR)/
endef
+ define Image/Build/grub2
+ # left here because the image builder doesnt need these
+ $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
+ $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
+ grub-mkimage \
+ -o $(KDIR)/grub2/core.img \
+ -O i386-pc \
+ -c ./grub-early.cfg \
+ $(GRUB2_MODULES)
+ $(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/grub2/
+ echo '(hd0) $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img' > $(KDIR)/grub2/device.map
+ sed \
+ -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
+ -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
+ -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
+ -e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
+ ./grub.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg
+ PADDING="$(CONFIG_TARGET_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_generic.sh \
+ $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
+ $(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.grub \
+ $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1) \
+ 256
+ grub-bios-setup \
+ --device-map="$(KDIR)/grub2/device.map" \
+ -d "$(KDIR)/grub2" \
+ -r "hd0,msdos1" \
+ "$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img"
+ $(call Image/Build/grub/$(1))
+ endef
endif
ROOTDELAY=10
@@ -210,7 +244,7 @@ define Image/Build
$(call Image/Build/$(1))
$(call Image/Build/bootscript,$(1))
ifneq ($(1),iso)
- $(call Image/Build/grub,$(1))
+ $(call Image/Build/$(if $(CONFIG_X86_USE_GRUB2),grub2,grub),$(1))
$(call Image/Build/vdi,$(1))
$(call Image/Build/vmdk,$(1))
endif
diff --git a/target/linux/x86/image/grub-early.cfg b/target/linux/x86/image/grub-early.cfg
new file mode 100644
index 000000000..4a5b5a609
--- /dev/null
+++ b/target/linux/x86/image/grub-early.cfg
@@ -0,0 +1 @@
+configfile (hd0,msdos1)/boot/grub/grub.cfg
diff --git a/target/linux/x86/image/grub.cfg b/target/linux/x86/image/grub.cfg
new file mode 100644
index 000000000..4e55dcfa6
--- /dev/null
+++ b/target/linux/x86/image/grub.cfg
@@ -0,0 +1,13 @@
+@SERIAL_CONFIG@
+@TERMINAL_CONFIG@
+
+set default="0"
+set timeout="@TIMEOUT@"
+set root='(hd0,msdos1)'
+
+menuentry "OpenWrt" {
+ linux /boot/vmlinuz @CMDLINE@ noinitrd reboot=bios
+}
+menuentry "OpenWrt (failsafe)" {
+ linux /boot/vmlinuz failsafe=true @CMDLINE@ noinitrd reboot=bios
+}