mx_flasher: set mode after other writes
authornotaz <notasas@gmail.com>
Sun, 1 Sep 2013 16:41:29 +0000 (19:41 +0300)
committernotaz <notasas@gmail.com>
Sun, 1 Sep 2013 16:41:29 +0000 (19:41 +0300)
seems to improve reliability (less random write errors)

mx/linux/mx_flasher.c

index 7bebc9c..1bec278 100644 (file)
@@ -1072,28 +1072,6 @@ breakloop:
                        goto end;
        }
 
-       /* set mode */
-       if (mx_mode || w_fsize > 0x200000) {
-               if (mx_mode == 0)
-                       mx_mode = '3';
-               printf("MX mode set to ");
-               switch (mx_mode) {
-               case '1':
-                       printf("2M with RAM.\n");
-                       mx_mode = C_MODE_2M_RAM;
-                       break;
-               case '2':
-                       printf("4M, no RAM.\n");
-                       mx_mode = C_MODE_4M_NORAM;
-                       break;
-               default:
-                       printf("4M with RAM.\n");
-                       mx_mode = C_MODE_4M_RAM;
-                       break;
-               }
-               set_ram_mode(device, mx_mode);
-       }
-
        /* erase */
        if (do_erase_size != 0) {
                if (erase_method)
@@ -1149,6 +1127,28 @@ breakloop:
                        fprintf(stderr, "warning: failed to save RAM filename\n");
        }
 
+       /* set mode */
+       if (mx_mode || w_fsize > 0x200000) {
+               if (mx_mode == 0)
+                       mx_mode = '3';
+               printf("MX mode set to ");
+               switch (mx_mode) {
+               case '1':
+                       printf("2M with RAM.\n");
+                       mx_mode = C_MODE_2M_RAM;
+                       break;
+               case '2':
+                       printf("4M, no RAM.\n");
+                       mx_mode = C_MODE_4M_NORAM;
+                       break;
+               default:
+                       printf("4M with RAM.\n");
+                       mx_mode = C_MODE_4M_RAM;
+                       break;
+               }
+               set_ram_mode(device, mx_mode);
+       }
+
        /* read flash */
        if (do_read && r_fname == NULL) {
                ret = read_filename(device, fname_buff, sizeof(fname_buff), FILENAME_ROM0);