forked from platformio/platformio-core
Merge branch 'develop' into feature/platformio-30
* develop: Check program size before uploading to the board // Resolve #689 Fix issue with "-L relative/path" when parsing "build_flags" // Resolve #688 Fix upload speed for OpenEnergyMonitor board
This commit is contained in:
@ -26,6 +26,10 @@ PlatformIO 2.0
|
|||||||
(`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
|
||||||
|
* Check program size before uploading to the board
|
||||||
|
(`issue #689 <https://github.com/platformio/platformio/issues/689>`_)
|
||||||
|
* Fixed issue with ``-L relative/path`` when parsing ``build_flags``
|
||||||
|
(`issue #688 <https://github.com/platformio/platformio/issues/688>`_)
|
||||||
|
|
||||||
2.9.4 (2016-06-04)
|
2.9.4 (2016-06-04)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -133,3 +133,6 @@ 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()
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
from os import environ
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
from platform import system
|
from platform import system
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
@ -21,7 +22,7 @@ from time import sleep
|
|||||||
|
|
||||||
from serial import Serial
|
from serial import Serial
|
||||||
|
|
||||||
from platformio.util import get_logicaldisks, get_serialports, get_systype
|
from platformio import util
|
||||||
|
|
||||||
|
|
||||||
def FlushSerialBuffer(env, port):
|
def FlushSerialBuffer(env, port):
|
||||||
@ -36,7 +37,7 @@ def FlushSerialBuffer(env, port):
|
|||||||
|
|
||||||
|
|
||||||
def TouchSerialPort(env, port, baudrate):
|
def TouchSerialPort(env, port, baudrate):
|
||||||
if "windows" not in get_systype():
|
if system() != "Windows":
|
||||||
try:
|
try:
|
||||||
s = Serial(env.subst(port))
|
s = Serial(env.subst(port))
|
||||||
s.close()
|
s.close()
|
||||||
@ -54,7 +55,7 @@ def WaitForNewSerialPort(env, before):
|
|||||||
new_port = None
|
new_port = None
|
||||||
elapsed = 0
|
elapsed = 0
|
||||||
while elapsed < 5 and new_port is None:
|
while elapsed < 5 and new_port is None:
|
||||||
now = get_serialports()
|
now = util.get_serialports()
|
||||||
for p in now:
|
for p in now:
|
||||||
if p not in before:
|
if p not in before:
|
||||||
new_port = p['port']
|
new_port = p['port']
|
||||||
@ -82,7 +83,7 @@ def AutodetectUploadPort(env):
|
|||||||
|
|
||||||
def _look_for_mbed_disk():
|
def _look_for_mbed_disk():
|
||||||
msdlabels = ("mbed", "nucleo", "frdm")
|
msdlabels = ("mbed", "nucleo", "frdm")
|
||||||
for item in get_logicaldisks():
|
for item in util.get_logicaldisks():
|
||||||
if (not item['name'] or
|
if (not item['name'] or
|
||||||
not any([l in item['name'].lower() for l in msdlabels])):
|
not any([l in item['name'].lower() for l in msdlabels])):
|
||||||
continue
|
continue
|
||||||
@ -94,7 +95,7 @@ def AutodetectUploadPort(env):
|
|||||||
board_hwids = []
|
board_hwids = []
|
||||||
if "BOARD" in env and "build.hwids" in env.BoardConfig():
|
if "BOARD" in env and "build.hwids" in env.BoardConfig():
|
||||||
board_hwids = env.BoardConfig().get("build.hwids")
|
board_hwids = env.BoardConfig().get("build.hwids")
|
||||||
for item in get_serialports():
|
for item in util.get_serialports():
|
||||||
if "VID:PID" not in item['hwid']:
|
if "VID:PID" not in item['hwid']:
|
||||||
continue
|
continue
|
||||||
port = item['port']
|
port = item['port']
|
||||||
@ -142,6 +143,31 @@ def UploadToDisk(_, target, source, env): # pylint: disable=W0613,W0621
|
|||||||
"Please restart your board.")
|
"Please restart your board.")
|
||||||
|
|
||||||
|
|
||||||
|
def CheckUploadSize(env):
|
||||||
|
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
|
||||||
|
|
||||||
|
sysenv = environ.copy()
|
||||||
|
sysenv['PATH'] = str(env['ENV']['PATH'])
|
||||||
|
cmd = [env.subst("$SIZETOOL"), "-B"]
|
||||||
|
cmd.append(env.subst(join("$BUILD_DIR", "$PROGNAME$PROGSUFFIX")))
|
||||||
|
result = util.exec_command(cmd, env=sysenv)
|
||||||
|
if result['returncode'] != 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
|
|
||||||
def exists(_):
|
def exists(_):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -152,4 +178,5 @@ def generate(env):
|
|||||||
env.AddMethod(WaitForNewSerialPort)
|
env.AddMethod(WaitForNewSerialPort)
|
||||||
env.AddMethod(AutodetectUploadPort)
|
env.AddMethod(AutodetectUploadPort)
|
||||||
env.AddMethod(UploadToDisk)
|
env.AddMethod(UploadToDisk)
|
||||||
|
env.AddMethod(CheckUploadSize)
|
||||||
return env
|
return env
|
||||||
|
@ -116,10 +116,11 @@ def ProcessFlags(env, flags):
|
|||||||
env.Append(CPPDEFINES=[flag])
|
env.Append(CPPDEFINES=[flag])
|
||||||
env.Append(**parsed_flags)
|
env.Append(**parsed_flags)
|
||||||
|
|
||||||
# fix relative CPPPATH
|
# fix relative CPPPATH & LIBPATH
|
||||||
for i, p in enumerate(env.get("CPPPATH", [])):
|
for k in ("CPPPATH", "LIBPATH"):
|
||||||
if isdir(p):
|
for i, p in enumerate(env.get(k, [])):
|
||||||
env['CPPPATH'][i] = realpath(p)
|
if isdir(p):
|
||||||
|
env[k][i] = realpath(p)
|
||||||
# fix relative path for "-include"
|
# fix relative path for "-include"
|
||||||
for i, f in enumerate(env.get("CCFLAGS", [])):
|
for i, f in enumerate(env.get("CCFLAGS", [])):
|
||||||
if isinstance(f, tuple) and f[0] == "-include":
|
if isinstance(f, tuple) and f[0] == "-include":
|
||||||
|
Reference in New Issue
Block a user