summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2017-02-09 04:01:36 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2017-02-09 04:01:57 +0100
commit571d99e74d42fac830069c2ca2fbd5f505613dc6 (patch)
treedb2700a1dd94b5b6760ee19573ef7395e6e1d901
parentfdfd165799d762acd6cf5871bfcb1493da1359e9 (diff)
add dual-boot / fwupdate for systems with grub-support
-rw-r--r--mk/image.mk14
-rw-r--r--package/fwupdate/Makefile3
-rwxr-xr-xpackage/fwupdate/src/fwupdate16
-rw-r--r--package/grub/Makefile20
-rw-r--r--package/grub/files/grub-dual.cfg50
-rw-r--r--rules.mk1
-rw-r--r--target/config/Config.in.rootfs17
-rw-r--r--target/config/Config.in.runtime2
-rw-r--r--target/x86_64/qemu-x86_64/genimage-dual.cfg34
-rw-r--r--target/x86_64/qemu-x86_64/genimage-efi-dual.cfg37
10 files changed, 189 insertions, 5 deletions
diff --git a/mk/image.mk b/mk/image.mk
index 5db333b19..f3ebcf50f 100644
--- a/mk/image.mk
+++ b/mk/image.mk
@@ -129,8 +129,13 @@ ROOTFSISO= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}.iso
kernel-package: kernel-strip
$(START_TRACE) "target/$(ADK_TARGET_ARCH)-create-kernel-package.. "
rm -rf $(KERNEL_PKGDIR)
+ifeq ($(ADK_TARGET_DUAL_BOOT),y)
+ @mkdir -p $(KERNEL_PKGDIR)
+ cp $(BUILD_DIR)/$(TARGET_KERNEL) $(KERNEL_PKGDIR)/kernel
+else
@mkdir -p $(KERNEL_PKGDIR)/boot
cp $(BUILD_DIR)/$(TARGET_KERNEL) $(KERNEL_PKGDIR)/boot/kernel
+endif
@${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh ${KERNEL_PKGDIR} \
../linux/kernel.control ${KERNEL_VERSION} ${ADK_TARGET_CPU_ARCH}
$(PKG_BUILD) $(KERNEL_PKGDIR) $(PACKAGE_DIR) $(MAKE_TRACE)
@@ -312,6 +317,15 @@ endif
--rootpath "$(TARGET_DIR)" \
--inputpath "$(FW_DIR)" \
--outputpath "$(FW_DIR)" $(MAKE_TRACE)
+ifeq ($(ADK_TARGET_DUAL_BOOT),y)
+ (cd ${TARGET_DIR}; find . | grep -v ./boot/ | sed -n '/^\.\//s///p' | sort | \
+ PATH='${HOST_PATH}' $(CPIO) -o --quiet -Hustar --owner=0:0 | \
+ ${XZ} -c > ${FW_DIR}/openadk.tar.xz)
+ (cd ${FW_DIR}; PATH='${HOST_PATH}' sha256sum openadk.tar.xz \
+ | cut -d\ -f1 > sha256.txt)
+ (cd ${FW_DIR}; PATH='${HOST_PATH}' tar -cf ${ADK_TARGET_SYSTEM}-update.tar openadk.tar.xz sha256.txt)
+ @rm -rf ${FW_DIR}/temp
+endif
ifeq ($(ADK_PACKAGE_GRUB_EFI_X86)$(ADK_PACKAGE_GRUB_EFI_X86_64),y)
@if [ ! -f $(ADK_TOPDIR)/bios-$(ADK_TARGET_ARCH).bin ]; then \
cd $(ADK_TOPDIR); wget http://distfiles.openadk.org/bios-$(ADK_TARGET_ARCH).bin ;\
diff --git a/package/fwupdate/Makefile b/package/fwupdate/Makefile
index 729ea6def..8cf897ed4 100644
--- a/package/fwupdate/Makefile
+++ b/package/fwupdate/Makefile
@@ -8,8 +8,11 @@ PKG_VERSION:= 1.0
PKG_RELEASE:= 1
PKG_DESCR:= update firmware
PKG_SECTION:= base/adk
+PKG_DEPENDS:= mke2fs
PKG_URL:= http://www.openadk.org
+PKG_CFLINE_FWUPDATE:= select BUSYBOX_SHA256SUM@
+
NO_DISTFILES:= 1
include $(ADK_TOPDIR)/mk/package.mk
diff --git a/package/fwupdate/src/fwupdate b/package/fwupdate/src/fwupdate
index 7a73115e0..1efe08339 100755
--- a/package/fwupdate/src/fwupdate
+++ b/package/fwupdate/src/fwupdate
@@ -44,7 +44,7 @@ CHECK_SUM_NEW_SYSTEM=$(tar -xf $FIRMWARE $FW_NAME -O | sha256sum - |cut -d\ -f1
echo "Compare the checksums ..."
if [ "X$CHECK_SUM_NEW_SYSTEM" = "X$CHECK_SUM_UPDATE_FILE" ]; then
- echo "Checksum verified (they match): "
+ echo "Checksum verified (they match) ..."
else
echo "Checksum does not match!"
echo "${CHECK_SUM_UPDATE_FILE} "
@@ -130,8 +130,18 @@ fi
cd /
umount $MOUNTPART
-mount -o remount,rw /boot
+grep /boot /proc/mounts 2>/dev/null
+if [ $? -eq 0 ]; then
+ mount -o remount,rw /boot
+else
+ mount /dev/sda1 /boot
+fi
grub-reboot $OS
-mount -o remount,ro /boot
+grep /boot /proc/mounts 2>/dev/null
+if [ $? -eq 0 ]; then
+ mount -o remount,ro /boot
+else
+ umount /boot
+fi
sync
echo "Reboot now to the updated system $OS"
diff --git a/package/grub/Makefile b/package/grub/Makefile
index 0198c5337..1e7a2625f 100644
--- a/package/grub/Makefile
+++ b/package/grub/Makefile
@@ -91,6 +91,12 @@ GRUB_PLATFORM= efi
GRUB_MODULES= boot linux ext2 fat part_msdos part_gpt normal efi_gop
endif
+ifeq ($(ADK_TARGET_DUAL_BOOT),y)
+GRUB_CFG= grub-dual.cfg
+else
+GRUB_CFG= grub.cfg
+endif
+
HOST_CONFIGURE_ARGS+= --enable-efiemu=no \
--disable-grub-mkfont \
--enable-device-mapper=no \
@@ -102,6 +108,11 @@ CONFIGURE_ARGS+= --disable-grub-mkfont \
--enable-libzfs=no \
--with-platform=$(GRUB_PLATFORM) \
--disable-werror
+
+ifeq ($(ADK_PACKAGE_GRUB_EFI_X86)$(ADK_PACKAGE_GRUB_EFI_X86_64),y)
+CONFIGURE_ARGS+= --with-bootdir=/boot/EFI/boot \
+ --with-grubdir=/
+endif
XAKE_FLAGS+= GCC_HONOUR_COPTS=s
grub-install:
@@ -120,11 +131,12 @@ endif
ifeq ($(ADK_PACKAGE_GRUB_EFI_X86)$(ADK_PACKAGE_GRUB_EFI_X86_64),y)
${CP} ${WRKINST}/usr/lib/grub/$(GRUB_ARCH) \
$(FW_DIR)/$(GRUB_DIR)
- $(CP) ./files/grub.cfg $(FW_DIR)/$(GRUB_DIR)
+ $(CP) ./files/$(GRUB_CFG) $(FW_DIR)/$(GRUB_DIR)/grub.cfg
+ $(SED) "s/@@ROOTDEV@@/$(ADK_TARGET_ROOTDEV)/g" $(FW_DIR)/$(GRUB_DIR)/grub.cfg
else
${CP} ${WRKINST}/usr/lib/grub/${GRUB_ARCH} \
$(IDIR_GRUB)/$(GRUB_DIR)
- $(CP) ./files/grub.cfg $(IDIR_GRUB)/$(GRUB_DIR)
+ $(CP) ./files/$(GRUB_CFG) $(IDIR_GRUB)/$(GRUB_DIR)/grub.cfg
endif
$(STAGING_HOST_DIR)/usr/bin/grub-mkimage \
-d $(WRKINST)/usr/lib/grub/$(GRUB_ARCH) \
@@ -147,6 +159,10 @@ grub-tools-install:
$(IDIR_GRUB_TOOLS)/usr/bin
${INSTALL_BIN} ${WRKINST}/usr/bin/grub-mkimage \
$(IDIR_GRUB_TOOLS)/usr/bin
+ ${INSTALL_BIN} ${WRKINST}/usr/sbin/grub-reboot \
+ $(IDIR_GRUB_TOOLS)/usr/sbin
+ ${INSTALL_BIN} ${WRKINST}/usr/sbin/grub-set-default \
+ $(IDIR_GRUB_TOOLS)/usr/sbin
${CP} ${WRKINST}/usr/lib/grub \
$(IDIR_GRUB_TOOLS)/usr/lib
${CP} ${WRKINST}/usr/share/grub \
diff --git a/package/grub/files/grub-dual.cfg b/package/grub/files/grub-dual.cfg
new file mode 100644
index 000000000..bae2fa414
--- /dev/null
+++ b/package/grub/files/grub-dual.cfg
@@ -0,0 +1,50 @@
+if [ "x\${timeout}" != "x-1" ]; then
+ if keystatus; then
+ if keystatus --shift; then
+ set timeout=-1
+ else
+ set timeout=0
+ fi
+ else
+ if sleep --interruptible 2; then
+ set timeout=0
+ fi
+ fi
+fi
+
+if [ -s $prefix/grubenv ]; then
+ set have_grubenv=true
+ load_env
+fi
+if [ "${next_entry}" ] ; then
+ set default="${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
+else
+ set default="${saved_entry}"
+fi
+if [ "${prev_saved_entry}" ]; then
+ set saved_entry="${prev_saved_entry}"
+ save_env saved_entry
+ set prev_saved_entry=
+ save_env prev_saved_entry
+ set boot_once=true
+fi
+
+function savedefault {
+ if [ -z "${boot_once}" ]; then
+ saved_entry="${chosen}"
+ save_env saved_entry
+ fi
+}
+
+menuentry "OpenADK1" {
+ set root=(hd0,2)
+ linux (hd0,2)/kernel root=/dev/@@ROOTDEV@@2 rootfstype=ext4 rootwait panic=5
+}
+menuentry "OpenADK2" {
+ set root=(hd0,3)
+ linux (hd0,3)/kernel root=/dev/@@ROOTDEV@@3 rootfstype=ext4 rootwait panic=5
+}
+
diff --git a/rules.mk b/rules.mk
index b01fd63d2..d59a30f4e 100644
--- a/rules.mk
+++ b/rules.mk
@@ -73,6 +73,7 @@ ADK_TARGET_KERNEL_GIT_VER:= $(strip $(subst ",, $(ADK_TARGET_KERNEL_GIT_VER)))
ADK_TARGET_KERNEL_GIT_TYPE:= $(strip $(subst ",, $(ADK_TARGET_KERNEL_GIT_TYPE)))
ADK_TARGET_KERNEL_DEFCONFIG:= $(strip $(subst ",, $(ADK_TARGET_KERNEL_DEFCONFIG)))
ADK_TARGET_GENIMAGE_FILENAME:= $(strip $(subst ",, $(ADK_TARGET_GENIMAGE_FILENAME)))
+ADK_TARGET_ROOTDEV:= $(strip $(subst ",, $(ADK_TARGET_ROOTDEV)))
ADK_TARGET_KARCH:=$(ADK_TARGET_ARCH)
diff --git a/target/config/Config.in.rootfs b/target/config/Config.in.rootfs
index 96fb5c1a2..41e9b27a6 100644
--- a/target/config/Config.in.rootfs
+++ b/target/config/Config.in.rootfs
@@ -158,6 +158,7 @@ config ADK_TARGET_ROOTFS_ARCHIVE
config ADK_TARGET_ROOTFS_GENIMAGE
bool "Create a disk image for the target"
select ADK_KERNEL_EXT4_FS
+ select ADK_KERNEL_VFAT_FS
select ADK_TARGET_QEMU_WITH_BLOCK if ADK_TARGET_QEMU
select ADK_HOST_BUILD_GENIMAGE
help
@@ -165,7 +166,23 @@ config ADK_TARGET_ROOTFS_GENIMAGE
endchoice
+config ADK_TARGET_ROOTDEV
+ string
+ default "sda"
+
+config ADK_TARGET_DUAL_BOOT
+ bool "Activate dual-boot partition layout"
+ depends on ADK_TARGET_ROOTFS_GENIMAGE
+ select ADK_PACKAGE_FWUPDATE
+ help
+ Activate dual-boot partition scheme for simple full updates into
+ a second unused partition. You can use fwupdate on the target to
+ update your system. A firmware update tar archive is created in
+ firmware output directory together with the full image.
+
config ADK_TARGET_GENIMAGE_FILENAME
string
+ default "genimage-efi-dual.cfg" if ADK_PACKAGE_GRUB_EFI_X86_64 || ADK_PACKAGE_GRUB_EFI_X86 && ADK_TARGET_DUAL_BOOT
default "genimage-efi.cfg" if ADK_PACKAGE_GRUB_EFI_X86_64 || ADK_PACKAGE_GRUB_EFI_X86
+ default "genimage-dual.cfg" if ADK_TARGET_DUAL_BOOT
default "genimage.cfg"
diff --git a/target/config/Config.in.runtime b/target/config/Config.in.runtime
index 62173c362..5e7cc27a6 100644
--- a/target/config/Config.in.runtime
+++ b/target/config/Config.in.runtime
@@ -173,6 +173,8 @@ config ADK_RUNTIME_TMPFS_SIZE
default "32768" if ADK_TARGET_SYSTEM_RASPBERRY_PI2
default "32768" if ADK_TARGET_SYSTEM_RASPBERRY_PI3
default "32768" if ADK_TARGET_SYSTEM_SOLIDRUN_IMX6
+ default "16384" if ADK_TARGET_SYSTEM_QEMU_X86_64
+ default "16384" if ADK_TARGET_SYSTEM_QEMU_X86
default "16384" if ADK_TARGET_VBOX
default "16384" if ADK_TARGET_SYSTEM_LEMOTE_YEELONG
default "8192" if ADK_TARGET_SYSTEM_MIKROTIK_RB532
diff --git a/target/x86_64/qemu-x86_64/genimage-dual.cfg b/target/x86_64/qemu-x86_64/genimage-dual.cfg
new file mode 100644
index 000000000..82d6dc2c2
--- /dev/null
+++ b/target/x86_64/qemu-x86_64/genimage-dual.cfg
@@ -0,0 +1,34 @@
+image disk.img {
+
+ hdimage {
+ }
+
+ partition boot {
+ in-partition-table = "no"
+ image = "boot.img"
+ offset = 0
+ size = 512
+ }
+
+ partition grub {
+ in-partition-table = "no"
+ image = "grub.img"
+ offset = 512
+ }
+
+ partition root1 {
+ partition-type = 0x83
+ image = "rootfs.ext"
+ }
+
+ partition root2 {
+ partition-type = 0x83
+ image = "rootfs.ext"
+ }
+
+ partition cfgfs {
+ partition-type = 0x88
+ image = "cfgfs.img"
+ }
+
+}
diff --git a/target/x86_64/qemu-x86_64/genimage-efi-dual.cfg b/target/x86_64/qemu-x86_64/genimage-efi-dual.cfg
new file mode 100644
index 000000000..7c82a0bcb
--- /dev/null
+++ b/target/x86_64/qemu-x86_64/genimage-efi-dual.cfg
@@ -0,0 +1,37 @@
+image efi-part.vfat {
+ vfat {
+ file EFI {
+ image = "efi-part/EFI"
+ }
+ }
+ size = 32M
+}
+
+image disk.img {
+
+ hdimage {
+ }
+
+ partition boot {
+ partition-type = 0xEF
+ image = "efi-part.vfat"
+ }
+
+ partition root1 {
+ partition-type = 0x83
+ image = "rootfs.ext"
+ size = 128M
+ }
+
+ partition root2 {
+ partition-type = 0x83
+ image = "rootfs.ext"
+ size = 128M
+ }
+
+ partition cfgfs {
+ partition-type = 0x88
+ image = "cfgfs.img"
+ }
+
+}