|
@@ -255,9 +255,7 @@ sub run_esptool($$$$@)
|
|
|
my($port,$common_options,$cmd,$cmd_options,@args) = @_;
|
|
|
|
|
|
my @espcmd = unquote_cmd($esptool);
|
|
|
- if (defined($port) && $common_options->{'port'} ne '') {
|
|
|
- push(@espcmd, '--port', $port);
|
|
|
- }
|
|
|
+ push(@espcmd, '--port', $port);
|
|
|
push(@espcmd, hash2opt($common_options));
|
|
|
push(@espcmd, unquote_cmd($cmd));
|
|
|
push(@espcmd, hash2opt($cmd_options));
|
|
@@ -777,6 +775,7 @@ sub upload_fpgadata($$) {
|
|
|
|
|
|
my @args = @ARGV;
|
|
|
my $esponly = 0;
|
|
|
+my $fpgaonly = 0;
|
|
|
my $file;
|
|
|
my $target_board = undef;
|
|
|
my $setver = 0;
|
|
@@ -789,6 +788,8 @@ while (1) {
|
|
|
|
|
|
if ($file eq '--esponly') {
|
|
|
$esponly = 1;
|
|
|
+ } elsif ($file eq '--fpgaonly') {
|
|
|
+ $fpgaonly = 1;
|
|
|
} elsif ($file eq '--which') {
|
|
|
$which = 1;
|
|
|
} elsif ($file eq '--setver') {
|
|
@@ -805,6 +806,33 @@ while (1) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+%espopt = (%espopt,
|
|
|
+ 'baud' => 115200, 'port' => undef, 'chip' => undef,
|
|
|
+ 'flash_mode' => undef, 'flash_freq' => undef,
|
|
|
+ 'flash_size' => undef);
|
|
|
+
|
|
|
+foreach my $e (keys %espopt) {
|
|
|
+ my $ev = $ENV{"ESP\U$e"};
|
|
|
+ if (defined($ev)) {
|
|
|
+ $espopt{$e} = $ev;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+while (defined(my $eo = shift(@args))) {
|
|
|
+ if ($eo =~ /^([^=]+)=(.*)$/) {
|
|
|
+ $espopt{$1} = $2;
|
|
|
+ } elsif ($args[0] !~ /^-/) {
|
|
|
+ $espopt{$eo} = shift(@args);
|
|
|
+ } else {
|
|
|
+ $espopt{$eo} = '';
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+if (defined($espopt{'port'})) {
|
|
|
+ $port = $espopt{'port'} unless (defined($port));
|
|
|
+ delete $espopt{'port'};
|
|
|
+}
|
|
|
+
|
|
|
# Legacy command line support: if no --port, specify port after firmware file
|
|
|
if (defined($file) && !defined($port) && $args[0] ne '--esptool') {
|
|
|
$port = shift(@args);
|
|
@@ -826,14 +854,14 @@ if ($which) {
|
|
|
exit 0;
|
|
|
}
|
|
|
|
|
|
-print STDERR "esptool v${espver} found\n\n";
|
|
|
+print STDERR "esptool ${espver} found\n\n";
|
|
|
|
|
|
if (!defined($port)) {
|
|
|
die "Usage: $0 [--which][--esponly][--setver version][--port port]\n".
|
|
|
" [file.fw] [--esptool esptool_options...]\n";
|
|
|
}
|
|
|
|
|
|
-if (!File::Spec->file_name_is_absolute($port)) {
|
|
|
+if (! -c $port && !File::Spec->file_name_is_absolute($port)) {
|
|
|
if (-c "/dev/$port") {
|
|
|
$port = "/dev/$port";
|
|
|
} elsif (-c "/dev/tty$port") {
|
|
@@ -846,28 +874,6 @@ if (!File::Spec->file_name_is_absolute($port)) {
|
|
|
}
|
|
|
print STDERR "Using serial port device $port\n";
|
|
|
|
|
|
-%espopt = (%espopt,
|
|
|
- 'baud' => 115200, 'port' => undef, 'chip' => undef,
|
|
|
- 'flash_mode' => undef, 'flash_freq' => undef,
|
|
|
- 'flash_size' => undef);
|
|
|
-
|
|
|
-foreach my $e (keys %espopt) {
|
|
|
- my $ev = $ENV{"ESP\U$e"};
|
|
|
- if (defined($ev)) {
|
|
|
- $espopt{$e} = $ev;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-while (defined(my $eo = shift(@args))) {
|
|
|
- if ($eo =~ /^([^=]+)=(.*)$/) {
|
|
|
- $espopt{$1} = $2;
|
|
|
- } elsif ($args[0] !~ /^-/) {
|
|
|
- $espopt{$eo} = shift(@args);
|
|
|
- } else {
|
|
|
- $espopt{$eo} = '';
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
my @espfiles = ();
|
|
|
|
|
|
if (defined($target_board)) {
|
|
@@ -896,7 +902,7 @@ if (defined($target_board)) {
|
|
|
my($fwfiles, $fpgadata) = read_fwfile($file, $target_board);
|
|
|
push(@espfiles, @$fwfiles);
|
|
|
|
|
|
-if (scalar(@espfiles)) {
|
|
|
+if (!$fpgaonly && scalar(@espfiles)) {
|
|
|
run_esptool($port, { hgrep {!/^flash_/} %espopt },
|
|
|
'write_flash', { hgrep {/^flash_/} %espopt },
|
|
|
'-z', map { (sprintf('0x%x', $_->[0]), $_->[1]) } @espfiles);
|