Teensy development platform for PlatformIO compatible with GCC10 & C++20
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

92 Zeilen
3.5KB

  1. # Copyright 2014-present PlatformIO <contact@platformio.org>
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from platform import system
  15. from platformio.managers.platform import PlatformBase
  16. class TeensygccPlatform(PlatformBase):
  17. def configure_default_packages(self, variables, targets):
  18. if variables.get("board"):
  19. board_config = self.board_config(variables.get("board"))
  20. del_toolchain = "toolchain-gcc-arm-embedded"
  21. if board_config.get("build.core") != "teensy":
  22. del_toolchain = "toolchain-atmelavr"
  23. if del_toolchain in self.packages:
  24. del self.packages[del_toolchain]
  25. if "mbed" in variables.get("pioframework", []):
  26. self.packages["toolchain-gccarmnoneeabi"][
  27. 'version'] = ">=1.60301.0,<1.80000.0"
  28. # configure J-LINK tool
  29. jlink_conds = [
  30. "jlink" in variables.get(option, "")
  31. for option in ("upload_protocol", "debug_tool")
  32. ]
  33. if variables.get("board"):
  34. board_config = self.board_config(variables.get("board"))
  35. jlink_conds.extend([
  36. "jlink" in board_config.get(key, "")
  37. for key in ("debug.default_tools", "upload.protocol")
  38. ])
  39. jlink_pkgname = "tool-jlink"
  40. if not any(jlink_conds) and jlink_pkgname in self.packages:
  41. del self.packages[jlink_pkgname]
  42. return PlatformBase.configure_default_packages(
  43. self, variables, targets)
  44. def get_boards(self, id_=None):
  45. result = PlatformBase.get_boards(self, id_)
  46. if not result:
  47. return result
  48. if id_:
  49. return self._add_default_debug_tools(result)
  50. else:
  51. for key, value in result.items():
  52. result[key] = self._add_default_debug_tools(result[key])
  53. return result
  54. def _add_default_debug_tools(self, board):
  55. debug = board.manifest.get("debug", {})
  56. upload_protocols = board.manifest.get("upload", {}).get(
  57. "protocols", [])
  58. if "tools" not in debug:
  59. debug['tools'] = {}
  60. if "jlink" in upload_protocols and "jlink" not in debug['tools']:
  61. assert debug.get("jlink_device"), (
  62. "Missed J-Link Device ID for %s" % board.id)
  63. debug['tools']['jlink'] = {
  64. "server": {
  65. "package": "tool-jlink",
  66. "arguments": [
  67. "-singlerun",
  68. "-if", "SWD",
  69. "-select", "USB",
  70. "-device", debug.get("jlink_device"),
  71. "-port", "2331"
  72. ],
  73. "executable": ("JLinkGDBServerCL.exe"
  74. if system() == "Windows" else
  75. "JLinkGDBServer")
  76. }
  77. }
  78. board.manifest['debug'] = debug
  79. return board