Flash upgrade works now.
authorNIIBE Yutaka <gniibe@fsij.org>
Thu, 18 Jan 2018 10:32:58 +0000 (19:32 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Thu, 18 Jan 2018 10:32:58 +0000 (19:32 +0900)
ChangeLog
src/main.c
vendor/flying-stone-technology/INDEX_EN.HTM

index 9b7ec5e..88084d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2018-01-18  NIIBE Yutaka  <gniibe@fsij.org>
 
        * src/main.c (usb_main): USB suspend fix for Fraucheky.
+       (main): Fix for flash upgrade CRC calculation.
 
        * src/stack-def.h (SIZE_0, SIZE_1): Increase.
 
index 2110dd4..e216eba 100644 (file)
@@ -56,8 +56,14 @@ enum {
   FSIJ_DEVICE_NEUG_EXIT_REQUESTED = 255
 };
 
+/*
+ * When Running NeuG:          1
+ * NeuG enabled but Suspend:   -1
+ * No NeuG _and_ not Suspend:   0 
+ */
+static int8_t running_neug;
+
 #ifdef FRAUCHEKY_SUPPORT
-static uint8_t running_neug;
 extern void EP6_IN_Callback (uint16_t len);
 extern void EP6_OUT_Callback (uint16_t len);
 #endif
@@ -862,20 +868,22 @@ usb_main (void *arg)
                break;
 
              case USB_EVENT_DEVICE_SUSPEND:
-#ifdef FRAUCHEKY_SUPPORT
-               if (running_neug)
-#endif
-                 neug_fini ();
+               if (running_neug == 1)
+                 {
+                   running_neug = -1;
+                   neug_fini ();
+                 }
                chopstx_conf_idle (2);
                bDeviceState |= USB_DEVICE_STATE_SUSPEND;
                break;
 
              case USB_EVENT_DEVICE_WAKEUP:
                chopstx_conf_idle (1);
-#ifdef FRAUCHEKY_SUPPORT
-               if (running_neug)
-#endif
-                 neug_init (random_word, RANDOM_BYTES_LENGTH/sizeof (uint32_t));
+               if (running_neug == -1)
+                 {
+                   neug_init (random_word, RANDOM_BYTES_LENGTH/sizeof (uint32_t));
+                   running_neug = 1;
+                 }
                bDeviceState &= ~USB_DEVICE_STATE_SUSPEND;
                break;
 
@@ -1120,7 +1128,6 @@ main (int argc, char **argv)
     {
     go_fraucheky:
       bDeviceState = USB_DEVICE_STATE_UNCONNECTED;
-      running_neug = 0;
       usb_thd = chopstx_create (PRIO_USB, STACK_ADDR_USB, STACK_SIZE_USB,
                                usb_main, NULL);
       while (bDeviceState != USB_DEVICE_STATE_CONFIGURED)
@@ -1132,13 +1139,10 @@ main (int argc, char **argv)
       usb_lld_shutdown ();
       bDeviceState = USB_DEVICE_STATE_UNCONNECTED;
     }
+#endif
 
   neug_init (random_word, RANDOM_BYTES_LENGTH/sizeof (uint32_t));
-
   running_neug = 1;
-#else
-  neug_init (random_word, RANDOM_BYTES_LENGTH/sizeof (uint32_t));
-#endif
 
   led_thread = chopstx_create (PRIO_LED, STACK_ADDR_LED, STACK_SIZE_LED,
                               led_blinker, NULL);
@@ -1269,7 +1273,16 @@ main (int argc, char **argv)
    * We come here, because of FSIJ_DEVICE_NEUG_EXIT_REQUESTED
    * or FSIJ_DEVICE_NEUG_FRAUCHEKY_REQUESTED.
    */
-  neug_fini ();
+  if (running_neug == 1)
+    {
+      running_neug = 0;
+      neug_fini ();
+
+      /* Enable CRC module again.
+       * This is required (together with one in download_check_crc32).
+       */
+      crc32_rv_reset ();
+    }
 
   chopstx_mutex_lock (&usb_mtx);
 #ifdef FRAUCHEKY_SUPPORT
index 90e165d..3c8beb9 100644 (file)
@@ -16,7 +16,8 @@
    will become a different USB device, starting NeuG.
    Your action may be one of following actions:
    <ul>
-     <li>In your shell command line, type <tt>eject /dev/sda</tt>(change <tt>sda</tt> to match your environment).</li>
+     <li>In your shell command line, type <tt>eject /dev/sda</tt>
+         (change <tt>sda</tt> to match your environment).</li>
      <li>By GUI file manager, eject the disk named "Fraucheky".</li>
    </ul>
 </p>