Improve uploading firmware to mbed-enabled mass storages

This commit is contained in:
Ivan Kravets
2015-03-13 00:02:31 +02:00
parent cd06f3ed43
commit f4c21be953
8 changed files with 47 additions and 38 deletions

View File

@ -1,6 +1,28 @@
Release History Release History
=============== ===============
1.2.0 (2015-03-??)
------------------
* Initial support of `mbed <http://docs.platformio.org/en/latest/frameworks/mbed.html>`__
framework (only core SDK)
* Added `freescalekinetis <http://docs.platformio.org/en/latest/platforms/freescalekinetis.html>`_
development platform with Freescale Kinetis Freedom boards
* Added `nordicnrf51 <http://docs.platformio.org/en/latest/platforms/nordicnrf51.html>`_
development platform with supported boards from *JKSoft, Nordic, RedBearLab,
Switch Science*
* Added `nxplpc <http://docs.platformio.org/en/latest/platforms/nxplpc.html>`_
development platform with supported boards from *CQ Publishing, Embedded
Artists, NGX Technologies, NXP, Outrageous Circuits, SeeedStudio,
Solder Splash Labs, Switch Science, u-blox*
* Added support for *ST Nucleo* boards to
`ststm32 <http://docs.platformio.org/en/latest/platforms/ststm32.html>`__
development platform
* Created new `Frameworks <http://docs.platformio.org/en/latest/frameworks/index.html>`__
page in documentation
* Renamed ``stm32`` development platform to
`ststm32 <http://docs.platformio.org/en/latest/platforms/ststm32.html>`__
1.1.0 (2015-03-05) 1.1.0 (2015-03-05)
------------------ ------------------
@ -31,7 +53,7 @@ Release History
* Added `atmelsam <http://docs.platformio.org/en/latest/platforms/atmelsam.html>`_ * Added `atmelsam <http://docs.platformio.org/en/latest/platforms/atmelsam.html>`_
development platform with supported boards: *Arduino Due and Digistump DigiX* development platform with supported boards: *Arduino Due and Digistump DigiX*
(`issue #71 <https://github.com/ivankravets/platformio/issues/71>`_) (`issue #71 <https://github.com/ivankravets/platformio/issues/71>`_)
* Added `stm32 <http://docs.platformio.org/en/latest/platforms/stm32.html>`_ * Added `ststm32 <http://docs.platformio.org/en/latest/platforms/ststm32.html>`__
development platform with supported boards: *Discovery kit for STM32L151/152, development platform with supported boards: *Discovery kit for STM32L151/152,
STM32F303xx, STM32F407/417 lines* and `libOpenCM3 Framework <http://www.libopencm3.org>`_ STM32F303xx, STM32F407/417 lines* and `libOpenCM3 Framework <http://www.libopencm3.org>`_
(`issue #73 <https://github.com/ivankravets/platformio/issues/73>`_) (`issue #73 <https://github.com/ivankravets/platformio/issues/73>`_)

View File

@ -58,7 +58,7 @@ Contents
installation installation
projectconf projectconf
envvars envvars
platforms/index Platforms & Boards <platforms/index>
frameworks/index frameworks/index
librarymanager/index librarymanager/index
userguide/index userguide/index

View File

@ -31,13 +31,13 @@ framework = mbed
board = nrf51_mkit board = nrf51_mkit
# Freescale FRDM Platform # Freescale FRDM Platform
[env:frdm_k64f] [env:frdm_kl25z]
platform = freescalekinetis platform = freescalekinetis
framework = mbed framework = mbed
board = frdm_k64f board = frdm_kl25z
# ST STM32 Platform # ST STM32 Platform
[env:nucleo_f401re] [env:nucleo_f401re]
platform = ststm32 platform = ststm32
framework = mbed framework = mbed
board = nucleo_f401re board = nucleo_f401re

View File

@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com> # Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details. # See LICENSE for details.
VERSION = (1, 2, "0.dev0") VERSION = (1, 2, "0.dev1")
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@ -6,19 +6,10 @@
""" """
from os.path import join from os.path import join
from shutil import copyfile
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
DefaultEnvironment, SConscript) DefaultEnvironment, SConscript)
def UploadToDisk(target, source, env): # pylint: disable=W0613,W0621
env.AutodetectUploadPort()
copyfile(join(env.subst("$BUILD_DIR"), "firmware.bin"),
join(env.subst("$UPLOAD_PORT"), "firmware.bin"))
print ("Firmware has been successfully uploaded.\n"
"Please restart your board.")
env = DefaultEnvironment() env = DefaultEnvironment()
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
@ -49,7 +40,7 @@ AlwaysBuild(target_size)
# Target: Upload by default .bin file # Target: Upload by default .bin file
# #
upload = env.Alias(["upload", "uploadlazy"], target_firm, UploadToDisk) upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk)
AlwaysBuild(upload) AlwaysBuild(upload)
# #

View File

@ -6,19 +6,10 @@
""" """
from os.path import join from os.path import join
from shutil import copyfile
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
DefaultEnvironment, SConscript) DefaultEnvironment, SConscript)
def UploadToDisk(target, source, env): # pylint: disable=W0613,W0621
env.AutodetectUploadPort()
copyfile(join(env.subst("$BUILD_DIR"), "firmware.bin"),
join(env.subst("$UPLOAD_PORT"), "firmware.bin"))
print ("Firmware has been successfully uploaded.\n"
"Please restart your board.")
env = DefaultEnvironment() env = DefaultEnvironment()
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
@ -49,7 +40,7 @@ AlwaysBuild(target_size)
# Target: Upload by default .bin file # Target: Upload by default .bin file
# #
upload = env.Alias(["upload", "uploadlazy"], target_firm, UploadToDisk) upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk)
AlwaysBuild(upload) AlwaysBuild(upload)
# #

View File

@ -6,19 +6,10 @@
""" """
from os.path import join from os.path import join
from shutil import copyfile
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
DefaultEnvironment, SConscript) DefaultEnvironment, SConscript)
def UploadToDisk(target, source, env): # pylint: disable=W0613,W0621
env.AutodetectUploadPort()
copyfile(join(env.subst("$BUILD_DIR"), "firmware.bin"),
join(env.subst("$UPLOAD_PORT"), "firmware.bin"))
print ("Firmware has been successfully uploaded.\n"
"Please restart your board.")
env = DefaultEnvironment() env = DefaultEnvironment()
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
@ -73,7 +64,8 @@ AlwaysBuild(target_size)
# #
if "mbed" in env.subst("$FRAMEWORK"): if "mbed" in env.subst("$FRAMEWORK"):
upload = env.Alias(["upload", "uploadlazy"], target_firm, UploadToDisk) upload = env.Alias(["upload", "uploadlazy"],
target_firm, env.UploadToDisk)
else: else:
upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD")
AlwaysBuild(upload) AlwaysBuild(upload)

View File

@ -2,6 +2,8 @@
# See LICENSE for details. # See LICENSE for details.
import platform import platform
from os.path import join
from shutil import copyfile
from time import sleep from time import sleep
from SCons.Script import Exit from SCons.Script import Exit
@ -56,10 +58,12 @@ def AutodetectUploadPort(env):
return return
if env.subst("$FRAMEWORK") == "mbed": if env.subst("$FRAMEWORK") == "mbed":
msdlabels = ("mbed", "nucleo", "frdm")
for item in get_logicaldisks(): for item in get_logicaldisks():
if not item['name'] or "mbed" != item['name'].lower(): if (not item['name'] or
not any([l in item['name'].lower() for l in msdlabels])):
continue continue
print "Auto-detected UPLOAD_PORT: %s" % item['disk'] print "Auto-detected UPLOAD_PORT/DISK: %s" % item['disk']
env.Replace(UPLOAD_PORT=item['disk']) env.Replace(UPLOAD_PORT=item['disk'])
break break
else: else:
@ -76,6 +80,14 @@ def AutodetectUploadPort(env):
"For the some development platforms it can be USB flash drive\n") "For the some development platforms it can be USB flash drive\n")
def UploadToDisk(_, target, source, env): # pylint: disable=W0613,W0621
env.AutodetectUploadPort()
copyfile(join(env.subst("$BUILD_DIR"), "firmware.bin"),
join(env.subst("$UPLOAD_PORT"), "firmware.bin"))
print ("Firmware has been successfully uploaded.\n"
"Please restart your board.")
def exists(_): def exists(_):
return True return True
@ -85,4 +97,5 @@ def generate(env):
env.AddMethod(TouchSerialPort) env.AddMethod(TouchSerialPort)
env.AddMethod(WaitForNewSerialPort) env.AddMethod(WaitForNewSerialPort)
env.AddMethod(AutodetectUploadPort) env.AddMethod(AutodetectUploadPort)
env.AddMethod(UploadToDisk)
return env return env