On Thursday, February 7, 2019 8:47:15 PM CET Linus Walleij wrote: > This factory binary i supposed to actually be unzipped and > untarred by the user as part of the installation process > (this NAS boots from harddisk), so name it "bootpart.tar.gz" > and not "factory.bin" so it is helpful for users. > > Signed-off-by: Linus Walleij <[email protected]> > ---
The name "factory" images comes from the various router images <https://openwrt.org/docs/guide-quick-start/factory_installation> <https://openwrt.org/faq/before_installation#what_is_the_difference_between_the_different_image_formats> | a factory image is designed to replace the vendor's “stock” firmware. | It matches the format of the file the vendor supplies. | You usually use the vendor's Web GUI to install a factory image. | | [...] a factory image would have extra header information or whatever | the platform needs. Generally speaking, the factory image is to be | used with the OEM GUI or OEM flashing utilities to convert the device | to OpenWrt. From what I know (in the context of NAS and such), these images are used for the first installation or refresh the device to OpenWrt's factory defaults. That said, I did find your article: "Recent Linux on the D-Link DNS-313" <https://dflund.se/~triad/krad/dlink-dns-313/> which listed the installation process. And wondered if it isn't possible to make a "factory" image with the existing firmware tools (ptgen, genext2fs) that aligns with the other NAS device. Please look at the attached patches. I think they should mostly do what you are after. Or, in other words: They cut down the installation process/script to just: 1. download either the ext4 or squashfs factory.bin.gz to your PC 2. extract the factory.bin.gz on your PC 3. write the extracted image to the attached NAS' HDD with dd. Since the kernel and rootfs are now integrated into one image. This will also solve the problem you mentioned: "There are daily snapshots from OpenWRT available, but these does not currently include a .tar.gz version of the root filesystem which is necessary for the DNS-313." and as a bonus the squashfs image should work as it is supposed to. But of course, this needs some testing + fixing. Cheers, Christian --- From 0afe6df0ef4a81e19b73dc2e6a297701bbf155a8 Mon Sep 17 00:00:00 2001 From: Christian Lamparter <[email protected]> Date: Sun, 10 Feb 2019 14:36:26 +0100 Subject: [PATCH] firmware-tools: ptgen: allow specifying empty partitions This patch make it possible through a new "-n" flag to specify partitions with a zero size. These partition entries will be left zeroed out which allows the user to specify them at a later time. This should help NAS devices like the DNS-313 that have the boot and root partition in PTE 2 and 3. Signed-off-by: Christian Lamparter <[email protected]> --- tools/firmware-utils/src/ptgen.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index 13e0eda622..0192bb65e5 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <stdio.h> #include <stdint.h> +#include <stdbool.h> #include <ctype.h> #include <fcntl.h> #include <stdint.h> @@ -59,6 +60,7 @@ int active = 1; int heads = -1; int sectors = -1; int kb_align = 0; +bool ignore_null_sized_partition = false; struct partinfo parts[4]; char *filename = NULL; @@ -140,6 +142,8 @@ static int gen_ptable(uint32_t signature, int nr) memset(pte, 0, sizeof(struct pte) * 4); 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; } @@ -196,7 +200,7 @@ fail: static void usage(char *prog) { - fprintf(stderr, "Usage: %s [-v] -h <heads> -s <sectors> -o <outputfile> [-a 0..4] [-l <align kB>] [[-t <type>] -p <size>...] \n", prog); + fprintf(stderr, "Usage: %s [-v] [-n] -h <heads> -s <sectors> -o <outputfile> [-a 0..4] [-l <align kB>] [[-t <type>] -p <size>...] \n", prog); exit(EXIT_FAILURE); } @@ -207,7 +211,7 @@ int main (int argc, char **argv) int part = 0; uint32_t signature = 0x5452574F; /* 'OWRT' */ - while ((ch = getopt(argc, argv, "h:s:p:a:t:o:vl:S:")) != -1) { + while ((ch = getopt(argc, argv, "h:s:p:a:t:o:vnl:S:")) != -1) { switch (ch) { case 'o': filename = optarg; @@ -215,6 +219,9 @@ int main (int argc, char **argv) case 'v': verbose++; break; + case 'n': + ignore_null_sized_partition = true; + break; case 'h': heads = (int)strtoul(optarg, NULL, 0); break; --- From 169dd527e49a10285ec507bc05cf42b46ff29641 Mon Sep 17 00:00:00 2001 From: Christian Lamparter <[email protected]> Date: Sun, 10 Feb 2019 14:57:31 +0100 Subject: [PATCH] gemini: generate hdd image for DNS313 --- target/linux/gemini/Makefile | 2 +- target/linux/gemini/config-4.14 | 6 +++++ target/linux/gemini/config-4.19 | 6 +++++ target/linux/gemini/image/Makefile | 18 ++++++++----- .../linux/gemini/image/dns313_gen_hdd_img.sh | 27 +++++++++++++++++++ 5 files changed, 52 insertions(+), 7 deletions(-) create mode 100755 target/linux/gemini/image/dns313_gen_hdd_img.sh diff --git a/target/linux/gemini/Makefile b/target/linux/gemini/Makefile index 3204b3f5d8..14b79829db 100644 --- a/target/linux/gemini/Makefile +++ b/target/linux/gemini/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk ARCH:=arm BOARD:=gemini BOARDNAME:=Cortina Systems CS351x -FEATURES:=squashfs pci rtc usb dt gpio display +FEATURES:=squashfs pci rtc usb dt gpio display ext4 root-part boot-part CPU_TYPE:=fa526 MAINTAINER:=Roman Yeryomin <[email protected]> diff --git a/target/linux/gemini/config-4.14 b/target/linux/gemini/config-4.14 index 326b05c089..53c8ec7ba7 100644 --- a/target/linux/gemini/config-4.14 +++ b/target/linux/gemini/config-4.14 @@ -45,6 +45,7 @@ CONFIG_ATAGS=y CONFIG_ATA_VERBOSE_ERROR=y CONFIG_AUTO_ZRELADDR=y CONFIG_BINFMT_MISC=y +CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_SD=y CONFIG_BLK_MQ_PCI=y CONFIG_BLK_SCSI_REQUEST=y @@ -148,6 +149,11 @@ CONFIG_ELF_CORE=y # CONFIG_ENABLE_WARN_DEPRECATED is not set # CONFIG_EXPERT is not set CONFIG_EXT4_FS=y +# CONFIG_F2FS_CHECK_FS is not set +CONFIG_F2FS_FS=y +# CONFIG_F2FS_FS_SECURITY is not set +CONFIG_F2FS_FS_XATTR=y +CONFIG_F2FS_STAT_FS=y CONFIG_FARADAY_FTINTC010=y CONFIG_FHANDLE=y CONFIG_FIRMWARE_IN_KERNEL=y diff --git a/target/linux/gemini/config-4.19 b/target/linux/gemini/config-4.19 index 7025ec149c..e2bd4f6351 100644 --- a/target/linux/gemini/config-4.19 +++ b/target/linux/gemini/config-4.19 @@ -45,6 +45,7 @@ CONFIG_ATAGS=y CONFIG_ATA_VERBOSE_ERROR=y CONFIG_AUTO_ZRELADDR=y CONFIG_BINFMT_MISC=y +CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_SD=y CONFIG_BLK_MQ_PCI=y CONFIG_BLK_SCSI_REQUEST=y @@ -173,6 +174,11 @@ CONFIG_ELF_CORE=y # CONFIG_EMBEDDED is not set # CONFIG_EXPERT is not set CONFIG_EXT4_FS=y +# CONFIG_F2FS_CHECK_FS is not set +CONFIG_F2FS_FS=y +# CONFIG_F2FS_FS_SECURITY is not set +CONFIG_F2FS_FS_XATTR=y +CONFIG_F2FS_STAT_FS=y CONFIG_FARADAY_FTINTC010=y CONFIG_FB=y CONFIG_FB_CFB_COPYAREA=y diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index d0180e297a..d0f2703621 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -38,9 +38,12 @@ define Build/dns313-images dns313-header $(IMAGE_KERNEL) \ [email protected]/.boot/zImage - tar --sort=name --owner=0 --group=0 --numeric-owner -czf $@ \ - -C [email protected] .boot \ - $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") + genext2fs --block-size $(BLOCKSIZE:%k=%Ki) \ + --size-in-blocks $$((1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE))) \ + --root [email protected]/.boot [email protected]/boot + + ./dns313_gen_hdd_img.sh $@ [email protected]/boot $(IMAGE_ROOTFS) \ + $(CONFIG_TARGET_KERNEL_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE) rm -rf [email protected] endef @@ -106,7 +109,8 @@ GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \ kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \ kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \ kmod-nls-utf8 kmod-usb-storage-extras \ - samba36-server mdadm cfdisk fdisk e2fsprogs badblocks + samba36-server mdadm cfdisk fdisk e2fsprogs badblocks \ + mkf2fs f2fsck partx-utils define Device/dlink_dir-685 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router @@ -123,8 +127,10 @@ define Device/dlink_dns-313 DEVICE_TITLE := D-Link DNS-313 1-Bay Network Storage Enclosure DEVICE_DTS := gemini-dlink-dns-313 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) - IMAGES := factory.bin - IMAGE/factory.bin := dns313-images + BLOCKSIZE := 1k + FILESYSTEMS := ext4 squashfs + IMAGES := factory.bin.gz + IMAGE/factory.bin.gz := dns313-images | gzip endef TARGET_DEVICES += dlink_dns-313 diff --git a/target/linux/gemini/image/dns313_gen_hdd_img.sh b/target/linux/gemini/image/dns313_gen_hdd_img.sh new file mode 100755 index 0000000000..d24d928716 --- /dev/null +++ b/target/linux/gemini/image/dns313_gen_hdd_img.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -x +[ $# -eq 5 ] || { + echo "SYNTAX: $0 <file> <bootfs image> <rootfs image> <bootfs size> <rootfs size>" + exit 1 +} + +OUTPUT="$1" +BOOTFS="$2" +ROOTFS="$3" +BOOTFSSIZE="$4" +ROOTFSSIZE="$5" + +head=4 +sect=63 + +set `ptgen -o $OUTPUT -h $head -s $sect -l 1024 -t 83 -n -p 0 -p 0 -p ${BOOTFSSIZE}M -p ${ROOTFSSIZE}M` + +BOOTOFFSET="$(($1 / 512))" +BOOTSIZE="$(($2 / 512))" +ROOTFSOFFSET="$(($3 / 512))" +ROOTFSSIZE="$(($4 / 512))" + +dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc +dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc + -- 2.20.1 _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
