ar71xx: Unifi AP Pro sysupgrade patch
authorFelix Fietkau <nbd@openwrt.org>
Thu, 14 Nov 2013 19:38:54 +0000 (19:38 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 14 Nov 2013 19:38:54 +0000 (19:38 +0000)
The current implementation of mtd will not append the backup
file created by sysupgrade to the correct partition, as mtd will append
the data to first jffs2 partition it finds. As the kernel is also
stored on a jffs2 partition (which resides before the overlay
partition), the data will be appended to this partition.

To fix this problem, a new option

-s <number>             skip the first n bytes when appending data to the jffs2 partiton, defaults to "0"

is added to mtd.

Signed-off-by: Peter Wagner <tripolar@gmx.at>
SVN-Revision: 38807

package/base-files/files/lib/upgrade/common.sh
package/base-files/files/sbin/sysupgrade
package/system/mtd/src/mtd.c
target/linux/ar71xx/base-files/lib/upgrade/platform.sh

index 91162069650030e1467c4b54573afd932d17e00a..6122ae7712085015c8cdac3666c259ea187c4918 100644 (file)
@@ -188,7 +188,7 @@ jffs2_copy_config() {
 default_do_upgrade() {
        sync
        if [ "$SAVE_CONFIG" -eq 1 ]; then
-               get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}"
+               get_image "$1" | mtd $MTD_CONFIG_ARGS -j "$CONF_TAR" write - "${PART_NAME:-image}"
        else
                get_image "$1" | mtd write - "${PART_NAME:-image}"
        fi
index eb5ab035c6885ab93ca0fa491014d8b00afeaa6e..14b09eb0b56ed4e62a4181830bead1aac0263416 100755 (executable)
@@ -4,6 +4,7 @@
 # initialize defaults
 RAMFS_COPY_BIN=""      # extra programs for temporary ramfs root
 RAMFS_COPY_DATA=""     # extra data files
+export MTD_CONFIG_ARGS=""
 export INTERACTIVE=0
 export VERBOSE=1
 export SAVE_CONFIG=1
index a6604862835f4124d9e4be31f4f7fab70cb30d15..2ec02a871b1be84b65d9893ad9d94896a36b7461 100644 (file)
@@ -55,6 +55,7 @@ int quiet;
 int no_erase;
 int mtdsize = 0;
 int erasesize = 0;
+int jffs2_skip_bytes=0;
 
 int mtd_open(const char *mtd, bool block)
 {
@@ -339,7 +340,6 @@ resume:
                fprintf(stderr, "Could not open mtd device: %s\n", mtd);
                exit(1);
        }
-
        if (part_offset > 0) {
                fprintf(stderr, "Seeking on mtd device '%s' to: %u\n", mtd, part_offset);
                lseek(fd, part_offset, SEEK_SET);
@@ -379,7 +379,7 @@ resume:
                        continue;
                }
 
-               if (jffs2file) {
+               if (jffs2file && w >= jffs2_skip_bytes) {
                        if (memcmp(buf, JFFS2_EOF, sizeof(JFFS2_EOF) - 1) == 0) {
                                if (!quiet)
                                        fprintf(stderr, "\b\b\b   ");
@@ -503,6 +503,7 @@ static void usage(void)
        "        -e <device>             erase <device> before executing the command\n"
        "        -d <name>               directory for jffs2write, defaults to \"tmp\"\n"
        "        -j <name>               integrate <file> into jffs2 data when writing an image\n"
+       "        -s <number>             skip the first n bytes when appending data to the jffs2 partiton, defaults to \"0\"\n"
        "        -p                      write beginning at partition offset\n");
        if (mtd_fixtrx) {
            fprintf(stderr,
@@ -560,7 +561,7 @@ int main (int argc, char **argv)
 #ifdef FIS_SUPPORT
                        "F:"
 #endif
-                       "frnqe:d:j:p:o:")) != -1)
+                       "frnqe:d:s:j:p:o:")) != -1)
                switch (ch) {
                        case 'f':
                                force = 1;
@@ -574,6 +575,14 @@ int main (int argc, char **argv)
                        case 'j':
                                jffs2file = optarg;
                                break;
+                       case 's':
+                               errno = 0;
+                               jffs2_skip_bytes = strtoul(optarg, 0, 0);
+                               if (errno) {
+                                               fprintf(stderr, "-s: illegal numeric string\n");
+                                               usage();
+                               }
+                               break;
                        case 'q':
                                quiet++;
                                break;
index 266bf3fd5c4bc679e7f88b75318249817bc06af1..1eb9354057548529b91f1db04b5bbb9d66b8c46a 100755 (executable)
@@ -327,6 +327,10 @@ platform_do_upgrade() {
        om2p-lc)
                platform_do_upgrade_openmesh "$ARGV"
                ;;
+       uap-pro)
+               MTD_CONFIG_ARGS="-s 0x180000"
+               default_do_upgrade "$ARGV"
+               ;;
        *)
                default_do_upgrade "$ARGV"
                ;;