Skip to content

Commit 53f51b5

Browse files
Clean up uploader.py, use implied paths (#5805)
No need to explicitly send in full paths for esptool and pyserial Python libs because they're in well known locations relative to upload.py. Make upload.py calculate these on-the-fly and clean up platform.txt.
1 parent 472faf7 commit 53f51b5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: platform.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ tools.esptool.upload.params.quiet=
137137
# First, potentially perform an erase or nothing
138138
# Next, do the binary upload
139139
# Combined in one rule because Arduino doesn't suport upload.1.pattern/upload.3.pattern
140-
tools.esptool.upload.pattern="{cmd}" "{runtime.platform.path}/tools/upload.py" "{runtime.platform.path}/tools/pyserial" "{runtime.platform.path}/tools/esptool" --chip esp8266 --port "{serial.port}" --baud "{upload.speed}" "{upload.verbose}" {upload.erase_cmd} --end --chip esp8266 --port "{serial.port}" --baud "{upload.speed}" "{upload.verbose}" write_flash 0x0 "{build.path}/{build.project_name}.bin" --end
140+
tools.esptool.upload.pattern="{cmd}" "{runtime.platform.path}/tools/upload.py" --chip esp8266 --port "{serial.port}" --baud "{upload.speed}" "{upload.verbose}" {upload.erase_cmd} --end --chip esp8266 --port "{serial.port}" --baud "{upload.speed}" "{upload.verbose}" write_flash 0x0 "{build.path}/{build.project_name}.bin" --end
141141

142142
tools.esptool.upload.network_pattern="{network_cmd}" "{runtime.platform.path}/tools/espota.py" -i "{serial.port}" -p "{network.port}" "--auth={network.password}" -f "{build.path}/{build.project_name}.bin"
143143

Diff for: tools/upload.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
# i.e. upload.py tools/pyserial tools/esptool erase_flash --end write_flash file 0x0 --end
88

99
import sys
10+
import os
1011

1112
sys.argv.pop(0) # Remove executable name
13+
toolspath = os.path.dirname(os.path.realpath(__file__)).replace('\\', '/') # CWD in UNIX format
1214
try:
13-
sys.path.append(sys.argv.pop(0).replace('\\', '/')) # Add pyserial dir to search path, in UNIX format
14-
sys.path.append(sys.argv.pop(0).replace('\\', '/')) # Add esptool dir to search path, in UNIX format
15+
sys.path.append(toolspath + "/pyserial") # Add pyserial dir to search path
16+
sys.path.append(toolspath + "/esptool") # Add esptool dir to search path
1517
import esptool # If this fails, we can't continue and will bomb below
1618
except:
1719
sys.stderr.write("Error in command line, need pyserial path as 1st arg and esptool path as 2nd.\n")

0 commit comments

Comments
 (0)