From: Florian Fainelli Date: Wed, 4 Apr 2012 16:06:25 +0000 (+0000) Subject: update wrt350nv2-builder to v2.4 and use new functionality for target orion_generic X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=930a8201726a3f1318fbf14ff3ccfb274ebf324d;p=openwrt%2Fstaging%2Fnbd.git update wrt350nv2-builder to v2.4 and use new functionality for target orion_generic Signed-off-by: Matthias Bücher SVN-Revision: 31199 --- diff --git a/target/linux/orion/image/generic.mk b/target/linux/orion/image/generic.mk index c3bd6015fa..f58165f613 100644 --- a/target/linux/orion/image/generic.mk +++ b/target/linux/orion/image/generic.mk @@ -1,15 +1,24 @@ # -# Copyright (C) 2008-2010 OpenWrt.org +# Copyright (C) 2008-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. # +### DO NOT INDENT LINES CONTAINING $(call xyz) AS THIS MAY CHANGE THE CONTEXT +### OF THE FIRST LINE IN THE CALLED VARIABLE (NOTE: variable!) +### see http://www.gnu.org/software/make/manual/html_node/Call-Function.html#Call-Function +### ACTUALLY IT IS A SIMPLE MACRO EXPANSION + +### use round brackets for make variables, and curly brackets for shell variables + define Image/Prepare +### Dummy comment for indented calls of Image/Prepare cp $(LINUX_DIR)/arch/arm/boot/uImage $(KDIR)/uImage endef define Image/BuildKernel +### Dummy comment for indented calls of Image/BuildKernel # Orion Kernel uImages # WRT350N v2: mach id 1633 (0x661) echo -en "\x06\x1c\xa0\xe3\x61\x10\x81\xe3" > $(KDIR)/wrt350nv2-zImage @@ -51,25 +60,27 @@ define Image/Build/Linksys rm -rf "${TMP_DIR}/$2_webupgrade" mkdir "${TMP_DIR}/$2_webupgrade" # create parameter file - echo ":kernel $5 ${BIN_DIR}/openwrt-$2-uImage" >"${TMP_DIR}/$2_webupgrade/$2.par" - echo ":rootfs 0 ${KDIR}/root.$1" >>"${TMP_DIR}/$2_webupgrade/$2.par" + echo ':image 0 $(BIN_DIR)/openwrt-$(2)-$(1).img' >'$(TMP_DIR)/$(2)_webupgrade/$(2).par' [ ! -f "$(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin" ] || ( \ echo ":u-boot 0 $(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin" >>"${TMP_DIR}/$2_webupgrade/$2.par"; ) echo "#version 0x2020" >>"${TMP_DIR}/$2_webupgrade/$2.par" # create bin file for recovery and webupgrade image ( cd "${TMP_DIR}/$2_webupgrade"; \ - "${STAGING_DIR_HOST}/bin/$2-builder" \ + "${STAGING_DIR_HOST}/bin/wrt350nv2-builder" \ -v -b "${TMP_DIR}/$2_webupgrade/$2.par"; \ ) # copy bin file as recovery image $(CP) "${TMP_DIR}/$2_webupgrade/wrt350n.bin" "$(BIN_DIR)/openwrt-$2-$1-recovery.bin" # create webupgrade image for stock firmware update mechanism - zip "${TMP_DIR}/$2_webupgrade/wrt350n.zip" "${TMP_DIR}/$2_webupgrade/wrt350n.bin" - "${STAGING_DIR_HOST}/bin/$2-builder" -v -z "${TMP_DIR}/$2_webupgrade/wrt350n.zip" "${BIN_DIR}/openwrt-$2-$1-webupgrade.img" + ( cd '$(TMP_DIR)/$(2)_webupgrade'; \ + zip 'wrt350n.zip' 'wrt350n.bin'; \ + ) + "${STAGING_DIR_HOST}/bin/wrt350nv2-builder" -v -z "${TMP_DIR}/$2_webupgrade/wrt350n.zip" "${BIN_DIR}/openwrt-$2-$1-webupgrade.img" rm -rf "${TMP_DIR}/$2_webupgrade" endef define Image/Build +### Dummy comment for indented calls of Image/Build with $(1) $(call Image/Build/$(1),$(1)) $(call Image/Build/Netgear,$(1),wnr854t,NG_WNR854T,$(1)) # Leave WRT350Nv2 at last position due to webimage dependency for zip diff --git a/tools/wrt350nv2-builder/Makefile b/tools/wrt350nv2-builder/Makefile index 689fd32a53..ccb66b6307 100644 --- a/tools/wrt350nv2-builder/Makefile +++ b/tools/wrt350nv2-builder/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2006-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wrt350nv2-builder -PKG_VERSION:=2.3 +PKG_VERSION:=2.4 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/${PKG_NAME}-$(PKG_VERSION) diff --git a/tools/wrt350nv2-builder/src/wrt350nv2-builder.c b/tools/wrt350nv2-builder/src/wrt350nv2-builder.c index 2ce57234c5..3ebb40ed51 100644 --- a/tools/wrt350nv2-builder/src/wrt350nv2-builder.c +++ b/tools/wrt350nv2-builder/src/wrt350nv2-builder.c @@ -1,8 +1,8 @@ /* - WRT350Nv2-Builder 2.3 (previously called buildimg) + WRT350Nv2-Builder 2.4 (previously called buildimg) Copyright (C) 2008-2009 Dirk Teurlings - Copyright (C) 2009-2010 Matthias Buecher (http://www.maddes.net/) + Copyright (C) 2009-2011 Matthias Buecher (http://www.maddes.net/) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,9 @@ :u-boot 0 /path/to/u-boot.bin #version 0x2020 + Additionally since v2.4 an already complete image can be used: + :image 0 /path/to/openwrt-wrt350nv2-[squashfs|jffs2-64k].img + args: 1 wrt350nv2.par parameter file describing the image layout 2 wrt350nv2.img output file for linksys style image @@ -62,6 +65,8 @@ https://forum.openwrt.org/viewtopic.php?pid=92928#p92928 Changelog: + v2.4 - added ":image" definition for parameter file, this allows + to use a complete sysupgrade image without any kernel size check v2.3 - allow jffs by adding its magic number (0x8519) added parameter option -i to ignore unknown magic numbers v2.2 - fixed checksum byte calculation for other versions than 0x2019 @@ -92,7 +97,7 @@ // version info -#define VERSION "2.3" +#define VERSION "2.4" char program_info[] = "WRT350Nv2-Builder v%s by Dirk Teurlings and Matthias Buecher (http://www.maddes.net/)\n"; // verbosity @@ -112,6 +117,7 @@ typedef struct { mtd_info mtd_kernel = { "kernel", 0, 0, NULL, 0L, { 0, 0 } }; mtd_info mtd_rootfs = { "rootfs", 0, 0, NULL, 0L, { 0, 0 } }; +mtd_info mtd_image = { "image", 0, 0, NULL, 0L, { 0, 0 } }; mtd_info mtd_uboot = { "u-boot", 0, 0, NULL, 0L, { 0, 0 } }; #define ROOTFS_END_OFFSET 0x00760000 @@ -281,6 +287,8 @@ int parse_par_file(FILE *f_par) { mtd = &mtd_rootfs; } else if (!strcmp(string1, mtd_uboot.name)) { mtd = &mtd_uboot; + } else if (!strcmp(string1, mtd_image.name)) { + mtd = &mtd_image; } if (!mtd) { @@ -404,20 +412,24 @@ int create_bin_file(char *bin_filename) { // add files if (!exitcode) { - for (i = 1; i <= 3; i++) { + for (i = 1; i <= 4; i++) { addsize = 0; padsize = 0; switch (i) { case 1: - mtd = &mtd_kernel; + mtd = &mtd_image; + padsize = ROOTFS_MIN_OFFSET - mtd->filesize; break; case 2: + mtd = &mtd_kernel; + break; + case 3: mtd = &mtd_rootfs; addsize = mtd->filesize; padsize = ROOTFS_MIN_OFFSET - mtd_kernel.size - mtd->filesize; break; - case 3: + case 4: mtd = &mtd_uboot; addsize = mtd->filesize; break; @@ -723,7 +735,6 @@ int main(int argc, char *argv[]) { int i; mtd_info *mtd; - int mandatory; int noupdate; int sizecheck; int magiccheck; @@ -934,28 +945,30 @@ int main(int argc, char *argv[]) { if ((!exitcode) && (par_filename)) { lprintf(DEBUG, "checking mtd data...\n"); - for (i = 1; i <= 3; i++) { - mandatory = 0; + for (i = 1; i <= 4; i++) { noupdate = 0; sizecheck = 0; magiccheck = 0; switch (i) { case 1: + mtd = &mtd_image; + sizecheck = ROOTFS_END_OFFSET; + magiccheck = 1; + break; + case 2: mtd = &mtd_kernel; - mandatory = 1; sizecheck = mtd_kernel.size - 16; magiccheck = 1; break; - case 2: + case 3: mtd = &mtd_rootfs; mtd->offset = mtd_kernel.size; mtd->size = ROOTFS_END_OFFSET - mtd_kernel.size; - mandatory = 1; sizecheck = PRODUCT_ID_OFFSET - mtd_kernel.size; magiccheck = 1; break; - case 3: + case 4: mtd = &mtd_uboot; mtd->offset = BOOT_ADDR_BASE_OFF; noupdate = 1; @@ -974,10 +987,6 @@ int main(int argc, char *argv[]) { lprintf(DEBUG_LVL2, " checking mtd %s\n", mtd->name); // general checks - if ((mandatory) && (!mtd->filename)) { - exitcode = 1; - printf("mtd %s not specified correctly or at all in parameter file\n", mtd->name); - } // no further checks if no file data present if (!mtd->filename) { @@ -993,14 +1002,15 @@ int main(int argc, char *argv[]) { magicerror = 0; if (magiccheck) { switch (i) { - case 1: // kernel + case 1: // image + case 2: // kernel if (!( ((mtd->magic[0] == 0x27) && (mtd->magic[1] == 0x05)) // uImage )) { magicerror = 1; } break; - case 2: // rootfs + case 3: // rootfs if (!( ((mtd->magic[0] == 0x68) && (mtd->magic[1] == 0x73)) // squashfs || ((mtd->magic[0] == 0x85) && (mtd->magic[1] == 0x19)) // jffs @@ -1024,8 +1034,15 @@ int main(int argc, char *argv[]) { } // mtd specific size check + if (mtd == &mtd_image) { + if (mtd->filesize < 0x00200000) { + exitcode = 1; + printf("mtd %s input file %s too unrealistic small (0x%08lX)\n", mtd->name, mtd->filename, mtd->filesize); + } + } + if (mtd == &mtd_kernel) { - if (mtd->filesize < 0x00050000) { + if (mtd->filesize < 0x00080000) { exitcode = 1; printf("mtd %s input file %s too unrealistic small (0x%08lX)\n", mtd->name, mtd->filename, mtd->filesize); } @@ -1044,6 +1061,25 @@ int main(int argc, char *argv[]) { } } } + + // Check for mandatory parts + if ((!mtd_image.filename) && (!mtd_kernel.filename || !mtd_rootfs.filename)) { + exitcode = 1; + if (mtd_kernel.filename && !mtd_rootfs.filename) { + printf("Kernel without rootfs, either incorrectly specified or not at all in parameter file\n"); + } else if (!mtd_kernel.filename && mtd_rootfs.filename) { + printf("Rootfs without kernel, either incorrectly specified or not at all in parameter file\n"); + } else { + printf("Neither an image nor kernel with rootfs was/were correctly specified or at all in parameter file\n"); + } + } + + // Check for duplicate parts + if ((mtd_image.filename) && (mtd_kernel.filename || mtd_rootfs.filename)) { + exitcode = 1; + printf("Image and kernel/rootfs specified in parameter file\n"); + } + lprintf(DEBUG, "...done checking mtd data\n"); }