Skip to content

Commit

Permalink
Add compatibility with PIO Core 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed May 27, 2022
1 parent b5dbf48 commit f067645
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 55 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.7]
example:
- "examples/arduino-blink"
- "examples/arduino-briki-internal-libs"
Expand All @@ -24,16 +23,15 @@ jobs:
- "examples/zephyr-subsys-logger"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U https://github.com/platformio/platformio/archive/develop.zip
pio pkg install --global --platform symlink://.
- name: Build examples
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Atmel SAM: development platform for [PlatformIO](http://platformio.org)
# Atmel SAM: development platform for [PlatformIO](https://platformio.org)

[![Build Status](https://github.com/platformio/platform-atmelsam/workflows/Examples/badge.svg)](https://github.com/platformio/platform-atmelsam/actions)

Expand All @@ -9,7 +9,7 @@ Atmel | SMART offers Flash- based ARM products based on the ARM Cortex-M0+, Cort

# Usage

1. [Install PlatformIO](http://platformio.org)
1. [Install PlatformIO](https://platformio.org)
2. Create PlatformIO project and configure a platform option in [platformio.ini](https://docs.platformio.org/page/projectconf.html) file:

## Stable version
Expand Down
4 changes: 2 additions & 2 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from SCons.Script import (ARGUMENTS, COMMAND_LINE_TARGETS, AlwaysBuild,
Builder, Default, DefaultEnvironment)

from platformio.util import get_serial_ports
from platformio.public import list_serial_ports


def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
Expand All @@ -33,7 +33,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
if not bool(upload_options.get("disable_flushing", False)):
env.FlushSerialBuffer("$UPLOAD_PORT")

before_ports = get_serial_ports()
before_ports = list_serial_ports()

if bool(upload_options.get("use_1200bps_touch", False)):
env.TouchSerialPort("$UPLOAD_PORT", 1200)
Expand Down
2 changes: 1 addition & 1 deletion platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"SAM D"
],
"engines": {
"platformio": "^5"
"platformio": "^6"
},
"repository": {
"type": "git",
Expand Down
99 changes: 55 additions & 44 deletions platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from copy import deepcopy
from platform import system
import sys

from platformio.managers.platform import PlatformBase
from platformio.util import get_systype
from platformio.public import PlatformBase

IS_WINDOWS = sys.platform.startswith("win")

class AtmelsamPlatform(PlatformBase):

class AtmelsamPlatform(PlatformBase):
def configure_default_packages(self, variables, targets):
if not variables.get("board"):
return PlatformBase.configure_default_packages(
self, variables, targets)
return super().configure_default_packages(variables, targets)
board = self.board_config(variables.get("board"))
upload_protocol = variables.get("upload_protocol",
board.get("upload.protocol", ""))
upload_protocol = variables.get(
"upload_protocol", board.get("upload.protocol", "")
)
disabled_pkgs = []
upload_tool = "tool-openocd"
if upload_protocol == "sam-ba":
Expand All @@ -47,12 +46,14 @@ def configure_default_packages(self, variables, targets):
disabled_pkgs.append(name)

build_core = variables.get(
"board_build.core", self.board_config(variables.get("board")).get(
"build.core", "arduino")).lower()
"board_build.core",
self.board_config(variables.get("board")).get("build.core", "arduino"),
).lower()

if "arduino" in variables.get("pioframework", []):
framework_package = "framework-arduino-%s" % (
"sam" if board.get("build.mcu", "").startswith("at91") else "samd")
"sam" if board.get("build.mcu", "").startswith("at91") else "samd"
)

if build_core != "arduino":
framework_package += "-" + build_core
Expand All @@ -77,42 +78,44 @@ def configure_default_packages(self, variables, targets):

if "mbed" in variables.get("pioframework", []):
self.packages["toolchain-gccarmnoneeabi"][
"version"] = ">=1.60301.0,<1.80000.0"
"version"
] = ">=1.60301.0,<1.80000.0"
if "simba" in variables.get("pioframework", []):
self.packages["toolchain-gccarmnoneeabi"][
"version"] = ">=1.40803.0,<1.40805.0"
if (board.get("build.core", "") in ("adafruit", "seeed", "sparkfun")
and "tool-bossac" in self.packages
and board.get("build.mcu", "").startswith(("samd51", "same51"))):
"version"
] = ">=1.40803.0,<1.40805.0"
if (
board.get("build.core", "") in ("adafruit", "seeed", "sparkfun")
and "tool-bossac" in self.packages
and board.get("build.mcu", "").startswith(("samd51", "same51"))
):
self.packages["tool-bossac"]["version"] = "~1.10900.0"
if "zephyr" in variables.get("pioframework", []):
for p in self.packages:
if p in ("tool-cmake", "tool-dtc", "tool-ninja"):
self.packages[p]["optional"] = False
self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.80201.0"
if "windows" not in get_systype():
if not IS_WINDOWS:
self.packages["tool-gperf"]["optional"] = False

for name in disabled_pkgs:
del self.packages[name]
return PlatformBase.configure_default_packages(self, variables,
targets)
return super().configure_default_packages(variables, targets)

def get_boards(self, id_=None):
result = PlatformBase.get_boards(self, id_)
result = super().get_boards(id_)
if not result:
return result
if id_:
return self._add_default_debug_tools(result)
else:
for key, value in result.items():
for key in result:
result[key] = self._add_default_debug_tools(result[key])
return result

def _add_default_debug_tools(self, board):
debug = board.manifest.get("debug", {})
upload_protocols = board.manifest.get("upload", {}).get(
"protocols", [])
upload_protocols = board.manifest.get("upload", {}).get("protocols", [])
if "tools" not in debug:
debug["tools"] = {}

Expand All @@ -124,27 +127,34 @@ def _add_default_debug_tools(self, board):
if link == "blackmagic":
debug["tools"]["blackmagic"] = {
"hwids": [["0x1d50", "0x6018"]],
"require_debug_port": True
"require_debug_port": True,
}

elif link == "jlink":
assert debug.get("jlink_device"), (
"Missed J-Link Device ID for %s" % board.id)
"Missed J-Link Device ID for %s" % board.id
)
debug["tools"][link] = {
"server": {
"package": "tool-jlink",
"arguments": [
"-singlerun",
"-if", "SWD",
"-select", "USB",
"-device", debug.get("jlink_device"),
"-port", "2331"
"-if",
"SWD",
"-select",
"USB",
"-device",
debug.get("jlink_device"),
"-port",
"2331",
],
"executable": ("JLinkGDBServerCL.exe"
if system() == "Windows" else
"JLinkGDBServer")
"executable": (
"JLinkGDBServerCL.exe"
if system() == "Windows"
else "JLinkGDBServer"
),
},
"onboard": link in debug.get("onboard_tools", [])
"onboard": link in debug.get("onboard_tools", []),
}

else:
Expand All @@ -154,19 +164,22 @@ def _add_default_debug_tools(self, board):
if link == "stlink" and "at91sam3" in openocd_chipname:
openocd_cmds.append("set CPUTAPID 0x2ba01477")
server_args = [
"-s", "$PACKAGE_DIR/scripts",
"-f", "interface/%s.cfg" % (
"cmsis-dap" if link == "atmel-ice" else link),
"-c", "; ".join(openocd_cmds),
"-f", "target/%s.cfg" % debug.get("openocd_target")
"-s",
"$PACKAGE_DIR/scripts",
"-f",
"interface/%s.cfg" % ("cmsis-dap" if link == "atmel-ice" else link),
"-c",
"; ".join(openocd_cmds),
"-f",
"target/%s.cfg" % debug.get("openocd_target"),
]
debug["tools"][link] = {
"server": {
"package": "tool-openocd",
"executable": "bin/openocd",
"arguments": server_args
"arguments": server_args,
},
"onboard": link in debug.get("onboard_tools", [])
"onboard": link in debug.get("onboard_tools", []),
}
if link == "stlink":
debug["tools"][link]["load_cmd"] = "preload"
Expand All @@ -185,8 +198,6 @@ def configure_debug_options(self, initial_debug_options, ide_data):
["-c", "adapter speed %s" % adapter_speed]
)
elif "jlink" in server_executable:
debug_options["server"]["arguments"].extend(
["-speed", adapter_speed]
)
debug_options["server"]["arguments"].extend(["-speed", adapter_speed])

return debug_options

0 comments on commit f067645

Please sign in to comment.