Ver Fonte

flashmax.pl: don't reset after reading board type in ROM

Resetting after reading the board type is rather redundant.
H. Peter Anvin há 1 ano atrás
pai
commit
a9394afb92
1 ficheiros alterados com 19 adições e 13 exclusões
  1. 19 13
      tools/flashmax.pl

+ 19 - 13
tools/flashmax.pl

@@ -128,7 +128,7 @@ sub unquote_cmd($) {
     return @a;
 }
 
-# Similar to grep, but for a hash; also filters out 
+# Similar to grep, but for a hash; also filters out
 sub hgrep(&%) {
     my($mfunc, %hash) = @_;
 
@@ -216,13 +216,13 @@ sub match_version($$)
     my @vv = target_string_valid($version);
 
     return 0 unless (defined($vv[0]));
-    
+
     my $v_board = $vv[0];
     my @v_ver   = split(/\./, $vv[1]);
     my $v_flags = $vv[2];
 
     return 1 if ($pattern eq $v_board); # Board only matchall pattern
-    
+
     if ($pattern !~ /^(\S+) v((?:0|[1-9][0-9]*)(?:\.\.0|\.[1-9][0-9]*)*)(?:(\-)((?:0|[1-9][0-9]*)(?:\.\.0|\.[1-9][0-9]*)*))?(?: ([\+\-a-zA-Z0-9]*))?$/) {
 	return 0;
     }
@@ -256,12 +256,18 @@ sub match_version($$)
 
     return 1;
 }
-    
+
+my %espopt = ('before' => 'default_reset', 'after' => 'hard_reset',
+	      'connect-attempts' => 8);
+
+
 sub get_target_board($$)
 {
     my($port,$boardinfo) = @_;
 
-    run_esptool($port, { 'before' => 'default_reset', 'after' => 'hard_reset' },
+    my %myespopt = (%espopt);
+    $myespopt{'after'} = 'no_reset';
+    run_esptool($port, \%myespopt,
 		'read_flash', { },
 		''.$boardinfo_addr, ''.$boardinfo_len, $boardinfo);
 
@@ -286,7 +292,7 @@ sub get_target_board($$)
 
     return undef;
 }
-    
+
 my @args = @ARGV;
 my $esponly = 0;
 my $file;
@@ -349,7 +355,7 @@ if (defined($target_board)) {
     push(@espfiles, ''.$boardinfo_addr, $boardinfo);
 } else {
     # Get the board version from target flash
-    
+
     $target_board = get_target_board($port, $boardinfo);
     if (!defined($target_board) || !target_string_valid($target_board)) {
 	die "$0: $port: board version not programmed, specify with --setver\n";
@@ -414,7 +420,7 @@ while (read($fw, $hdr, 16) == 16) {
 	    $err = 1;
 	    last;
 	}
-	
+
 	if ($c->{'vmin'} > $version_match->{'vmax'} ||
 	    $c->{'vmax'} < $version_match->{'vmin'} ||
 	    (($c->{'vmatch'} ^ $version_match->{'vmatch'}) & $c->{'vmask'})) {
@@ -422,7 +428,7 @@ while (read($fw, $hdr, 16) == 16) {
 	    next;
 	}
     }
-    
+
     push(@chunks, $c);
 
     last if ($t eq 'end'); # End of stream
@@ -431,10 +437,10 @@ while (read($fw, $hdr, 16) == 16) {
 close($fw);
 exit $err if ($err);
 
-my %espopt = ('before' => 'default_reset', 'after' => 'hard_reset',
-	      'baud' => 115200, 'port' => undef, 'chip' => undef,
-	      'flash_mode' => undef, 'flash_freq' => undef,
-	      'flash_size' => undef);
+%espopt = (%espopt,
+	   'baud' => 115200, 'port' => undef, 'chip' => undef,
+	   'flash_mode' => undef, 'flash_freq' => undef,
+	   'flash_size' => undef);
 
 # Create a compressed data buffer without the ESP32 chunks
 my $fpgadata;