How would I go about doing this? Whatâs the process? Has it been documented somewhere? Itâs a little confusing between boards, platforms, libraries and frameworksâŚ
The clostest thing to developer documentation youâll see is probably my post. The PlatformIO-side documentation on self-developing integrations for new platforms / frameworks is lacking in my eyes, not covering it from start-to-finish in enough detail. Things like modifying existing platforms or logic is also not covered.
You may also look at similiar work as e.g. done in
@maxgerhardt after reading your documentation I tried tinkering with the atmelsam package to get the new framework to work (locally), but Iâm getting a bunch of errors:
KeyError: "Invalid board option 'build.core'":
File "/Users/stephanemuller/.platformio/penv/lib/python3.8/site-packages/platformio/builder/main.py", line 181:
env.SConscript("$BUILD_SCRIPT")
File "/Users/stephanemuller/.platformio/packages/tool-scons/scons-local-4.3.0/SCons/Script/SConscript.py", line 597:
return _SConscript(self.fs, *files, **subst_kw)
File "/Users/stephanemuller/.platformio/packages/tool-scons/scons-local-4.3.0/SCons/Script/SConscript.py", line 285:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/Users/stephanemuller/.platformio/platforms/atmelsam/builder/main.py", line 220:
if board.get("build.core") in ("adafruit", "seeed", "sparkfun") and board.get(
File "/Users/stephanemuller/.platformio/penv/lib/python3.8/site-packages/platformio/platform/board.py", line 46:
raise KeyError("Invalid board option '%s'" % path)
Iâm guessing everything stems from the first one env.SConscript("$BUILD_SCRIPT") and more specifically from the builder process Iâve tried to tweak, but I donât know where to look. Do you have a suggestion or an idea?
Oh, yes indeed! Ok, fixed that.
Now itâs telling me it canât find Arduino.h⌠Thatâs weird⌠Itâs seeing the fabsam framework alright, even the variant shows up. And in VS the include is not even underlined.
Processing samd11c14a (platform: atmelsam; board: samd11c14a)
--------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/samd11c14a.html
PLATFORM: Atmel SAM (7.1.0) > Generic Atmel SAMD11C14A
HARDWARE: FABSAMD11C14A 20MHz, 32KB RAM, 256KB Flash
DEBUG: Current (cmsis-dap) On-board (cmsis-dap) External (atmel-ice)
PACKAGES:
- framework-arduino-fabsam 1.8.3
- tool-bossac 1.10700.190624 (1.7.0)
- toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/samd11c14a/src/main.o
src/main.cpp:1:10: fatal error: Arduino.h: No such file or directory
The next problem youâll have is, now that youâve created framework-arduino-fabsam, is the builder script for it. That is, the piece of Python code that tells PlatformIO (aka SCons) where do find all needed header and source files and how to build them, like the original Arduino core would through the settings declared in its platform.txt and boards.txt.
Not finding Arduino.h has to do with the fact that the include path
is added.
For your core Arduino.h is in cores/arduino/Arduino.h. The logic above would add cores/BUILD_CORE with BUILD_CORE having the value arduino, so that is correct, but the problem is that FRAMEWORK_DIR wold be wrongly computed since itâs looking for framework-arduino-samd-<build.core value from JSON file>, but you named it framework-arduino-fabsam.
Eitehr fork the platform-atmelsam repository and correct this arduino-samd.py logic (because possibly more adapations are needed?) and refer to its Git link with platform = <git link here> in the platformio.ini or rename your framework package.
Hm on second thought, itâs checking that all directories exist
so the fault might be somewhere else. You can insert print statements into the builder scripts (if using the default, C:\Users\<user>\.platformio\platforms\atmelsam\builder\frameworks\arduino\arduino-samd.py) and see what paths it is appending.
Will do it more cleanly once it works, but it still wonât⌠I think this should work but for some reason I have the feeling itâs not getting all the way where I want it.
Thatâs missing a LIBPATH (folder(s) where .a static libraries can be found that are referred to in LIBS) and LINKFLAGS (linker invocation flags) closing ) at least.
Whatâs weird here is that you donât specificy a source for it with @ <source> at the end? Like @ file://<some path> or @ <git repo link>. Or does it then really source it from the existing C:\Users\<user>\.platformio\packages\framework-arduino-fabsam folder?
Because, as I understand it, it will check the atmelsam package and since Iâve chosen the arduino framework, it should launch arduino.py and in turn arduino-fabsam.py.
I have also copied the arduino-samd.py, renamed it arduino-fabsam.py and basically just changed the framework_package. There might be other things to change, but one thing at a timeâŚ
Ok, so I renamed the directory framework-arduino-samd-fabsam and all references to it. Turns out I had forgotten to add the framework to the platform.json as well.
But now I have this error:
Tool Manager: Installing platformio/framework-arduino-samd-fabsam @ ~1.8.3
Error: Could not find the package with 'platformio/framework-arduino-samd-fabsam @ ~1.8.3' requirements for your system 'darwin_x86_64
It never ends⌠How come it doesnât find the directory when itâs in the .platformio/packages directory already?
You should upload the framework-arduino-samd-fabsam to a Git(hub) repo and put that in as the version for the package inside the platform.json, then it should have no problems installing it.
I pushed the package.json the the git repo of the framework so we should be good now. And yet⌠the error message stays the same. It canât find the reference to the framework. Itâs not getting past the platform.json I think.
It looks like itâs looking at the root of the platformio directory, is that normal?
Itâs weird because when I try to open each files itâs saying it canât find them (although they exist)⌠From the kind of errors my guess would be that it canât find the CMSIS framework with all the register definitions, but in the build/arduino/arduino-samd-fabsam.py the framework is still defined:
import os
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
platform = env.PioPlatform()
board = env.BoardConfig()
VENDOR_CORE = board.get("build.core", "").lower()
framework_package = "framework-arduino-samd-fabsam"
FRAMEWORK_DIR = platform.get_package_dir(framework_package)
CMSIS_DIR = platform.get_package_dir("framework-cmsis")
CMSIS_ATMEL_DIR = platform.get_package_dir("framework-cmsis-atmel")
assert all(os.path.isdir(d) for d in (FRAMEWORK_DIR, CMSIS_DIR, CMSIS_ATMEL_DIR))