1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-03-09 15:40:20 +00:00

Update OpenWrt and UEFI patch

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-09-10 18:19:24 +02:00
parent 819aabbf22
commit dd2ee05daa
2 changed files with 149 additions and 35 deletions

View file

@ -1,7 +1,7 @@
From bb60d3b29ad3ce3bdae786498f6d2160d80426cb Mon Sep 17 00:00:00 2001
From c8c937208ee2f9cd6f3a206a0f8408951767a9b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E5=9B=BD?= <uxgood.org@gmail.com>
Date: Thu, 4 Apr 2019 02:40:15 +0000
Subject: [PATCH 1/3] firmware-utils: ptgen: add GPT support
Subject: [PATCH 1/4] firmware-utils: ptgen: add GPT support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -23,10 +23,10 @@ Signed-off-by: 李国 <uxgood.org@gmail.com>
2 files changed, 314 insertions(+), 25 deletions(-)
diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index bde90f0ecd1..4a27e69ce52 100644
index 2d2c96ce0af..d50faa42db2 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -25,7 +25,7 @@ define Host/Compile
@@ -31,7 +31,7 @@ define Host/Compile
$(call cc,dgfirmware)
$(call cc,mksenaofw md5, -Wall --std=gnu99)
$(call cc,trx2usr)
@ -493,10 +493,10 @@ index 0192bb65e51..caee0f94190 100644
+ }
}
From b72e8c90af941960f77bd4f739e1fbf75f0d4c14 Mon Sep 17 00:00:00 2001
From 252d3e1dfe244a4d5a594a85bdce466bbbc4f19a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E5=9B=BD?= <uxgood.org@gmail.com>
Date: Thu, 4 Apr 2019 03:17:01 +0000
Subject: [PATCH 2/3] grub2: split to grub2 and grub2-efi packages
Subject: [PATCH 2/4] grub2: split to grub2 and grub2-efi packages
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -507,24 +507,32 @@ so we split it to grub2 and grub2-efi packages.
Signed-off-by: 李国 <uxgood.org@gmail.com>
---
package/boot/grub2/{Makefile => common.mk} | 50 +++-------------------
package/boot/grub2/{Makefile => common.mk} | 52 +++-------------------
package/boot/grub2/grub2-efi/Makefile | 19 ++++++++
package/boot/grub2/grub2/Makefile | 46 ++++++++++++++++++++
3 files changed, 71 insertions(+), 44 deletions(-)
rename package/boot/grub2/{Makefile => common.mk} (53%)
package/boot/grub2/grub2/Makefile | 46 +++++++++++++++++++
3 files changed, 72 insertions(+), 45 deletions(-)
rename package/boot/grub2/{Makefile => common.mk} (52%)
create mode 100644 package/boot/grub2/grub2-efi/Makefile
create mode 100644 package/boot/grub2/grub2/Makefile
diff --git a/package/boot/grub2/Makefile b/package/boot/grub2/common.mk
similarity index 53%
similarity index 52%
rename from package/boot/grub2/Makefile
rename to package/boot/grub2/common.mk
index d6af65128e5..5c7e65d37f5 100644
index 1f92ba92502..53ee26552f8 100644
--- a/package/boot/grub2/Makefile
+++ b/package/boot/grub2/common.mk
@@ -19,49 +19,19 @@ PKG_HASH:=810b3798d316394f94096ec2797909dbf23c858e48f7b3830826b8daa06b7b0f
@@ -11,56 +11,26 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=grub
PKG_CPE_ID:=cpe:/a:gnu:grub2
PKG_VERSION:=2.04
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@GNU/grub
PKG_HASH:=e5292496995ad42dabe843a0192cf2a2c502e7ffcc7479398232b10a472df77d
PKG_FIXUP:=autoreconf
HOST_BUILD_PARALLEL:=1
-PKG_BUILD_DEPENDS:=grub2/host
@ -576,7 +584,7 @@ index d6af65128e5..5c7e65d37f5 100644
HOST_CONFIGURE_VARS += \
grub_build_mkfont_excuse="don't want fonts"
@@ -72,7 +42,8 @@ HOST_CONFIGURE_ARGS += \
@@ -71,7 +41,8 @@ HOST_CONFIGURE_ARGS += \
--sbindir="$(STAGING_DIR_HOST)/bin" \
--disable-werror \
--disable-libzfs \
@ -586,7 +594,7 @@ index d6af65128e5..5c7e65d37f5 100644
HOST_MAKE_FLAGS += \
TARGET_RANLIB=$(TARGET_RANLIB) \
@@ -82,12 +53,3 @@ define Host/Configure
@@ -81,12 +52,3 @@ define Host/Configure
$(SED) 's,(RANLIB),(TARGET_RANLIB),' $(HOST_BUILD_DIR)/grub-core/Makefile.in
$(Host/Configure/Default)
endef
@ -677,10 +685,10 @@ index 00000000000..b1db13295d9
+$(eval $(call BuildPackage,grub2))
+$(eval $(call BuildPackage,grub2-editenv))
From 5762e8237dc9b79242d055189421baeb84088a34 Mon Sep 17 00:00:00 2001
From 4d3e51d9aa9d81b4444e9ed16c41459efa083370 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E5=9B=BD?= <uxgood.org@gmail.com>
Date: Thu, 4 Apr 2019 03:42:16 +0000
Subject: [PATCH 3/3] x86: add EFI images and make iso images EFI bootable
Subject: [PATCH 3/4] x86: add EFI images and make iso images EFI bootable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -699,7 +707,7 @@ kernel can not find rootfs, we pad enough sectors will be ok.
Signed-off-by: 李国 <uxgood.org@gmail.com>
---
config/Config-images.in | 27 +++--
.../base-files/files/lib/upgrade/common.sh | 15 +++
.../base-files/files/lib/upgrade/common.sh | 11 ++
scripts/gen_image_generic.sh | 10 +-
.../x86/base-files/lib/preinit/79_move_config | 6 +-
.../x86/base-files/lib/upgrade/platform.sh | 6 +-
@ -707,10 +715,10 @@ Signed-off-by: 李国 <uxgood.org@gmail.com>
target/linux/x86/generic/config-4.19 | 1 +
target/linux/x86/image/Makefile | 103 +++++++++++++++++-
target/linux/x86/image/grub-iso.cfg | 7 +-
9 files changed, 157 insertions(+), 19 deletions(-)
9 files changed, 153 insertions(+), 19 deletions(-)
diff --git a/config/Config-images.in b/config/Config-images.in
index ee686e8266e..85c346762d0 100644
index a3d99288422..8ba069ed4fc 100644
--- a/config/Config-images.in
+++ b/config/Config-images.in
@@ -195,19 +195,28 @@ menu "Target Images"
@ -795,18 +803,14 @@ index ee686e8266e..85c346762d0 100644
Override the root partition on the final device. If left empty,
it will be mounted by PARTUUID which makes the kernel find the
diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
index bbedeefd262..78cdc2495ee 100644
index efa301cd950..a978c11e445 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -134,6 +134,21 @@ export_bootdevice() {
@@ -134,6 +134,17 @@ export_bootdevice() {
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]\
+-[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]02)
+ PARTUUID=????????-????-????-????-??????????02)
+ uuid="${rootpart#PARTUUID=}"
+ uuid="${uuid%02}00"
+ for disk in $(find /dev -type b); do
@ -870,7 +874,7 @@ index aff720a52c5..8eea97c5b66 100644
mv -f /boot/sysupgrade.tgz /
fi
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
index 439ba8f5125..ea66b4aa24f 100644
index 162dbaf3aaa..ac060818df1 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -35,10 +35,12 @@ platform_check_image() {
@ -889,7 +893,7 @@ index 439ba8f5125..ea66b4aa24f 100644
umount /mnt
fi
diff --git a/target/linux/x86/generic/config-4.14 b/target/linux/x86/generic/config-4.14
index 92380f526db..8f4b5182312 100644
index 1e31e117dd0..41bd58afddd 100644
--- a/target/linux/x86/generic/config-4.14
+++ b/target/linux/x86/generic/config-4.14
@@ -125,6 +125,7 @@ CONFIG_FB_EFI=y
@ -901,7 +905,7 @@ index 92380f526db..8f4b5182312 100644
CONFIG_FB_SYS_FILLRECT=y
CONFIG_FB_SYS_FOPS=y
diff --git a/target/linux/x86/generic/config-4.19 b/target/linux/x86/generic/config-4.19
index e769835b73a..89a6e142022 100644
index 4a689ca026c..ada81ce04ea 100644
--- a/target/linux/x86/generic/config-4.19
+++ b/target/linux/x86/generic/config-4.19
@@ -139,6 +139,7 @@ CONFIG_FB_DEFERRED_IO=y
@ -913,7 +917,7 @@ index e769835b73a..89a6e142022 100644
CONFIG_FB_SYS_FILLRECT=y
CONFIG_FB_SYS_FOPS=y
diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
index 24825f2ba2c..176c01833db 100644
index ac70e771c86..6af5cfed963 100644
--- a/target/linux/x86/image/Makefile
+++ b/target/linux/x86/image/Makefile
@@ -11,6 +11,7 @@ export PATH=$(TARGET_PATH):/sbin
@ -1032,7 +1036,7 @@ index 24825f2ba2c..176c01833db 100644
- define Image/Build/vdi
+ define Image/Build/vdi/default
rm $(BIN_DIR)/$(IMG_COMBINED)-$(1).vdi || true
qemu-img convert -f raw -O vdi \
$(STAGING_DIR_HOST)/bin/qemu-img convert -f raw -O vdi \
$(BIN_DIR)/$(IMG_COMBINED)-$(1).img \
@@ -129,7 +204,7 @@ ifneq ($(CONFIG_VDI_IMAGES),)
endif
@ -1041,7 +1045,7 @@ index 24825f2ba2c..176c01833db 100644
- define Image/Build/vmdk
+ define Image/Build/vmdk/default
rm $(BIN_DIR)/$(IMG_COMBINED)-$(1).vmdk || true
qemu-img convert -f raw -O vmdk \
$(STAGING_DIR_HOST)/bin/qemu-img convert -f raw -O vmdk \
$(BIN_DIR)/$(IMG_COMBINED)-$(1).img \
@@ -137,8 +212,27 @@ ifneq ($(CONFIG_VMDK_IMAGES),)
endef
@ -1100,3 +1104,113 @@ index 9c59bdf6d49..92516b61e5e 100644
menuentry "@TITLE@" {
linux /boot/vmlinuz @CMDLINE@ noinitrd
From a72d68886dff937dab696ecae757c5d5f72c7279 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E5=9B=BD?= <uxgood.org@gmail.com>
Date: Sat, 31 Aug 2019 13:28:05 +0000
Subject: [PATCH 4/4] x86: fix sysupgrade for EFI images
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
1. make function get_partitions support GPT disks
2. get more bytes from image to get GPT partition table
3. update the original PARTUUID to new grub.cfg
Signed-off-by: 李国 <uxgood.org@gmail.com>
---
.../base-files/files/lib/upgrade/common.sh | 40 ++++++++++++++-----
.../x86/base-files/lib/upgrade/platform.sh | 17 +++++++-
2 files changed, 44 insertions(+), 13 deletions(-)
diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
index a978c11e445..9ae634932d2 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -204,17 +204,35 @@ get_partitions() { # <device> <filename>
rm -f "/tmp/partmap.$filename"
local part
- for part in 1 2 3 4; do
- set -- $(hexdump -v -n 12 -s "$((0x1B2 + $part * 16))" -e '3/4 "0x%08X "' "$disk")
-
- local type="$(( $(hex_le32_to_cpu $1) % 256))"
- local lba="$(( $(hex_le32_to_cpu $2) ))"
- local num="$(( $(hex_le32_to_cpu $3) ))"
-
- [ $type -gt 0 ] || continue
-
- printf "%2d %5d %7d\n" $part $lba $num >> "/tmp/partmap.$filename"
- done
+ local magic=$(dd if="$disk" bs=8 count=1 skip=64 2>/dev/null)
+ if [ "$magic" = "EFI PART" ]; then
+ #export_partdevice will fail when partition number is greater than 15, as
+ #the partition major device number is not equal to the disk major device number
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
+ set -- $(hexdump -v -n 48 -s "$((0x380 + $part * 0x80))" -e '4/4 "%08x"" "4/4 "%08x"" "4/4 "0x%08X "' "$disk")
+
+ local type="$1"
+ local lba="$(( $(hex_le32_to_cpu $4) * 0x100000000 + $(hex_le32_to_cpu $3) ))"
+ local end="$(( $(hex_le32_to_cpu $6) * 0x100000000 + $(hex_le32_to_cpu $5) ))"
+ local num="$(( $end - $lba ))"
+
+ [ "$type" = "00000000000000000000000000000000" ] && continue
+
+ printf "%2d %5d %7d\n" $part $lba $num >> "/tmp/partmap.$filename"
+ done
+ else
+ for part in 1 2 3 4; do
+ set -- $(hexdump -v -n 12 -s "$((0x1B2 + $part * 16))" -e '3/4 "0x%08X "' "$disk")
+
+ local type="$(( $(hex_le32_to_cpu $1) % 256))"
+ local lba="$(( $(hex_le32_to_cpu $2) ))"
+ local num="$(( $(hex_le32_to_cpu $3) ))"
+
+ [ $type -gt 0 ] || continue
+
+ printf "%2d %5d %7d\n" $part $lba $num >> "/tmp/partmap.$filename"
+ done
+ fi
fi
}
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
index ac060818df1..f66c5873e37 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -18,7 +18,7 @@ platform_check_image() {
get_partitions "/dev/$diskdev" bootdisk
#extract the boot sector from the image
- get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null
+ get_image "$@" | dd of=/tmp/image.bs count=63 bs=512b 2>/dev/null
get_partitions /tmp/image.bs image
@@ -60,7 +60,7 @@ platform_do_upgrade() {
get_partitions "/dev/$diskdev" bootdisk
#extract the boot sector from the image
- get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
+ get_image "$@" | dd of=/tmp/image.bs count=63 bs=512b
get_partitions /tmp/image.bs image
@@ -94,4 +94,17 @@ platform_do_upgrade() {
#copy partition uuid
echo "Writing new UUID to /dev/$diskdev..."
get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
+
+ local magic parttype=ext4
+ magic=$(dd if="/dev/$diskdev" bs=8 count=1 skip=64 2>/dev/null)
+ [ "$magic" = "EFI PART" ] || return 0
+ if export_partdevice partdev 1; then
+ magic=$(dd if="/dev/$partdev" bs=1 count=3 skip=54 2>/dev/null)
+ [ "$magic" = "FAT" ] && parttype=vfat
+ mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt
+ set -- $(dd if=/dev/$diskdev bs=1 skip=1168 count=16 2>/dev/null | hexdump -v -e '8/1 "%02x "" "2/1 "%02x""-"6/1 "%02x"')
+ sed -i "s/\(PARTUUID=\)[a-f0-9-]\+/\1$4$3$2$1-$6$5-$8$7-$9/ig" /mnt/boot/grub/grub.cfg
+ umount /mnt
+ fi
+
}