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:
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
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)
- 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
Building in release mode
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
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.
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?
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?
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:
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))