Fork a framework?

I’m happily building things for my Adafruit Feather M4, using the standard PlatformIO packages:

[env]
platform = atmelsam
board = adafruit_feather_m4
framework = arduino
build_flags =
	-D USE_TINYUSB
	-D SH110X_NO_SPLASH
lib_deps =
	adafruit/Adafruit SH110X@^2.1.14
	pharap/FixedPoints@^1.1.2

I’d like to do some development work on Adafruit’s core for SAMD, by forking their repo locally and tinkering with the code. (I have improvements to wiring.cpp and reset.cpp…)

I though I could add something like this:

platform_packages =
  framework-arduino-samd-adafruit @ ~/projects/framework-samd-fork

But,

  1. I can’t seem to get PlatformIO configuration to recognize the local repo

  2. PlatformIO seems to want to clone it… where will it go? will it keep it separate from the official one? Can I keep it from doing that - I’d rather it work right out of the repo (so I can test changes I’m making easily.)

  3. ~/.platformio/packages/framework-arduino-samd-adafruit/ contains an extra file: package.json that isn’t in the source repo… Where does this file come from? Do I need to create it and put it… where?

Better use

platform_packages =
  framework-arduino-samd-adafruit @ symlink://~/projects/framework-samd-fork

to avoid PlatformIO copying it into ~/.platformio/packages/framework-arduino-samd-adafruit. See docs

PlatformIO will reject to use a new framework package if it does not have a package.json in it. You absolutely need it. And yes, as a base you can just use the current ~/.platformio/packages/framework-arduino-samd-adafruit/ and then just change the value of the version field.

1 Like

Thank you! That worked, though I couldn’t get ~ to work as part of the path, so I just put in the whole absolute path.

Since package.json isn’t part of the original repo… I’m just wondering where those get created and archived. Is this just some magic with the PlatformIO package system? I had no problem copying it into my tree… though I now have a file there that git doesn’t control.

The package.json are usually created by hand by the one creating and uploading a package. I see that in the documentation, the package.json isn’t clearly documented, there is a schema file though.The highly related library.json is documented, and it shares many fields. Though really, a “name” and “version” field are usually enough. I recommend to always look at existing package.json files from frameworks like