diff --git a/patches/uefi.patch b/patches/uefi.patch index 825b8e84..22f554e0 100644 --- a/patches/uefi.patch +++ b/patches/uefi.patch @@ -1,4 +1,4 @@ -From ab231a81af007ae364e5ce58de978ebd676a8556 Mon Sep 17 00:00:00 2001 +From bb60d3b29ad3ce3bdae786498f6d2160d80426cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=9B=BD?= Date: Thu, 4 Apr 2019 02:40:15 +0000 Subject: [PATCH 1/3] firmware-utils: ptgen: add GPT support @@ -19,16 +19,16 @@ sectors when generate these images. Signed-off-by: 李国 --- tools/firmware-utils/Makefile | 2 +- - tools/firmware-utils/src/ptgen.c | 279 ++++++++++++++++++++++++++++++- - 2 files changed, 274 insertions(+), 7 deletions(-) + tools/firmware-utils/src/ptgen.c | 337 ++++++++++++++++++++++++++++--- + 2 files changed, 314 insertions(+), 25 deletions(-) diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile -index 76d5929af52..ef4dffd31d6 100644 +index bde90f0ecd1..4a27e69ce52 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -25,7 +25,7 @@ define Host/Compile $(call cc,dgfirmware) - $(call cc,mksenaofw md5) + $(call cc,mksenaofw md5, -Wall --std=gnu99) $(call cc,trx2usr) - $(call cc,ptgen) + $(call cc,ptgen cyg_crc32) @@ -36,10 +36,10 @@ index 76d5929af52..ef4dffd31d6 100644 $(call cc,mkmylofw) $(call cc,mkcsysimg) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c -index 0192bb65e51..7f7c74ef591 100644 +index 0192bb65e51..caee0f94190 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c -@@ -31,15 +31,50 @@ +@@ -31,15 +31,62 @@ #include #include #include @@ -67,6 +67,8 @@ index 0192bb65e51..7f7c74ef591 100644 + UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) +#endif + ++#define GUID_STRING_LENGTH 36 ++ +#define GPT_SIGNATURE 0x5452415020494645ULL +#define GPT_REVISION 0x00010000 + @@ -85,12 +87,22 @@ index 0192bb65e51..7f7c74ef591 100644 +#define GPT_HEADER_SIZE 92 +#define GPT_ENTRY_SIZE 128 +#define GPT_ENTRY_MAX 128 ++#define GPT_ENTRY_NAME_SIZE 72 + ++#define GPT_HEADER_SECTOR 1 ++#define GPT_FIRST_ENTRY_SECTOR 2 ++ ++#define MBR_ENTRY_MAX 4 ++#define MBR_DISK_SIGNATURE_OFFSET 440 ++#define MBR_PARTITION_ENTRY_OFFSET 446 ++#define MBR_BOOT_SIGNATURE_OFFSET 510 ++ ++#define DISK_SECTOR_SIZE 512 + /* Partition table entry */ struct pte { uint8_t active; -@@ -55,13 +90,43 @@ struct partinfo { +@@ -55,13 +102,43 @@ struct partinfo { int type; }; @@ -119,7 +131,7 @@ index 0192bb65e51..7f7c74ef591 100644 + uint64_t start; + uint64_t end; + uint64_t attr; -+ uint16_t name[72 / sizeof(uint16_t)]; ++ uint16_t name[GPT_ENTRY_NAME_SIZE / sizeof(uint16_t)]; +} __attribute__((packed)); + + @@ -135,7 +147,16 @@ index 0192bb65e51..7f7c74ef591 100644 char *filename = NULL; -@@ -132,6 +197,57 @@ static inline unsigned long round_to_kb(long sect) { +@@ -91,7 +168,7 @@ static long to_kbytes(const char *string) + end++; + + if (*end) { +- fprintf(stderr, "garbage after end of number\n"); ++ fputs("garbage after end of number\n", stderr); + return 0; + } + +@@ -132,20 +209,73 @@ static inline unsigned long round_to_kb(long sect) { return ((sect - 1) / kb_align + 1) * kb_align; } @@ -150,12 +171,12 @@ index 0192bb65e51..7f7c74ef591 100644 +{ + char b[4] = {0}; + char *p = buf; -+ int i = 0; -+ if (strnlen(buf, 36) != 36) ++ unsigned i = 0; ++ if (strnlen(buf, GUID_STRING_LENGTH) != GUID_STRING_LENGTH) + return -1; -+ for (i = 0; i < 16; i++) { ++ for (i = 0; i < sizeof(guid_t); i++) { + if (*p == '-') -+ p ++; ++ p++; + if (*p == '\0') + return -1; + memcpy(b, p, 2); @@ -170,22 +191,24 @@ index 0192bb65e51..7f7c74ef591 100644 +} + +/* init an utf-16 string from utf-8 string */ -+static inline void init_utf16(char *str, uint16_t *buf, int bufsize) ++static inline void init_utf16(char *str, uint16_t *buf, unsigned bufsize) +{ -+ int i, n = 0; ++ unsigned i, n = 0; + for (i = 0; i < bufsize; i++) { + if (str[n] == 0x00) { + buf[i] = 0x00; + return ; -+ } else if((str[n] & 0x80) == 0x00) {//0xxxxxxx ++ } else if ((str[n] & 0x80) == 0x00) {//0xxxxxxx + buf[i] = cpu_to_le16(str[n++]); -+ } else if((str[n] & 0xE0) == 0xC0) {//110xxxxx -+ buf[i] = cpu_to_le16((str[n++] & 0x1F) << 6 | str[n++] & 0x3F); -+ } else if((str[n] & 0xF0) == 0xE0) {//1110xxxx -+ buf[i] = cpu_to_le16((str[n++] & 0x0F) << 12 | (str[n++] & 0x3F) << 6 | str[n++] & 0x3F); ++ } else if ((str[n] & 0xE0) == 0xC0) {//110xxxxx ++ buf[i] = cpu_to_le16((str[n] & 0x1F) << 6 | str[n + 1] & 0x3F); ++ n += 2; ++ } else if ((str[n] & 0xF0) == 0xE0) {//1110xxxx ++ buf[i] = cpu_to_le16((str[n] & 0x0F) << 12 | (str[n + 1] & 0x3F) << 6 | str[n + 2] & 0x3F); ++ n += 3; + } else { + buf[i] = cpu_to_le16('?'); -+ n ++; ++ n++; + } + } +} @@ -193,28 +216,94 @@ index 0192bb65e51..7f7c74ef591 100644 /* check the partition sizes and write the partition table */ static int gen_ptable(uint32_t signature, int nr) { -@@ -198,20 +314,158 @@ static int gen_ptable(uint32_t signature, int nr) +- struct pte pte[4]; +- unsigned long sect = 0; +- int i, fd, ret = -1, start, len; ++ struct pte pte[MBR_ENTRY_MAX]; ++ unsigned long start, len, sect = 0; ++ int i, fd, ret = -1; + +- memset(pte, 0, sizeof(struct pte) * 4); ++ memset(pte, 0, sizeof(struct pte) * MBR_ENTRY_MAX); + for (i = 0; i < nr; i++) { + if (!parts[i].size) { + if (ignore_null_sized_partition) + continue; + fprintf(stderr, "Invalid size in partition %d!\n", i); +- return -1; ++ return ret; + } + + pte[i].active = ((i + 1) == active) ? 0x80 : 0; +@@ -165,30 +295,34 @@ static int gen_ptable(uint32_t signature, int nr) + to_chs(start + len - 1, pte[i].chs_end); + + if (verbose) +- fprintf(stderr, "Partition %d: start=%ld, end=%ld, size=%ld\n", i, (long)start * 512, ((long)start + (long)len) * 512, (long)len * 512); +- printf("%ld\n", (long)start * 512); +- printf("%ld\n", (long)len * 512); ++ fprintf(stderr, "Partition %d: start=%ld, end=%ld, size=%ld\n", ++ i, ++ (long)start * DISK_SECTOR_SIZE, ++ (long)(start + len) * DISK_SECTOR_SIZE, ++ (long)len * DISK_SECTOR_SIZE); ++ printf("%ld\n", (long)start * DISK_SECTOR_SIZE); ++ printf("%ld\n", (long)len * DISK_SECTOR_SIZE); + } + + if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) { + fprintf(stderr, "Can't open output file '%s'\n",filename); +- return -1; ++ return ret; + } + +- lseek(fd, 440, SEEK_SET); ++ lseek(fd, MBR_DISK_SIGNATURE_OFFSET, SEEK_SET); + if (write(fd, &signature, sizeof(signature)) != sizeof(signature)) { +- fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } + +- lseek(fd, 446, SEEK_SET); +- if (write(fd, pte, sizeof(struct pte) * 4) != sizeof(struct pte) * 4) { +- fprintf(stderr, "write failed.\n"); ++ lseek(fd, MBR_PARTITION_ENTRY_OFFSET, SEEK_SET); ++ if (write(fd, pte, sizeof(struct pte) * MBR_ENTRY_MAX) != sizeof(struct pte) * MBR_ENTRY_MAX) { ++ fputs("write failed.\n", stderr); + goto fail; + } +- lseek(fd, 510, SEEK_SET); ++ lseek(fd, MBR_BOOT_SIGNATURE_OFFSET, SEEK_SET); + if (write(fd, "\x55\xaa", 2) != 2) { +- fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } + +@@ -198,20 +332,162 @@ static int gen_ptable(uint32_t signature, int nr) return ret; } +/* check the partition sizes and write the guid partition table */ -+static int gen_gptable(uint32_t signature, guid_t guid, int nr) ++static int gen_gptable(uint32_t signature, guid_t guid, unsigned nr) +{ + struct pte pte; + struct gpth gpth = { + .signature = cpu_to_le64(GPT_SIGNATURE), + .revision = cpu_to_le32(GPT_REVISION), + .size = cpu_to_le32(GPT_HEADER_SIZE), -+ .self = cpu_to_le64(1), -+ .first_usable = cpu_to_le64(GPT_ENTRY_SIZE * GPT_ENTRY_MAX / 512 + 2), -+ .first_entry = cpu_to_le64(2), ++ .self = cpu_to_le64(GPT_HEADER_SECTOR), ++ .first_usable = cpu_to_le64(GPT_FIRST_ENTRY_SECTOR + GPT_ENTRY_SIZE * GPT_ENTRY_MAX / DISK_SECTOR_SIZE), ++ .first_entry = cpu_to_le64(GPT_FIRST_ENTRY_SECTOR), + .disk_guid = guid, + .entry_num = cpu_to_le32(GPT_ENTRY_MAX), + .entry_size = cpu_to_le32(GPT_ENTRY_SIZE), + }; + struct gpte gpte[GPT_ENTRY_MAX]; -+ unsigned long long start, end, sect = 0; -+ int i, fd, ret = -1; ++ uint64_t start, end, sect = 0; ++ int fd, ret = -1; ++ unsigned i; + + memset(gpte, 0, GPT_ENTRY_SIZE * GPT_ENTRY_MAX); + for (i = 0; i < nr; i++) { @@ -222,7 +311,7 @@ index 0192bb65e51..7f7c74ef591 100644 + if (ignore_null_sized_partition) + continue; + fprintf(stderr, "Invalid size in partition %d!\n", i); -+ return -1; ++ return ret; + } + start = sect + sectors; + if (kb_align != 0) @@ -234,95 +323,98 @@ index 0192bb65e51..7f7c74ef591 100644 + sect = round_to_cyl(sect); + gpte[i].end = cpu_to_le64(sect -1); + gpte[i].guid = guid; -+ gpte[i].guid.b[15] += i + 1; ++ gpte[i].guid.b[sizeof(guid_t) -1] += i + 1; + if (parts[i].type == 0xEF || (i + 1) == active) { + gpte[i].type = GUID_PARTITION_SYSTEM; -+ init_utf16("EFI System Partition", gpte[i].name, 36) ; ++ init_utf16("EFI System Partition", gpte[i].name, GPT_ENTRY_NAME_SIZE / sizeof(uint16_t)); + } else { + gpte[i].type = GUID_PARTITION_BASIC_DATA; + } + + if (verbose) -+ fprintf(stderr, "Partition %d: start=%lld, end=%lld, size=%lld\n", i, start * 512, sect * 512, (sect - start) * 512); -+ printf("%lld\n", start * 512); -+ printf("%lld\n", (sect - start) * 512); ++ fprintf(stderr, "Partition %d: start=%lld, end=%lld, size=%lld\n", ++ i, ++ start * DISK_SECTOR_SIZE, sect * DISK_SECTOR_SIZE, ++ (sect - start) * DISK_SECTOR_SIZE); ++ printf("%lld\n", start * DISK_SECTOR_SIZE); ++ printf("%lld\n", (sect - start) * DISK_SECTOR_SIZE); + } + -+ gpte[GPT_ENTRY_MAX - 1].start = cpu_to_le64(GPT_ENTRY_SIZE * GPT_ENTRY_MAX / 512 + 2); ++ gpte[GPT_ENTRY_MAX - 1].start = cpu_to_le64(GPT_FIRST_ENTRY_SECTOR + GPT_ENTRY_SIZE * GPT_ENTRY_MAX / DISK_SECTOR_SIZE); + gpte[GPT_ENTRY_MAX - 1].end = cpu_to_le64((kb_align ? round_to_kb(sectors) : sectors) - 1); + gpte[GPT_ENTRY_MAX - 1].type = GUID_PARTITION_BIOS_BOOT; + gpte[GPT_ENTRY_MAX - 1].guid = guid; -+ gpte[GPT_ENTRY_MAX - 1].guid.b[15] += GPT_ENTRY_MAX; ++ gpte[GPT_ENTRY_MAX - 1].guid.b[sizeof(guid_t) -1] += GPT_ENTRY_MAX; + + end = sect + sectors - 1; + + pte.type = 0xEE; -+ pte.start = cpu_to_le32(1); ++ pte.start = cpu_to_le32(GPT_HEADER_SECTOR); + pte.length = cpu_to_le32(end); -+ to_chs(1, pte.chs_start); ++ to_chs(GPT_HEADER_SECTOR, pte.chs_start); + to_chs(end, pte.chs_end); + -+ gpth.last_usable = cpu_to_le64(end - GPT_ENTRY_SIZE * GPT_ENTRY_MAX / 512 - 1); ++ gpth.last_usable = cpu_to_le64(end - GPT_ENTRY_SIZE * GPT_ENTRY_MAX / DISK_SECTOR_SIZE - 1); + gpth.alternate = cpu_to_le64(end); + gpth.entry_crc32 = cpu_to_le32(gpt_crc32(gpte, GPT_ENTRY_SIZE * GPT_ENTRY_MAX)); + gpth.crc32 = cpu_to_le32(gpt_crc32((char *)&gpth, GPT_HEADER_SIZE)); + + if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) { + fprintf(stderr, "Can't open output file '%s'\n",filename); -+ return -1; ++ return ret; + } + -+ lseek(fd, 440, SEEK_SET); ++ lseek(fd, MBR_DISK_SIGNATURE_OFFSET, SEEK_SET); + if (write(fd, &signature, sizeof(signature)) != sizeof(signature)) { -+ fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } + -+ lseek(fd, 446, SEEK_SET); ++ lseek(fd, MBR_PARTITION_ENTRY_OFFSET, SEEK_SET); + if (write(fd, &pte, sizeof(struct pte)) != sizeof(struct pte)) { -+ fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } + -+ lseek(fd, 510, SEEK_SET); ++ lseek(fd, MBR_BOOT_SIGNATURE_OFFSET, SEEK_SET); + if (write(fd, "\x55\xaa", 2) != 2) { -+ fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } + -+ lseek(fd, 512, SEEK_SET); ++ //lseek(fd, GPT_HEADER_SECTOR * DISK_SECTOR_SIZE, SEEK_SET); + if (write(fd, &gpth, GPT_HEADER_SIZE) != GPT_HEADER_SIZE) { -+ fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } + -+ lseek(fd, 1024, SEEK_SET); ++ lseek(fd, GPT_FIRST_ENTRY_SECTOR * DISK_SECTOR_SIZE, SEEK_SET); + if (write(fd, &gpte, GPT_ENTRY_SIZE * GPT_ENTRY_MAX) != GPT_ENTRY_SIZE * GPT_ENTRY_MAX) { -+ fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } + +#if 0 + /* The alternate partition table (We omit it) */ + swap(gpth.self, gpth.alternate); -+ gpth.first_entry = cpu_to_le64(end - GPT_ENTRY_SIZE * GPT_ENTRY_MAX / 512), ++ gpth.first_entry = cpu_to_le64(end - GPT_ENTRY_SIZE * GPT_ENTRY_MAX / DISK_SECTOR_SIZE), + gpth.crc32 = 0; + gpth.crc32 = cpu_to_le32(gpt_crc32(&gpth, GPT_HEADER_SIZE)); + -+ lseek(fd, end * 512 - GPT_ENTRY_SIZE * GPT_ENTRY_MAX, SEEK_SET); ++ lseek(fd, end * DISK_SECTOR_SIZE - GPT_ENTRY_SIZE * GPT_ENTRY_MAX, SEEK_SET); + if (write(fd, &gpte, GPT_ENTRY_SIZE * GPT_ENTRY_MAX) != GPT_ENTRY_SIZE * GPT_ENTRY_MAX) { -+ fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } + -+ lseek(fd, end * 512, SEEK_SET); ++ lseek(fd, end * DISK_SECTOR_SIZE, SEEK_SET); + if (write(fd, &gpth, GPT_HEADER_SIZE) != GPT_HEADER_SIZE) { -+ fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } -+ lseek(fd, end * 512 + 511, SEEK_SET); ++ lseek(fd, (end + 1) * DISK_SECTOR_SIZE -1, SEEK_SET); + if (write(fd, "\x00", 1) != 1) { -+ fprintf(stderr, "write failed.\n"); ++ fputs("write failed.\n", stderr); + goto fail; + } +#endif @@ -355,7 +447,7 @@ index 0192bb65e51..7f7c74ef591 100644 switch (ch) { case 'o': filename = optarg; -@@ -222,6 +476,9 @@ int main (int argc, char **argv) +@@ -222,6 +498,9 @@ int main (int argc, char **argv) case 'n': ignore_null_sized_partition = true; break; @@ -365,29 +457,31 @@ index 0192bb65e51..7f7c74ef591 100644 case 'h': heads = (int)strtoul(optarg, NULL, 0); break; -@@ -229,7 +486,7 @@ int main (int argc, char **argv) +@@ -229,8 +508,8 @@ int main (int argc, char **argv) sectors = (int)strtoul(optarg, NULL, 0); break; case 'p': - if (part > 3) { -+ if (part > GPT_ENTRY_MAX - 1 || (use_guid_partition_table == false && part > 3)) { - fprintf(stderr, "Too many partitions\n"); +- fprintf(stderr, "Too many partitions\n"); ++ if (part > GPT_ENTRY_MAX - 1 || (!use_guid_partition_table && part > 3)) { ++ fputs("Too many partitions\n", stderr); exit(EXIT_FAILURE); } -@@ -250,6 +507,12 @@ int main (int argc, char **argv) + parts[part].size = to_kbytes(optarg); +@@ -250,6 +529,12 @@ int main (int argc, char **argv) case 'S': signature = strtoul(optarg, NULL, 0); break; + case 'G': + if (guid_parse(optarg, &guid)) { -+ fprintf(stderr, "Invalid guid string\n"); ++ fputs("Invalid guid string\n", stderr); + exit(EXIT_FAILURE); + } + break; case '?': default: usage(argv[0]); -@@ -259,5 +522,9 @@ int main (int argc, char **argv) +@@ -259,5 +544,9 @@ int main (int argc, char **argv) if (argc || (heads <= 0) || (sectors <= 0) || !filename) usage(argv[0]); @@ -399,7 +493,7 @@ index 0192bb65e51..7f7c74ef591 100644 + } } -From 95bcdb36536f6697975adc18e8ba724738226504 Mon Sep 17 00:00:00 2001 +From b72e8c90af941960f77bd4f739e1fbf75f0d4c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=9B=BD?= Date: Thu, 4 Apr 2019 03:17:01 +0000 Subject: [PATCH 2/3] grub2: split to grub2 and grub2-efi packages @@ -583,7 +677,7 @@ index 00000000000..b1db13295d9 +$(eval $(call BuildPackage,grub2)) +$(eval $(call BuildPackage,grub2-editenv)) -From 4bcc334cead3225d13e5425a48a946f0da2966b4 Mon Sep 17 00:00:00 2001 +From 5762e8237dc9b79242d055189421baeb84088a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=9B=BD?= Date: Thu, 4 Apr 2019 03:42:16 +0000 Subject: [PATCH 3/3] x86: add EFI images and make iso images EFI bootable @@ -616,10 +710,10 @@ Signed-off-by: 李国 9 files changed, 157 insertions(+), 19 deletions(-) diff --git a/config/Config-images.in b/config/Config-images.in -index 9daaf749158..950f59ca657 100644 +index ee686e8266e..85c346762d0 100644 --- a/config/Config-images.in +++ b/config/Config-images.in -@@ -194,19 +194,28 @@ menu "Target Images" +@@ -195,19 +195,28 @@ menu "Target Images" select PACKAGE_grub2 default y @@ -651,7 +745,7 @@ index 9daaf749158..950f59ca657 100644 default 38400 if TARGET_x86_generic default 115200 -@@ -217,20 +226,20 @@ menu "Target Images" +@@ -218,20 +227,20 @@ menu "Target Images" config GRUB_BOOTOPTS string "Extra kernel boot options" @@ -675,7 +769,7 @@ index 9daaf749158..950f59ca657 100644 default "OpenWrt" help This is the title of the GRUB menu entry. -@@ -265,21 +274,21 @@ menu "Target Images" +@@ -260,21 +269,21 @@ menu "Target Images" config TARGET_KERNEL_PARTSIZE int "Kernel partition size (in MB)" @@ -701,10 +795,10 @@ index 9daaf749158..950f59ca657 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 b3a29fb32e3..f319692b491 100644 +index bbedeefd262..78cdc2495ee 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh -@@ -128,6 +128,21 @@ export_bootdevice() { +@@ -134,6 +134,21 @@ export_bootdevice() { fi done ;; @@ -724,7 +818,7 @@ index b3a29fb32e3..f319692b491 100644 + done + ;; /dev/*) - uevent="/sys/class/block/${disk##*/}/uevent" + uevent="/sys/class/block/${rootpart##*/}/../uevent" ;; diff --git a/scripts/gen_image_generic.sh b/scripts/gen_image_generic.sh index d9beeb02953..cc5a4d56fbe 100755 @@ -819,7 +913,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 84a3d88a7f2..aacb1b4830d 100644 +index 24825f2ba2c..176c01833db 100644 --- a/target/linux/x86/image/Makefile +++ b/target/linux/x86/image/Makefile @@ -11,6 +11,7 @@ export PATH=$(TARGET_PATH):/sbin @@ -834,13 +928,13 @@ index 84a3d88a7f2..aacb1b4830d 100644 SIGNATURE:=$(shell perl -e 'printf("%08x", rand(0xFFFFFFFF))') ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME)) ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(SIGNATURE)-02) -+EFI_SIGNATURE:=$(strip $(shell uuidgen | sed 's/[a-zA-Z0-9]\{2\}$$/00/')) ++EFI_SIGNATURE:=$(strip $(shell uuidgen | sed -r 's/[a-zA-Z0-9]{2}$$/00/')) +EFI_ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME)) +EFI_ROOTPART:=$(if $(EFI_ROOTPART),$(EFI_ROOTPART),PARTUUID=$(shell echo $(EFI_SIGNATURE) | sed 's/00$$/02/')) GRUB_TIMEOUT:=$(call qstrip,$(CONFIG_GRUB_TIMEOUT)) GRUB_TITLE:=$(call qstrip,$(CONFIG_GRUB_TITLE)) -@@ -93,8 +99,67 @@ ifneq ($(CONFIG_GRUB_IMAGES),) +@@ -93,8 +97,67 @@ ifneq ($(CONFIG_GRUB_IMAGES),) endef endif @@ -889,7 +983,7 @@ index 84a3d88a7f2..aacb1b4830d 100644 + -e 's#msdos1#gpt1#g' \ + ./grub.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg + -$(CP) $(STAGING_DIR_ROOT)/boot/. $(KDIR)/root.grub/boot/ -+ EFI_SIGNATURE=$(EFI_SIGNATURE) PADDING="$(CONFIG_TARGET_IMAGES_PAD)" SIGNATURE="$(SIGNATURE)" PATH="$(TARGET_PATH)" $(SCRIPT_DIR)/gen_image_generic.sh \ ++ EFI_SIGNATURE=$(EFI_SIGNATURE) PADDING="1" SIGNATURE="$(SIGNATURE)" PATH="$(TARGET_PATH)" $(SCRIPT_DIR)/gen_image_generic.sh \ + $(BIN_DIR)/$(IMG_COMBINED)-$(1)-efi.img \ + $(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.grub \ + $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1) \ @@ -908,7 +1002,7 @@ index 84a3d88a7f2..aacb1b4830d 100644 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz grub-mkimage \ -p /boot/grub \ -@@ -111,6 +174,17 @@ define Image/Build/iso +@@ -107,6 +170,17 @@ define Image/Build/iso $(STAGING_DIR_HOST)/lib/grub/i386-pc/cdboot.img \ $(KDIR)/grub2/eltorito.img \ > $(KDIR)/root.grub/boot/grub/eltorito.img @@ -926,7 +1020,7 @@ index 84a3d88a7f2..aacb1b4830d 100644 sed \ -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \ -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \ -@@ -120,11 +194,12 @@ define Image/Build/iso +@@ -116,11 +190,12 @@ define Image/Build/iso ./grub-iso.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg -$(CP) $(STAGING_DIR_ROOT)/boot/. $(KDIR)/root.grub/boot/ mkisofs -R -b boot/grub/eltorito.img -no-emul-boot -boot-info-table \ @@ -940,7 +1034,7 @@ index 84a3d88a7f2..aacb1b4830d 100644 rm $(BIN_DIR)/$(IMG_COMBINED)-$(1).vdi || true qemu-img convert -f raw -O vdi \ $(BIN_DIR)/$(IMG_COMBINED)-$(1).img \ -@@ -133,7 +208,7 @@ ifneq ($(CONFIG_VDI_IMAGES),) +@@ -129,7 +204,7 @@ ifneq ($(CONFIG_VDI_IMAGES),) endif ifneq ($(CONFIG_VMDK_IMAGES),) @@ -949,7 +1043,7 @@ index 84a3d88a7f2..aacb1b4830d 100644 rm $(BIN_DIR)/$(IMG_COMBINED)-$(1).vmdk || true qemu-img convert -f raw -O vmdk \ $(BIN_DIR)/$(IMG_COMBINED)-$(1).img \ -@@ -141,8 +216,27 @@ ifneq ($(CONFIG_VMDK_IMAGES),) +@@ -137,8 +212,27 @@ ifneq ($(CONFIG_VMDK_IMAGES),) endef endif @@ -978,7 +1072,7 @@ index 84a3d88a7f2..aacb1b4830d 100644 gzip -f9n $(BIN_DIR)/$(IMG_ROOTFS)-$(1).img endef -@@ -173,6 +267,9 @@ define Image/Build +@@ -162,6 +256,9 @@ define Image/Build $(call Image/Build/grub2,$(1)) $(call Image/Build/vdi,$(1)) $(call Image/Build/vmdk,$(1)) @@ -989,7 +1083,7 @@ index 84a3d88a7f2..aacb1b4830d 100644 else $(CP) $(KDIR)/root.iso $(BIN_DIR)/$(IMG_PREFIX).iso diff --git a/target/linux/x86/image/grub-iso.cfg b/target/linux/x86/image/grub-iso.cfg -index 9c59bdf6d49..4530258fbd6 100644 +index 9c59bdf6d49..92516b61e5e 100644 --- a/target/linux/x86/image/grub-iso.cfg +++ b/target/linux/x86/image/grub-iso.cfg @@ -3,7 +3,12 @@ @@ -998,7 +1092,7 @@ index 9c59bdf6d49..4530258fbd6 100644 set timeout="@TIMEOUT@" -set root='(cd)' + -+if [ x${grub_platform} = xefi ]; then ++if [ "${grub_platform}" = "efi" ]; then + set root='(cd0)' +else + set root='(cd)'