Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[orion] update wrt350nv2-builder to v2.4 and use new functionality fo…

…r target orion_generic

Signed-off-by: Matthias Bücher <mail@maddes.net>

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31199 3c298f89-4303-0410-b956-a3cf2f4a3e73
  • Loading branch information...
commit c0ade48327ba560509bce52b7e22b2225dd50475 1 parent 8675646
florian authored
23 target/linux/orion/image/generic.mk
... ... @@ -1,15 +1,24 @@
1 1 #
2   -# Copyright (C) 2008-2010 OpenWrt.org
  2 +# Copyright (C) 2008-2011 OpenWrt.org
3 3 #
4 4 # This is free software, licensed under the GNU General Public License v2.
5 5 # See /LICENSE for more information.
6 6 #
7 7
  8 +### DO NOT INDENT LINES CONTAINING $(call xyz) AS THIS MAY CHANGE THE CONTEXT
  9 +### OF THE FIRST LINE IN THE CALLED VARIABLE (NOTE: variable!)
  10 +### see http://www.gnu.org/software/make/manual/html_node/Call-Function.html#Call-Function
  11 +### ACTUALLY IT IS A SIMPLE MACRO EXPANSION
  12 +
  13 +### use round brackets for make variables, and curly brackets for shell variables
  14 +
8 15 define Image/Prepare
  16 +### Dummy comment for indented calls of Image/Prepare
9 17 cp $(LINUX_DIR)/arch/arm/boot/uImage $(KDIR)/uImage
10 18 endef
11 19
12 20 define Image/BuildKernel
  21 +### Dummy comment for indented calls of Image/BuildKernel
13 22 # Orion Kernel uImages
14 23 # WRT350N v2: mach id 1633 (0x661)
15 24 echo -en "\x06\x1c\xa0\xe3\x61\x10\x81\xe3" > $(KDIR)/wrt350nv2-zImage
@@ -51,25 +60,27 @@ define Image/Build/Linksys
51 60 rm -rf "${TMP_DIR}/$2_webupgrade"
52 61 mkdir "${TMP_DIR}/$2_webupgrade"
53 62 # create parameter file
54   - echo ":kernel $5 ${BIN_DIR}/openwrt-$2-uImage" >"${TMP_DIR}/$2_webupgrade/$2.par"
55   - echo ":rootfs 0 ${KDIR}/root.$1" >>"${TMP_DIR}/$2_webupgrade/$2.par"
  63 + echo ':image 0 $(BIN_DIR)/openwrt-$(2)-$(1).img' >'$(TMP_DIR)/$(2)_webupgrade/$(2).par'
56 64 [ ! -f "$(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin" ] || ( \
57 65 echo ":u-boot 0 $(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin" >>"${TMP_DIR}/$2_webupgrade/$2.par"; )
58 66 echo "#version 0x2020" >>"${TMP_DIR}/$2_webupgrade/$2.par"
59 67 # create bin file for recovery and webupgrade image
60 68 ( cd "${TMP_DIR}/$2_webupgrade"; \
61   - "${STAGING_DIR_HOST}/bin/$2-builder" \
  69 + "${STAGING_DIR_HOST}/bin/wrt350nv2-builder" \
62 70 -v -b "${TMP_DIR}/$2_webupgrade/$2.par"; \
63 71 )
64 72 # copy bin file as recovery image
65 73 $(CP) "${TMP_DIR}/$2_webupgrade/wrt350n.bin" "$(BIN_DIR)/openwrt-$2-$1-recovery.bin"
66 74 # create webupgrade image for stock firmware update mechanism
67   - zip "${TMP_DIR}/$2_webupgrade/wrt350n.zip" "${TMP_DIR}/$2_webupgrade/wrt350n.bin"
68   - "${STAGING_DIR_HOST}/bin/$2-builder" -v -z "${TMP_DIR}/$2_webupgrade/wrt350n.zip" "${BIN_DIR}/openwrt-$2-$1-webupgrade.img"
  75 + ( cd '$(TMP_DIR)/$(2)_webupgrade'; \
  76 + zip 'wrt350n.zip' 'wrt350n.bin'; \
  77 + )
  78 + "${STAGING_DIR_HOST}/bin/wrt350nv2-builder" -v -z "${TMP_DIR}/$2_webupgrade/wrt350n.zip" "${BIN_DIR}/openwrt-$2-$1-webupgrade.img"
69 79 rm -rf "${TMP_DIR}/$2_webupgrade"
70 80 endef
71 81
72 82 define Image/Build
  83 +### Dummy comment for indented calls of Image/Build with $(1)
73 84 $(call Image/Build/$(1),$(1))
74 85 $(call Image/Build/Netgear,$(1),wnr854t,NG_WNR854T,$(1))
75 86 # Leave WRT350Nv2 at last position due to webimage dependency for zip
4 tools/wrt350nv2-builder/Makefile
... ... @@ -1,5 +1,5 @@
1 1 #
2   -# Copyright (C) 2006-2010 OpenWrt.org
  2 +# Copyright (C) 2006-2011 OpenWrt.org
3 3 #
4 4 # This is free software, licensed under the GNU General Public License v2.
5 5 # See /LICENSE for more information.
@@ -8,7 +8,7 @@
8 8 include $(TOPDIR)/rules.mk
9 9
10 10 PKG_NAME:=wrt350nv2-builder
11   -PKG_VERSION:=2.3
  11 +PKG_VERSION:=2.4
12 12
13 13 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/${PKG_NAME}-$(PKG_VERSION)
14 14
76 tools/wrt350nv2-builder/src/wrt350nv2-builder.c
... ... @@ -1,8 +1,8 @@
1 1 /*
2 2
3   - WRT350Nv2-Builder 2.3 (previously called buildimg)
  3 + WRT350Nv2-Builder 2.4 (previously called buildimg)
4 4 Copyright (C) 2008-2009 Dirk Teurlings <info@upexia.nl>
5   - Copyright (C) 2009-2010 Matthias Buecher (http://www.maddes.net/)
  5 + Copyright (C) 2009-2011 Matthias Buecher (http://www.maddes.net/)
6 6
7 7 This program is free software; you can redistribute it and/or modify
8 8 it under the terms of the GNU General Public License as published by
@@ -33,6 +33,9 @@
33 33 :u-boot 0 /path/to/u-boot.bin
34 34 #version 0x2020
35 35
  36 + Additionally since v2.4 an already complete image can be used:
  37 + :image 0 /path/to/openwrt-wrt350nv2-[squashfs|jffs2-64k].img
  38 +
36 39 args:
37 40 1 wrt350nv2.par parameter file describing the image layout
38 41 2 wrt350nv2.img output file for linksys style image
@@ -62,6 +65,8 @@
62 65 https://forum.openwrt.org/viewtopic.php?pid=92928#p92928
63 66
64 67 Changelog:
  68 + v2.4 - added ":image" definition for parameter file, this allows
  69 + to use a complete sysupgrade image without any kernel size check
65 70 v2.3 - allow jffs by adding its magic number (0x8519)
66 71 added parameter option -i to ignore unknown magic numbers
67 72 v2.2 - fixed checksum byte calculation for other versions than 0x2019
@@ -92,7 +97,7 @@
92 97
93 98
94 99 // version info
95   -#define VERSION "2.3"
  100 +#define VERSION "2.4"
96 101 char program_info[] = "WRT350Nv2-Builder v%s by Dirk Teurlings <info@upexia.nl> and Matthias Buecher (http://www.maddes.net/)\n";
97 102
98 103 // verbosity
@@ -112,6 +117,7 @@ typedef struct {
112 117
113 118 mtd_info mtd_kernel = { "kernel", 0, 0, NULL, 0L, { 0, 0 } };
114 119 mtd_info mtd_rootfs = { "rootfs", 0, 0, NULL, 0L, { 0, 0 } };
  120 +mtd_info mtd_image = { "image", 0, 0, NULL, 0L, { 0, 0 } };
115 121 mtd_info mtd_uboot = { "u-boot", 0, 0, NULL, 0L, { 0, 0 } };
116 122
117 123 #define ROOTFS_END_OFFSET 0x00760000
@@ -281,6 +287,8 @@ int parse_par_file(FILE *f_par) {
281 287 mtd = &mtd_rootfs;
282 288 } else if (!strcmp(string1, mtd_uboot.name)) {
283 289 mtd = &mtd_uboot;
  290 + } else if (!strcmp(string1, mtd_image.name)) {
  291 + mtd = &mtd_image;
284 292 }
285 293
286 294 if (!mtd) {
@@ -404,20 +412,24 @@ int create_bin_file(char *bin_filename) {
404 412
405 413 // add files
406 414 if (!exitcode) {
407   - for (i = 1; i <= 3; i++) {
  415 + for (i = 1; i <= 4; i++) {
408 416 addsize = 0;
409 417 padsize = 0;
410 418
411 419 switch (i) {
412 420 case 1:
413   - mtd = &mtd_kernel;
  421 + mtd = &mtd_image;
  422 + padsize = ROOTFS_MIN_OFFSET - mtd->filesize;
414 423 break;
415 424 case 2:
  425 + mtd = &mtd_kernel;
  426 + break;
  427 + case 3:
416 428 mtd = &mtd_rootfs;
417 429 addsize = mtd->filesize;
418 430 padsize = ROOTFS_MIN_OFFSET - mtd_kernel.size - mtd->filesize;
419 431 break;
420   - case 3:
  432 + case 4:
421 433 mtd = &mtd_uboot;
422 434 addsize = mtd->filesize;
423 435 break;
@@ -723,7 +735,6 @@ int main(int argc, char *argv[]) {
723 735
724 736 int i;
725 737 mtd_info *mtd;
726   - int mandatory;
727 738 int noupdate;
728 739 int sizecheck;
729 740 int magiccheck;
@@ -934,28 +945,30 @@ int main(int argc, char *argv[]) {
934 945 if ((!exitcode) && (par_filename)) {
935 946 lprintf(DEBUG, "checking mtd data...\n");
936 947
937   - for (i = 1; i <= 3; i++) {
938   - mandatory = 0;
  948 + for (i = 1; i <= 4; i++) {
939 949 noupdate = 0;
940 950 sizecheck = 0;
941 951 magiccheck = 0;
942 952
943 953 switch (i) {
944 954 case 1:
  955 + mtd = &mtd_image;
  956 + sizecheck = ROOTFS_END_OFFSET;
  957 + magiccheck = 1;
  958 + break;
  959 + case 2:
945 960 mtd = &mtd_kernel;
946   - mandatory = 1;
947 961 sizecheck = mtd_kernel.size - 16;
948 962 magiccheck = 1;
949 963 break;
950   - case 2:
  964 + case 3:
951 965 mtd = &mtd_rootfs;
952 966 mtd->offset = mtd_kernel.size;
953 967 mtd->size = ROOTFS_END_OFFSET - mtd_kernel.size;
954   - mandatory = 1;
955 968 sizecheck = PRODUCT_ID_OFFSET - mtd_kernel.size;
956 969 magiccheck = 1;
957 970 break;
958   - case 3:
  971 + case 4:
959 972 mtd = &mtd_uboot;
960 973 mtd->offset = BOOT_ADDR_BASE_OFF;
961 974 noupdate = 1;
@@ -974,10 +987,6 @@ int main(int argc, char *argv[]) {
974 987 lprintf(DEBUG_LVL2, " checking mtd %s\n", mtd->name);
975 988
976 989 // general checks
977   - if ((mandatory) && (!mtd->filename)) {
978   - exitcode = 1;
979   - printf("mtd %s not specified correctly or at all in parameter file\n", mtd->name);
980   - }
981 990
982 991 // no further checks if no file data present
983 992 if (!mtd->filename) {
@@ -993,14 +1002,15 @@ int main(int argc, char *argv[]) {
993 1002 magicerror = 0;
994 1003 if (magiccheck) {
995 1004 switch (i) {
996   - case 1: // kernel
  1005 + case 1: // image
  1006 + case 2: // kernel
997 1007 if (!(
998 1008 ((mtd->magic[0] == 0x27) && (mtd->magic[1] == 0x05)) // uImage
999 1009 )) {
1000 1010 magicerror = 1;
1001 1011 }
1002 1012 break;
1003   - case 2: // rootfs
  1013 + case 3: // rootfs
1004 1014 if (!(
1005 1015 ((mtd->magic[0] == 0x68) && (mtd->magic[1] == 0x73)) // squashfs
1006 1016 || ((mtd->magic[0] == 0x85) && (mtd->magic[1] == 0x19)) // jffs
@@ -1024,8 +1034,15 @@ int main(int argc, char *argv[]) {
1024 1034 }
1025 1035
1026 1036 // mtd specific size check
  1037 + if (mtd == &mtd_image) {
  1038 + if (mtd->filesize < 0x00200000) {
  1039 + exitcode = 1;
  1040 + printf("mtd %s input file %s too unrealistic small (0x%08lX)\n", mtd->name, mtd->filename, mtd->filesize);
  1041 + }
  1042 + }
  1043 +
1027 1044 if (mtd == &mtd_kernel) {
1028   - if (mtd->filesize < 0x00050000) {
  1045 + if (mtd->filesize < 0x00080000) {
1029 1046 exitcode = 1;
1030 1047 printf("mtd %s input file %s too unrealistic small (0x%08lX)\n", mtd->name, mtd->filename, mtd->filesize);
1031 1048 }
@@ -1044,6 +1061,25 @@ int main(int argc, char *argv[]) {
1044 1061 }
1045 1062 }
1046 1063 }
  1064 +
  1065 + // Check for mandatory parts
  1066 + if ((!mtd_image.filename) && (!mtd_kernel.filename || !mtd_rootfs.filename)) {
  1067 + exitcode = 1;
  1068 + if (mtd_kernel.filename && !mtd_rootfs.filename) {
  1069 + printf("Kernel without rootfs, either incorrectly specified or not at all in parameter file\n");
  1070 + } else if (!mtd_kernel.filename && mtd_rootfs.filename) {
  1071 + printf("Rootfs without kernel, either incorrectly specified or not at all in parameter file\n");
  1072 + } else {
  1073 + printf("Neither an image nor kernel with rootfs was/were correctly specified or at all in parameter file\n");
  1074 + }
  1075 + }
  1076 +
  1077 + // Check for duplicate parts
  1078 + if ((mtd_image.filename) && (mtd_kernel.filename || mtd_rootfs.filename)) {
  1079 + exitcode = 1;
  1080 + printf("Image and kernel/rootfs specified in parameter file\n");
  1081 + }
  1082 +
1047 1083 lprintf(DEBUG, "...done checking mtd data\n");
1048 1084 }
1049 1085

0 comments on commit c0ade48

Please sign in to comment.
Something went wrong with that request. Please try again.