mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Merge Digistump platform to "atmelavr" and "atmelsam"
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
},
|
||||
"framework": "arduino",
|
||||
"name": "Digispark (Default - 16.5mhz)",
|
||||
"platform": "digistump",
|
||||
"platform": "atmelavr",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 512,
|
||||
@ -29,7 +29,7 @@
|
||||
},
|
||||
"framework": "arduino",
|
||||
"name": "Digispark Pro (Default 16 Mhz)",
|
||||
"platform": "digistump",
|
||||
"platform": "atmelavr",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 512,
|
||||
@ -49,7 +49,7 @@
|
||||
},
|
||||
"framework": "arduino",
|
||||
"name": "Digispark Pro (16 Mhz) (32 byte buffer)",
|
||||
"platform": "digistump",
|
||||
"platform": "atmelavr",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 512,
|
||||
@ -69,7 +69,7 @@
|
||||
},
|
||||
"framework": "arduino",
|
||||
"name": "Digispark Pro (16 Mhz) (64 byte buffer)",
|
||||
"platform": "digistump",
|
||||
"platform": "atmelavr",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 512,
|
||||
@ -94,7 +94,7 @@
|
||||
},
|
||||
"framework": "arduino",
|
||||
"name": "Digistump DigiX",
|
||||
"platform": "digistump",
|
||||
"platform": "atmelsam",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 28672,
|
||||
|
@ -57,20 +57,31 @@ env = DefaultEnvironment()
|
||||
|
||||
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "baseavr.py")))
|
||||
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"),
|
||||
UPLOADERFLAGS=[
|
||||
"-v",
|
||||
"-D", # disable auto erase for flash memory
|
||||
"-p", "$BOARD_MCU",
|
||||
"-C",
|
||||
'"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"),
|
||||
"-c", "$UPLOAD_PROTOCOL"
|
||||
],
|
||||
if "digispark" in env.get("BOARD_OPTIONS", {}).get("build", {}).get("core", ""):
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-micronucleus", "micronucleus"),
|
||||
UPLOADERFLAGS=[
|
||||
"-c", "$UPLOAD_PROTOCOL",
|
||||
"--timeout", "60"
|
||||
],
|
||||
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i'
|
||||
)
|
||||
|
||||
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i',
|
||||
UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i'
|
||||
)
|
||||
else:
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"),
|
||||
UPLOADERFLAGS=[
|
||||
"-v",
|
||||
"-D", # disable auto erase for flash memory
|
||||
"-p", "$BOARD_MCU",
|
||||
"-C",
|
||||
'"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"),
|
||||
"-c", "$UPLOAD_PROTOCOL"
|
||||
],
|
||||
|
||||
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i',
|
||||
UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i'
|
||||
)
|
||||
|
||||
CORELIBS = env.ProcessGeneral()
|
||||
|
||||
|
@ -1,103 +0,0 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Builder for Digistump boards
|
||||
"""
|
||||
|
||||
from os.path import join
|
||||
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||
DefaultEnvironment, SConscript)
|
||||
|
||||
|
||||
def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
|
||||
if "cortex" in env.get("BOARD_OPTIONS").get("build").get("cpu"):
|
||||
env.AutodetectUploadPort()
|
||||
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
||||
if "cortex" in env.get("BOARD_OPTIONS", {}).get("build", {}).get("cpu", ""):
|
||||
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
|
||||
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"),
|
||||
UPLOADERFLAGS=[
|
||||
"--info",
|
||||
"--debug",
|
||||
"--port", "$UPLOAD_PORT",
|
||||
"--erase",
|
||||
"--write",
|
||||
"--verify",
|
||||
"--boot",
|
||||
"--reset"
|
||||
],
|
||||
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
|
||||
)
|
||||
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
"printf=iprintf"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Wl,--entry=Reset_Handler",
|
||||
"-Wl,--start-group"
|
||||
]
|
||||
)
|
||||
else:
|
||||
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "baseavr.py")))
|
||||
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-micronucleus", "micronucleus"),
|
||||
UPLOADERFLAGS=[
|
||||
"-c", "$UPLOAD_PROTOCOL",
|
||||
"--timeout", "60"
|
||||
],
|
||||
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i'
|
||||
)
|
||||
|
||||
CORELIBS = env.ProcessGeneral()
|
||||
|
||||
#
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildFirmware(["m"] + CORELIBS)
|
||||
|
||||
#
|
||||
# Target: Build the firmware file
|
||||
#
|
||||
|
||||
if "cortex" in env.get("BOARD_OPTIONS", {}).get("build", {}).get("cpu", ""):
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_firm = join("$BUILD_DIR", "firmware.bin")
|
||||
else:
|
||||
target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
else:
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_firm = join("$BUILD_DIR", "firmware.hex")
|
||||
else:
|
||||
target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Print binary size
|
||||
#
|
||||
|
||||
target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD")
|
||||
AlwaysBuild(target_size)
|
||||
|
||||
#
|
||||
# Target: Upload by default firmware file
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_firm,
|
||||
[BeforeUpload, "$UPLOADCMD"])
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
Default([target_firm, target_size])
|
@ -2,9 +2,11 @@
|
||||
# See LICENSE for details.
|
||||
|
||||
from platformio.platforms.base import BasePlatform
|
||||
from platformio.util import get_boards
|
||||
|
||||
|
||||
class AtmelavrPlatform(BasePlatform):
|
||||
|
||||
"""
|
||||
An embedded platform for Atmel AVR microcontrollers
|
||||
(with Arduino Framework)
|
||||
@ -18,7 +20,10 @@ class AtmelavrPlatform(BasePlatform):
|
||||
},
|
||||
|
||||
"tool-avrdude": {
|
||||
"alias": "uploader",
|
||||
"default": True
|
||||
},
|
||||
|
||||
"tool-micronucleus": {
|
||||
"default": True
|
||||
},
|
||||
|
||||
@ -33,3 +38,16 @@ class AtmelavrPlatform(BasePlatform):
|
||||
self.on_run_out(line)
|
||||
else:
|
||||
BasePlatform.on_run_err(self, line)
|
||||
|
||||
def run(self, variables, targets):
|
||||
for v in variables:
|
||||
if "BOARD=" not in v:
|
||||
continue
|
||||
tuploader = "tool-avrdude"
|
||||
_, board = v.split("=")
|
||||
bdata = get_boards(board)
|
||||
if "digispark" in bdata['build']['core']:
|
||||
tuploader = "tool-micronucleus"
|
||||
self.PACKAGES[tuploader]['alias'] = "uploader"
|
||||
break
|
||||
return BasePlatform.run(self, variables, targets)
|
||||
|
@ -1,61 +0,0 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from platformio.platforms.base import BasePlatform
|
||||
from platformio.util import get_boards
|
||||
|
||||
|
||||
class DigistumpPlatform(BasePlatform):
|
||||
|
||||
"""
|
||||
An embedded platform for Digistump boards
|
||||
(with Arduino Framework)
|
||||
"""
|
||||
|
||||
PACKAGES = {
|
||||
|
||||
"toolchain-atmelavr": {
|
||||
"default": True
|
||||
},
|
||||
|
||||
"toolchain-gccarmnoneeabi": {
|
||||
"default": True
|
||||
},
|
||||
|
||||
"ldscripts": {
|
||||
"default": True
|
||||
},
|
||||
|
||||
"tool-bossac": {
|
||||
"default": True
|
||||
},
|
||||
|
||||
"tool-micronucleus": {
|
||||
"default": True
|
||||
},
|
||||
|
||||
"framework-arduinoavr": {
|
||||
"default": True
|
||||
},
|
||||
|
||||
"framework-arduinosam": {
|
||||
"default": True
|
||||
}
|
||||
}
|
||||
|
||||
def run(self, variables, targets):
|
||||
for v in variables:
|
||||
if "BOARD=" not in v:
|
||||
continue
|
||||
_, board = v.split("=")
|
||||
bdata = get_boards(board)
|
||||
if "cpu" in bdata['build']:
|
||||
tpackage = "toolchain-gccarmnoneeabi"
|
||||
tuploader = "tool-bossac"
|
||||
else:
|
||||
tpackage = "toolchain-atmelavr"
|
||||
tuploader = "tool-micronucleus"
|
||||
self.PACKAGES[tpackage]['alias'] = "toolchain"
|
||||
self.PACKAGES[tuploader]['alias'] = "uploader"
|
||||
break
|
||||
return BasePlatform.run(self, variables, targets)
|
@ -19,4 +19,4 @@ def test_search_json_output(clirunner, validate_cliresult):
|
||||
def test_search_raw_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli, ["arduino"])
|
||||
validate_cliresult(result)
|
||||
assert "digistump" in result.output
|
||||
assert "teensy" in result.output
|
||||
|
Reference in New Issue
Block a user