Skip to content

Commit 36c3b8d

Browse files
committed
Updated to esptool.py for flashing
1 parent 9a31d78 commit 36c3b8d

File tree

260 files changed

+45878
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+45878
-8
lines changed

Changelog.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
### 3.2
55

6-
- Compiled against [2.6.4 Arduino Core](https://github.com/esp8266/Arduino/releases/tag/2.7.4)
7-
- Updated to [AdruinoJson 6.16.1](https://github.com/bblanchon/ArduinoJson/releases/tag/v6.16.1)
6+
- Compiled against [2.7.4 Arduino Core](https://github.com/esp8266/Arduino/releases/tag/2.7.4)
7+
- Updated to [AdruinoJson 6.17.0](https://github.com/bblanchon/ArduinoJson/releases/tag/v6.17.0)
88
- Updated to [async-mqtt-client 2019.12.08](https://github.com/marvinroger/async-mqtt-client/tree/7f1ba481a22d56ccf123e4b2f6e555d134c956d0)
99
- Fix for Client Timeout not Changing [Issue #201](https://github.com/forkineye/ESPixelStick/issues/201)
10+
- Updated the flash tool included in binary releases to fix issues flashing on newer releases of MacOS.
1011

1112
### 3.1
1213

dist/ESPSFlashTool.jar

3 KB
Binary file not shown.

dist/bin/esptool/CONTRIBUTING.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Contributing to esptool.py
2+
3+
## Reporting Issues
4+
5+
Please report bugs in esptool.py if you find them.
6+
7+
However, before reporting a bug please check through the following:
8+
9+
* [Troubleshooting Section](https://github.com/espressif/esptool/#troubleshooting) - common problems and known issues
10+
11+
* [Existing Open Issues](https://github.com/espressif/esptool/issues) - someone might have already encountered this.
12+
13+
If you don't find anything, please [open a new issue](https://github.com/espressif/esptool/issues/new).
14+
15+
## Sending Feature Requests
16+
17+
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
18+
19+
There are usually some outstanding feature requests in the [existing issues list](https://github.com/espressif/esptool/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
20+
21+
## Sending Pull Requests
22+
23+
Pull Requests with changes and fixes are also welcome!
24+
25+
### Code Style & Static Analysis
26+
27+
esptool.py complies with Flake 8 and is valid Python 2 & Python 3 code (in the same source file.)
28+
29+
When you submit a Pull Request, the Travis automated build system will run automated checks for this, using the [flake8 tool](http://flake8.readthedocs.io/en/latest/). If you want to check your code locally before submitting, you can install flake8 and run `python setup.py flake8` to test it.
30+
31+
### Automated Integration Tests
32+
33+
The test directory contains an integration suite with some integration tests for esptool.py:
34+
35+
* `test_imagegen.py` tests the elf2image command and is run automatically by Travis for each Pull Request. You can run this command locally to check for regressions in the elf2image functionality.
36+
37+
* `test_esptool.py` is a [Python unittest](https://docs.python.org/3/library/unittest.html) file that contains integration tests to be run against real ESP8266 or ESP32 hardware. These tests need real hardware so are not run automatically by Travis, they need to be run locally:
38+
39+
`test_esptool.py` takes a command line with the following format:
40+
41+
`./test_esptool.py <serial port> <name of chip> <baud rate> [optional test name(s)]`
42+
43+
For example, to run all tests on an ESP32 board connected to /dev/ttyUSB0, at 230400bps:
44+
45+
`./test_esptool.py /dev/ttyUSB0 esp32 230400`
46+
47+
Or to run the TestFlashing suite only on an ESP8266 board connected to /dev/ttyUSB2` at 460800bps:
48+
49+
`./test_esptool.py /dev/ttyUSB2 esp8266 460800 TestFlashing`
50+
51+
(Note that some tests will fail at higher baud rates on some hardware.)

dist/bin/esptool/LICENSE

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

dist/bin/esptool/MANIFEST.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
include README.md
2+
include LICENSE
3+
# sdist includes test/test*.py by default, but esptool.py tests
4+
# are so far only intended to run from the git repo itself
5+
prune test
6+
prune ecdsa
7+
prune pyaes
8+
prune flasher_stub
9+
prune .github
10+
exclude .git*
11+
exclude .travis*
12+
exclude MANIFEST*
13+
14+

dist/bin/esptool/README.md

Lines changed: 446 additions & 0 deletions
Large diffs are not rendered by default.

dist/bin/esptool/ecdsa/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
__all__ = ["curves", "der", "ecdsa", "ellipticcurve", "keys", "numbertheory",
2+
"test_pyecdsa", "util", "six"]
3+
from .keys import SigningKey, VerifyingKey, BadSignatureError, BadDigestError
4+
from .curves import NIST192p, NIST224p, NIST256p, NIST384p, NIST521p, SECP256k1
5+
6+
_hush_pyflakes = [SigningKey, VerifyingKey, BadSignatureError, BadDigestError,
7+
NIST192p, NIST224p, NIST256p, NIST384p, NIST521p, SECP256k1]
8+
del _hush_pyflakes
9+
10+
# This code comes from http://github.com/warner/python-ecdsa
11+
12+
from ._version import get_versions
13+
__version__ = get_versions()['version']
14+
del get_versions

dist/bin/esptool/ecdsa/_version.py

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
2+
# This file helps to compute a version number in source trees obtained from
3+
# git-archive tarball (such as those provided by githubs download-from-tag
4+
# feature). Distribution tarballs (built by setup.py sdist) and build
5+
# directories (produced by setup.py build) will contain a much shorter file
6+
# that just contains the computed version number.
7+
8+
# This file is released into the public domain. Generated by
9+
# versioneer-0.12 (https://github.com/warner/python-versioneer)
10+
11+
# these strings will be replaced by git during git-archive
12+
git_refnames = " (tag: python-ecdsa-0.13)"
13+
git_full = "5a6fc047222cf21ad89f6cbf8782d0f1e3ddacda"
14+
15+
# these strings are filled in when 'setup.py versioneer' creates _version.py
16+
tag_prefix = "python-ecdsa-"
17+
parentdir_prefix = "ecdsa-"
18+
versionfile_source = "ecdsa/_version.py"
19+
20+
import os, sys, re, subprocess, errno
21+
22+
def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
23+
assert isinstance(commands, list)
24+
p = None
25+
for c in commands:
26+
try:
27+
# remember shell=False, so use git.cmd on windows, not just git
28+
p = subprocess.Popen([c] + args, cwd=cwd, stdout=subprocess.PIPE,
29+
stderr=(subprocess.PIPE if hide_stderr
30+
else None))
31+
break
32+
except EnvironmentError:
33+
e = sys.exc_info()[1]
34+
if e.errno == errno.ENOENT:
35+
continue
36+
if verbose:
37+
print("unable to run %s" % args[0])
38+
print(e)
39+
return None
40+
else:
41+
if verbose:
42+
print("unable to find command, tried %s" % (commands,))
43+
return None
44+
stdout = p.communicate()[0].strip()
45+
if sys.version >= '3':
46+
stdout = stdout.decode()
47+
if p.returncode != 0:
48+
if verbose:
49+
print("unable to run %s (error)" % args[0])
50+
return None
51+
return stdout
52+
53+
54+
def versions_from_parentdir(parentdir_prefix, root, verbose=False):
55+
# Source tarballs conventionally unpack into a directory that includes
56+
# both the project name and a version string.
57+
dirname = os.path.basename(root)
58+
if not dirname.startswith(parentdir_prefix):
59+
if verbose:
60+
print("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" %
61+
(root, dirname, parentdir_prefix))
62+
return None
63+
return {"version": dirname[len(parentdir_prefix):], "full": ""}
64+
65+
def git_get_keywords(versionfile_abs):
66+
# the code embedded in _version.py can just fetch the value of these
67+
# keywords. When used from setup.py, we don't want to import _version.py,
68+
# so we do it with a regexp instead. This function is not used from
69+
# _version.py.
70+
keywords = {}
71+
try:
72+
f = open(versionfile_abs,"r")
73+
for line in f.readlines():
74+
if line.strip().startswith("git_refnames ="):
75+
mo = re.search(r'=\s*"(.*)"', line)
76+
if mo:
77+
keywords["refnames"] = mo.group(1)
78+
if line.strip().startswith("git_full ="):
79+
mo = re.search(r'=\s*"(.*)"', line)
80+
if mo:
81+
keywords["full"] = mo.group(1)
82+
f.close()
83+
except EnvironmentError:
84+
pass
85+
return keywords
86+
87+
def git_versions_from_keywords(keywords, tag_prefix, verbose=False):
88+
if not keywords:
89+
return {} # keyword-finding function failed to find keywords
90+
refnames = keywords["refnames"].strip()
91+
if refnames.startswith("$Format"):
92+
if verbose:
93+
print("keywords are unexpanded, not using")
94+
return {} # unexpanded, so not in an unpacked git-archive tarball
95+
refs = set([r.strip() for r in refnames.strip("()").split(",")])
96+
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
97+
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
98+
TAG = "tag: "
99+
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
100+
if not tags:
101+
# Either we're using git < 1.8.3, or there really are no tags. We use
102+
# a heuristic: assume all version tags have a digit. The old git %d
103+
# expansion behaves like git log --decorate=short and strips out the
104+
# refs/heads/ and refs/tags/ prefixes that would let us distinguish
105+
# between branches and tags. By ignoring refnames without digits, we
106+
# filter out many common branch names like "release" and
107+
# "stabilization", as well as "HEAD" and "master".
108+
tags = set([r for r in refs if re.search(r'\d', r)])
109+
if verbose:
110+
print("discarding '%s', no digits" % ",".join(refs-tags))
111+
if verbose:
112+
print("likely tags: %s" % ",".join(sorted(tags)))
113+
for ref in sorted(tags):
114+
# sorting will prefer e.g. "2.0" over "2.0rc1"
115+
if ref.startswith(tag_prefix):
116+
r = ref[len(tag_prefix):]
117+
if verbose:
118+
print("picking %s" % r)
119+
return { "version": r,
120+
"full": keywords["full"].strip() }
121+
# no suitable tags, so we use the full revision id
122+
if verbose:
123+
print("no suitable tags, using full revision id")
124+
return { "version": keywords["full"].strip(),
125+
"full": keywords["full"].strip() }
126+
127+
128+
def git_versions_from_vcs(tag_prefix, root, verbose=False):
129+
# this runs 'git' from the root of the source tree. This only gets called
130+
# if the git-archive 'subst' keywords were *not* expanded, and
131+
# _version.py hasn't already been rewritten with a short version string,
132+
# meaning we're inside a checked out source tree.
133+
134+
if not os.path.exists(os.path.join(root, ".git")):
135+
if verbose:
136+
print("no .git in %s" % root)
137+
return {}
138+
139+
GITS = ["git"]
140+
if sys.platform == "win32":
141+
GITS = ["git.cmd", "git.exe"]
142+
stdout = run_command(GITS, ["describe", "--tags", "--dirty", "--always"],
143+
cwd=root)
144+
if stdout is None:
145+
return {}
146+
if not stdout.startswith(tag_prefix):
147+
if verbose:
148+
print("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix))
149+
return {}
150+
tag = stdout[len(tag_prefix):]
151+
stdout = run_command(GITS, ["rev-parse", "HEAD"], cwd=root)
152+
if stdout is None:
153+
return {}
154+
full = stdout.strip()
155+
if tag.endswith("-dirty"):
156+
full += "-dirty"
157+
return {"version": tag, "full": full}
158+
159+
160+
def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
161+
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
162+
# __file__, we can work backwards from there to the root. Some
163+
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
164+
# case we can only use expanded keywords.
165+
166+
keywords = { "refnames": git_refnames, "full": git_full }
167+
ver = git_versions_from_keywords(keywords, tag_prefix, verbose)
168+
if ver:
169+
return ver
170+
171+
try:
172+
root = os.path.abspath(__file__)
173+
# versionfile_source is the relative path from the top of the source
174+
# tree (where the .git directory might live) to this file. Invert
175+
# this to find the root from __file__.
176+
for i in range(len(versionfile_source.split(os.sep))):
177+
root = os.path.dirname(root)
178+
except NameError:
179+
return default
180+
181+
return (git_versions_from_vcs(tag_prefix, root, verbose)
182+
or versions_from_parentdir(parentdir_prefix, root, verbose)
183+
or default)

dist/bin/esptool/ecdsa/curves.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from __future__ import division
2+
3+
from . import der, ecdsa
4+
5+
class UnknownCurveError(Exception):
6+
pass
7+
8+
def orderlen(order):
9+
return (1+len("%x"%order))//2 # bytes
10+
11+
# the NIST curves
12+
class Curve:
13+
def __init__(self, name, curve, generator, oid, openssl_name=None):
14+
self.name = name
15+
self.openssl_name = openssl_name # maybe None
16+
self.curve = curve
17+
self.generator = generator
18+
self.order = generator.order()
19+
self.baselen = orderlen(self.order)
20+
self.verifying_key_length = 2*self.baselen
21+
self.signature_length = 2*self.baselen
22+
self.oid = oid
23+
self.encoded_oid = der.encode_oid(*oid)
24+
25+
NIST192p = Curve("NIST192p", ecdsa.curve_192, ecdsa.generator_192,
26+
(1, 2, 840, 10045, 3, 1, 1), "prime192v1")
27+
NIST224p = Curve("NIST224p", ecdsa.curve_224, ecdsa.generator_224,
28+
(1, 3, 132, 0, 33), "secp224r1")
29+
NIST256p = Curve("NIST256p", ecdsa.curve_256, ecdsa.generator_256,
30+
(1, 2, 840, 10045, 3, 1, 7), "prime256v1")
31+
NIST384p = Curve("NIST384p", ecdsa.curve_384, ecdsa.generator_384,
32+
(1, 3, 132, 0, 34), "secp384r1")
33+
NIST521p = Curve("NIST521p", ecdsa.curve_521, ecdsa.generator_521,
34+
(1, 3, 132, 0, 35), "secp521r1")
35+
SECP256k1 = Curve("SECP256k1", ecdsa.curve_secp256k1, ecdsa.generator_secp256k1,
36+
(1, 3, 132, 0, 10), "secp256k1")
37+
38+
curves = [NIST192p, NIST224p, NIST256p, NIST384p, NIST521p, SECP256k1]
39+
40+
def find_curve(oid_curve):
41+
for c in curves:
42+
if c.oid == oid_curve:
43+
return c
44+
raise UnknownCurveError("I don't know about the curve with oid %s."
45+
"I only know about these: %s" %
46+
(oid_curve, [c.name for c in curves]))

0 commit comments

Comments
 (0)