From 56666262423e63ca19b7241a70b5e945e4da6253 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 15 Mar 2021 13:08:46 +0800 Subject: [PATCH 1/3] Add early support for framework-portduino --- boards/native.json | 15 +++++ builder/frameworks/arduino.py | 112 ++++++++++++++++++++++++++++++++++ platform.json | 13 ++++ 3 files changed, 140 insertions(+) create mode 100644 boards/native.json create mode 100644 builder/frameworks/arduino.py diff --git a/boards/native.json b/boards/native.json new file mode 100644 index 0000000..b0a2160 --- /dev/null +++ b/boards/native.json @@ -0,0 +1,15 @@ +{ + "build": { + "core": "FIXMECORE", + "extra_flags": "-DFIXMEFLAG", + "variant": "native" + }, + "upload": { + "maximum_ram_size": 99999999, + "maximum_size": 99999999 + }, + "frameworks": ["arduino"], + "name": "Portduino", + "url": "https://github.com/geeksville/framework-portduino", + "vendor": "Geeksville Industries, LLC" +} diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py new file mode 100644 index 0000000..2c00ce6 --- /dev/null +++ b/builder/frameworks/arduino.py @@ -0,0 +1,112 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Arduino + +Arduino Wiring-based Framework allows writing cross-platform software to +control devices attached to a wide range of Arduino boards to create all +kinds of creative coding, interactive objects, spaces or physical experiences. + +http://arduino.cc/en/Reference/HomePage +""" + +import os + +from SCons.Script import DefaultEnvironment + +env = DefaultEnvironment() +platform = env.PioPlatform() +board = env.BoardConfig() +core = board.get("build.core") + +FRAMEWORK_DIR = platform.get_package_dir("framework-portduino") +assert os.path.isdir(FRAMEWORK_DIR) + +env.Append( + CPPDEFINES=[ + ("ARDUINO", 4403), # FIXME, find how these numbers are assigned! + "PORTDUINO" # FIXME, should we use some different convention? + # ("CONFIG_MANUFACTURER", '\\"ASR\\"'), + # ("CONFIG_DEVICE_MODEL", '\\"6501\\"'), + # ("CONFIG_VERSION", '\\"v4.0\\"'), + ], + + CCFLAGS=[ + "-w", + "-Wall", + "-ggdb" + ], + + CXXFLAGS=[ + # "-fno-exceptions", + ], + + LINKFLAGS=[ + "-ggdb" + ], + + CPPPATH=[ + os.path.join(FRAMEWORK_DIR, "cores", "portduino"), + os.path.join(FRAMEWORK_DIR, "cores", "portduino", "FS"), + os.path.join(FRAMEWORK_DIR, "cores", "arduino", "api") + # os.path.join(FRAMEWORK_DIR, "cores", core), + # os.path.join(FRAMEWORK_DIR, "cores", core, "cores"), + # os.path.join(FRAMEWORK_DIR, "cores", core, "Serial"), + # os.path.join(FRAMEWORK_DIR, "cores", core, "Wire"), + # os.path.join(FRAMEWORK_DIR, "cores", core, "SPI"), + ], + + LIBS=[ + "stdc++", + "m", + "psocksxx" + ], + + LIBSOURCE_DIRS=[ + os.path.join(FRAMEWORK_DIR, "libraries") + ] +) + +# +# Target: Build Core Library +# + +libs = [] + +if "build.variant" in env.BoardConfig(): + variants_dir = os.path.join( + "$PROJECT_DIR", board.get("build.variants_dir")) if board.get( + "build.variants_dir", "") else os.path.join(FRAMEWORK_DIR, "variants") + env.Append( + CPPPATH=[ + os.path.join(variants_dir, board.get("build.variant")) + ] + ) + libs.append(env.BuildLibrary( + os.path.join("$BUILD_DIR", "FrameworkArduinoVariant"), + os.path.join(variants_dir, board.get("build.variant")) + )) + +libs.append(env.BuildLibrary( + os.path.join("$BUILD_DIR", "FrameworkArduino"), + os.path.join(FRAMEWORK_DIR, "cores"), + src_filter=[ + "+<*>", + "-<%s/projects/PSoC4/CyBootAsmIar.s>" % core, + "-<%s/projects/PSoC4/CyBootAsmRv.s>" % core + ] +)) + +env.Prepend(LIBS=libs) diff --git a/platform.json b/platform.json index ce5ed6c..cf474e0 100644 --- a/platform.json +++ b/platform.json @@ -12,6 +12,19 @@ "engines": { "platformio": "^5" }, + "packages": { + "framework-portduino": { + "type": "framework", + "version": "https://github.com/geeksville/framework-portduino.git", + "optional": true + } + }, + "frameworks": { + "arduino": { + "package": "framework-portduino", + "script": "builder/frameworks/arduino.py" + } + }, "repository": { "type": "git", "url": "https://github.com/platformio/platform-native.git" From 2cba543e1f6d8b5f6c046fdf88ef74c7e6311719 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Fri, 2 Apr 2021 13:53:17 +0800 Subject: [PATCH 2/3] remove psocks dependency --- builder/frameworks/arduino.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 2c00ce6..b0b55a6 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -70,8 +70,7 @@ LIBS=[ "stdc++", - "m", - "psocksxx" + "m" ], LIBSOURCE_DIRS=[ From 220bf37041b3433fca47bd2c1e734435d33d3905 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 23 May 2021 17:49:19 +0800 Subject: [PATCH 3/3] make a platform that is for simulation vs one that includes linux hw access --- boards/{native.json => cross_platform.json} | 2 +- boards/linux_hardware.json | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) rename boards/{native.json => cross_platform.json} (86%) create mode 100644 boards/linux_hardware.json diff --git a/boards/native.json b/boards/cross_platform.json similarity index 86% rename from boards/native.json rename to boards/cross_platform.json index b0a2160..c654e45 100644 --- a/boards/native.json +++ b/boards/cross_platform.json @@ -1,7 +1,7 @@ { "build": { "core": "FIXMECORE", - "extra_flags": "-DFIXMEFLAG", + "extra_flags": "-DPORTDUINO_CROSSPLATFORM", "variant": "native" }, "upload": { diff --git a/boards/linux_hardware.json b/boards/linux_hardware.json new file mode 100644 index 0000000..282c3b5 --- /dev/null +++ b/boards/linux_hardware.json @@ -0,0 +1,15 @@ +{ + "build": { + "core": "FIXMECORE", + "extra_flags": "-DPORTDUINO_LINUX_HARDWARE", + "variant": "native" + }, + "upload": { + "maximum_ram_size": 99999999, + "maximum_size": 99999999 + }, + "frameworks": ["arduino"], + "name": "Portduino", + "url": "https://github.com/geeksville/framework-portduino", + "vendor": "Geeksville Industries, LLC" +}