From f4aa7c4d642dcc10d3b209f208bb7a54ecf60804 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Wed, 21 Mar 2018 23:39:39 +0100 Subject: [PATCH] New layout of images --- .../board/ova/barebox-env/boot/system1 | 3 + buildroot-external/board/ova/barebox.config | 1 + buildroot-external/board/ova/genimage.cfg | 1 + buildroot-external/configs/ova_defconfig | 1 + ...1-Add-support-for-extended-partition.patch | 95 +++++++++++++++++++ 5 files changed, 101 insertions(+) create mode 100644 buildroot-external/board/ova/barebox-env/boot/system1 create mode 100644 buildroot-external/patches/genimage/0001-Add-support-for-extended-partition.patch diff --git a/buildroot-external/board/ova/barebox-env/boot/system1 b/buildroot-external/board/ova/barebox-env/boot/system1 new file mode 100644 index 000000000..a5389f842 --- /dev/null +++ b/buildroot-external/board/ova/barebox-env/boot/system1 @@ -0,0 +1,3 @@ + +global bootm.image="/dev/disk0.2/boot/bzImage" +global linux.bootargs.base="root=/dev/sda3 rootfstype=squashfs ro" diff --git a/buildroot-external/board/ova/barebox.config b/buildroot-external/board/ova/barebox.config index 1af7fd403..755c03b38 100644 --- a/buildroot-external/board/ova/barebox.config +++ b/buildroot-external/board/ova/barebox.config @@ -7,6 +7,7 @@ CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y CONFIG_STATE=y CONFIG_BOOTCHOOSER=y CONFIG_CMD_UIMAGE=y +CONFIG_CMD_DETECT=y CONFIG_CMD_STATE=y CONFIG_CMD_BOOTCHOOSER=y CONFIG_DRIVER_SERIAL_EFI=y diff --git a/buildroot-external/board/ova/genimage.cfg b/buildroot-external/board/ova/genimage.cfg index a45dac5bf..23b1d4424 100644 --- a/buildroot-external/board/ova/genimage.cfg +++ b/buildroot-external/board/ova/genimage.cfg @@ -12,6 +12,7 @@ image boot.vfat { image sdcard.img { hdimage { align = 1M + extended-partition = 2 } partition boot { diff --git a/buildroot-external/configs/ova_defconfig b/buildroot-external/configs/ova_defconfig index 15a26828a..8ceee447b 100644 --- a/buildroot-external/configs/ova_defconfig +++ b/buildroot-external/configs/ova_defconfig @@ -52,6 +52,7 @@ BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y BR2_TARGET_BAREBOX=y BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG=y BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_HASSIO_PATH)/board/ova/barebox.config" +BR2_TARGET_BAREBOX_CUSTOM_EMBEDDED_ENV_PATH="$(BR2_EXTERNAL_HASSIO_PATH)/board/ova/barebox-env" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y BR2_PACKAGE_HOST_GENIMAGE=y diff --git a/buildroot-external/patches/genimage/0001-Add-support-for-extended-partition.patch b/buildroot-external/patches/genimage/0001-Add-support-for-extended-partition.patch new file mode 100644 index 000000000..7674ca33b --- /dev/null +++ b/buildroot-external/patches/genimage/0001-Add-support-for-extended-partition.patch @@ -0,0 +1,95 @@ +From 22568ea927b8b78c8463ad5beb0105e476d4cf3e Mon Sep 17 00:00:00 2001 +From: Pascal Vizeli +Date: Wed, 21 Mar 2018 23:35:44 +0100 +Subject: [PATCH 1/1] Add support for extended partition + +--- + image-hd.c | 25 +++++++++++++++++++------ + 1 file changed, 19 insertions(+), 6 deletions(-) + +diff --git a/image-hd.c b/image-hd.c +index c53a64a..7d392d3 100644 +--- a/image-hd.c ++++ b/image-hd.c +@@ -26,6 +26,7 @@ + + struct hdimage { + cfg_bool_t partition_table; ++ unsigned int extended_partition; + unsigned long long align; + unsigned long long extended_lba; + uint32_t disksig; +@@ -227,14 +228,22 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + { + struct partition *part; + int has_extended; +- int partition_table_entries = 0; ++ unsigned int partition_table_entries = 0; + unsigned long long now = 0; + struct hdimage *hd = xzalloc(sizeof(*hd)); + + hd->align = cfg_getint_suffix(cfg, "align"); + hd->partition_table = cfg_getbool(cfg, "partition-table"); ++ hd->extended_partition = cfg_getint(cfg, "extended-partition"); + hd->disksig = strtoul(cfg_getstr(cfg, "disk-signature"), NULL, 0); + ++ if (hd->extended_partition > 4) { ++ image_error(image, "invalid extended partition index (%i). must be " ++ "inferior or equal to 4 (0 for automatic)\n", ++ hd->extended_partition); ++ return -EINVAL; ++ } ++ + if ((hd->align % 512) || (hd->align == 0)) { + image_error(image, "partition alignment (%lld) must be a " + "multiple of 1 sector (512 bytes)\n", hd->align); +@@ -244,7 +253,10 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + if (part->in_partition_table) + ++partition_table_entries; + } +- has_extended = partition_table_entries > 4; ++ if (!hd->extended_partition && partition_table_entries > 4) ++ hd->extended_partition = 4; ++ has_extended = hd->extended_partition > 0; ++ + partition_table_entries = 0; + list_for_each_entry(part, &image->partitions, list) { + if (part->image) { +@@ -275,8 +287,8 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + /* reserve space for extended boot record if necessary */ + if (part->in_partition_table) + ++partition_table_entries; +- if (has_extended && (partition_table_entries > 3)) +- part->extended = cfg_true; ++ part->extended = has_extended && ++ (partition_table_entries >= hd->extended_partition); + if (part->extended) { + if (!hd->extended_lba) + hd->extended_lba = now; +@@ -289,13 +301,13 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + part->name, part->offset, hd->align); + return -EINVAL; + } +- if (part->offset || !part->in_partition_table) { ++ if (part->offset && part->in_partition_table) { + if (now > part->offset) { + image_error(image, "part %s overlaps with previous partition\n", + part->name); + return -EINVAL; + } +- } else { ++ } else if (!part->offset && part->in_partition_table) { + if (!now && hd->partition_table) + now = 512; + part->offset = roundup(now, hd->align); +@@ -317,6 +329,7 @@ cfg_opt_t hdimage_opts[] = { + CFG_STR("align", "512", CFGF_NONE), + CFG_STR("disk-signature", "", CFGF_NONE), + CFG_BOOL("partition-table", cfg_true, CFGF_NONE), ++ CFG_INT("extended-partition", 0, CFGF_NONE), + CFG_END() + }; + +-- +2.7.4 +