Merge branch 'develop' into feature/platformio-30

* develop:
  Improve checking for the program size before uploading // Issue #689
  Refactor board "hwid" option to "hwids"
  Add HWID for NodeMCU board
  Better checking of program size before uploading // Issue #689
This commit is contained in:
Ivan Kravets
2016-06-11 16:46:34 +03:00
4 changed files with 18 additions and 13 deletions

View File

@@ -21,8 +21,8 @@ PlatformIO 2.0
* Added support for `emonPi <https://github.com/openenergymonitor/emonpi>`__,
the OpenEnergyMonitor system
(`issue #687 <https://github.com/platformio/platformio/issues/687>`_)
* Added support for STM32F0 boards for `SPL <http://platformio.org/frameworks/spl>`__
framework
* Added support for `SPL <http://platformio.org/frameworks/spl>`__
framework for STM32F0 boards
(`issue #683 <https://github.com/platformio/platformio/issues/683>`_)
* Added support for `Arduboy DevKit <https://www.arduboy.com>`__, the game system
the size of a credit card

View File

@@ -133,6 +133,3 @@ if "envdump" in COMMAND_LINE_TARGETS:
if "idedata" in COMMAND_LINE_TARGETS:
print json.dumps(env.DumpIDEData())
env.Exit()
if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS):
env.CheckUploadSize()

View File

@@ -79,7 +79,9 @@ def WaitForNewSerialPort(env, before):
return new_port
def AutodetectUploadPort(env):
def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
env = args[0]
print "Looking for upload port/disk..."
def _look_for_mbed_disk():
msdlabels = ("mbed", "nucleo", "frdm")
@@ -106,6 +108,7 @@ def AutodetectUploadPort(env):
return port
if "UPLOAD_PORT" in env:
print env.subst("Manually specified: $UPLOAD_PORT")
return
if env.subst("$FRAMEWORK") == "mbed":
@@ -113,7 +116,7 @@ def AutodetectUploadPort(env):
else:
if (system() == "Linux" and
not isfile("/etc/udev/99-platformio-udev.rules")):
print (
print(
"\nWarning! Please install `99-platformio-udev.rules` and "
"check that your board's PID and VID are listed in the rules."
"\n https://raw.githubusercontent.com/platformio/platformio"
@@ -122,7 +125,7 @@ def AutodetectUploadPort(env):
env.Replace(UPLOAD_PORT=_look_for_serial_port())
if env.subst("$UPLOAD_PORT"):
print "Auto-detected UPLOAD_PORT/DISK: %s" % env['UPLOAD_PORT']
print env.subst("Auto-detected: $UPLOAD_PORT")
else:
env.Exit("Error: Please specify `upload_port` for environment or use "
"global `--upload-port` option.\n"
@@ -143,27 +146,27 @@ def UploadToDisk(_, target, source, env): # pylint: disable=W0613,W0621
"Please restart your board.")
def CheckUploadSize(env):
def CheckUploadSize(_, target, source, env): # pylint: disable=W0613,W0621
if "BOARD" not in env:
return
max_size = int(env.BoardConfig().get("upload.maximum_size", 0))
if max_size == 0 or "SIZETOOL" not in env:
return
print "Check program size..."
sysenv = environ.copy()
sysenv['PATH'] = str(env['ENV']['PATH'])
cmd = [env.subst("$SIZETOOL"), "-B"]
cmd.append(env.subst(join("$BUILD_DIR", "$PROGNAME$PROGSUFFIX")))
cmd = [env.subst("$SIZETOOL"), "-B", str(source[0])]
result = util.exec_command(cmd, env=sysenv)
if result['returncode'] != 0:
return
print result['out'].strip()
line = result['out'].strip().splitlines()[1]
values = [v.strip() for v in line.split("\t")]
used_size = int(values[0]) + int(values[1])
if used_size > max_size:
print result['out']
env.Exit("Error: The program size (%d bytes) is greater "
"than maximum allowed (%s bytes)" % (used_size, max_size))

View File

@@ -96,11 +96,16 @@ def BuildProgram(env):
"Error: Nothing to build. Please put your source code files "
"to '%s' folder" % env.subst("$PROJECTSRC_DIR"))
return env.Program(
program = env.Program(
join("$BUILD_DIR", env.subst("$PROGNAME")),
sources
)
if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS):
env.AddPostAction(program, env.CheckUploadSize)
return program
def ProcessFlags(env, flags):
for f in flags: