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

View File

@@ -133,6 +133,3 @@ if "envdump" in COMMAND_LINE_TARGETS:
if "idedata" in COMMAND_LINE_TARGETS: if "idedata" in COMMAND_LINE_TARGETS:
print json.dumps(env.DumpIDEData()) print json.dumps(env.DumpIDEData())
env.Exit() 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 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(): def _look_for_mbed_disk():
msdlabels = ("mbed", "nucleo", "frdm") msdlabels = ("mbed", "nucleo", "frdm")
@@ -106,6 +108,7 @@ def AutodetectUploadPort(env):
return port return port
if "UPLOAD_PORT" in env: if "UPLOAD_PORT" in env:
print env.subst("Manually specified: $UPLOAD_PORT")
return return
if env.subst("$FRAMEWORK") == "mbed": if env.subst("$FRAMEWORK") == "mbed":
@@ -122,7 +125,7 @@ def AutodetectUploadPort(env):
env.Replace(UPLOAD_PORT=_look_for_serial_port()) env.Replace(UPLOAD_PORT=_look_for_serial_port())
if env.subst("$UPLOAD_PORT"): if env.subst("$UPLOAD_PORT"):
print "Auto-detected UPLOAD_PORT/DISK: %s" % env['UPLOAD_PORT'] print env.subst("Auto-detected: $UPLOAD_PORT")
else: else:
env.Exit("Error: Please specify `upload_port` for environment or use " env.Exit("Error: Please specify `upload_port` for environment or use "
"global `--upload-port` option.\n" "global `--upload-port` option.\n"
@@ -143,27 +146,27 @@ def UploadToDisk(_, target, source, env): # pylint: disable=W0613,W0621
"Please restart your board.") "Please restart your board.")
def CheckUploadSize(env): def CheckUploadSize(_, target, source, env): # pylint: disable=W0613,W0621
if "BOARD" not in env: if "BOARD" not in env:
return return
max_size = int(env.BoardConfig().get("upload.maximum_size", 0)) max_size = int(env.BoardConfig().get("upload.maximum_size", 0))
if max_size == 0 or "SIZETOOL" not in env: if max_size == 0 or "SIZETOOL" not in env:
return return
print "Check program size..."
sysenv = environ.copy() sysenv = environ.copy()
sysenv['PATH'] = str(env['ENV']['PATH']) sysenv['PATH'] = str(env['ENV']['PATH'])
cmd = [env.subst("$SIZETOOL"), "-B"] cmd = [env.subst("$SIZETOOL"), "-B", str(source[0])]
cmd.append(env.subst(join("$BUILD_DIR", "$PROGNAME$PROGSUFFIX")))
result = util.exec_command(cmd, env=sysenv) result = util.exec_command(cmd, env=sysenv)
if result['returncode'] != 0: if result['returncode'] != 0:
return return
print result['out'].strip()
line = result['out'].strip().splitlines()[1] line = result['out'].strip().splitlines()[1]
values = [v.strip() for v in line.split("\t")] values = [v.strip() for v in line.split("\t")]
used_size = int(values[0]) + int(values[1]) used_size = int(values[0]) + int(values[1])
if used_size > max_size: if used_size > max_size:
print result['out']
env.Exit("Error: The program size (%d bytes) is greater " env.Exit("Error: The program size (%d bytes) is greater "
"than maximum allowed (%s bytes)" % (used_size, max_size)) "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 " "Error: Nothing to build. Please put your source code files "
"to '%s' folder" % env.subst("$PROJECTSRC_DIR")) "to '%s' folder" % env.subst("$PROJECTSRC_DIR"))
return env.Program( program = env.Program(
join("$BUILD_DIR", env.subst("$PROGNAME")), join("$BUILD_DIR", env.subst("$PROGNAME")),
sources sources
) )
if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS):
env.AddPostAction(program, env.CheckUploadSize)
return program
def ProcessFlags(env, flags): def ProcessFlags(env, flags):
for f in flags: for f in flags: