Преглед на файлове

fwupdate: improve performance, but locks up over USB... why?

H. Peter Anvin преди 2 години
родител
ревизия
98d3af41b7
променени са 5 файла, в които са добавени 13 реда и са изтрити 5 реда
  1. 9 3
      esp32/flashesp.pl
  2. 4 2
      esp32/max80/tty.cpp
  3. BIN
      esp32/output/max80.ino.bin
  4. BIN
      fpga/output/v1.fw
  5. BIN
      fpga/output/v2.fw

+ 9 - 3
esp32/flashesp.pl

@@ -397,6 +397,7 @@ my $maxchunk = 64;
 my $maxahead = 256;
 my $last_ack = 0;
 my @pktends  = ();
+my $last_enq = 0;
 
 print STDERR "\nStarting packet transmit...\n";
 
@@ -412,7 +413,7 @@ while ($last_ack < $bytes) {
 	$chunk = 0 if ($chunk <= 0);
 	$chunk = $maxchunk if ($chunk > $maxchunk);
 
-	my $d = tty_read($tty, \$ttybuf, $chunk ? 0 : 1000);
+	my $d = tty_read($tty, \$ttybuf, $chunk ? 0 : $maxchunk/10);
 	last if ($d eq '');
 
 	my $dc = unpack('C', $d);
@@ -441,10 +442,15 @@ while ($last_ack < $bytes) {
 	}
     }
 
-    print STDERR "Send offset: $offset, window: $winspc, chunk: $chunk\n";
+    print STDERR "Send offset: $offset, last ack: $last_ack, window: $winspc, chunk: $chunk\n";
     if (!$chunk) {
 	if ($bytes > $offset) {
-	    tty_write($tty, "\026"); # Request to resynchronize credits
+	    my $now = time();
+	    if ($now != $last_enq) {
+		tty_write($tty, "\026"); # SYN: request window resync
+		print STDERR "Trying to resynchronize window\n";
+		$last_enq = $now;
+	    }
 	}
 	next;
     }

+ 4 - 2
esp32/max80/tty.cpp

@@ -75,11 +75,13 @@ int TTY::rxdata(void *buf, size_t len)
 		break;
 
 	    if (port().write(WRST)) {
+		printf("[UPLD] Resetting window\n");
 		tx_credits_reset = false;
 		tx_credits = STREAMBUF_SIZE - BUF_SLACK;
 	    } else {
-		// Uhm... wait one tick and then try again to sent WRST?
-		rcv = xStreamBufferReceive(rx_sbuf, buf, len, 1);
+		// Uhm... wait a tiny bit and then try again to sent WRST?
+		printf("[UPLD] Failed to reset window?!\n");
+		rcv = xStreamBufferReceive(rx_sbuf, buf, len, 10);
 	    }
 	} else {
 	    while (tx_credits >= WGO_CHUNK && port().write(WGO))

BIN
esp32/output/max80.ino.bin


BIN
fpga/output/v1.fw


BIN
fpga/output/v2.fw