I’ve had some good success using the platform_packages directive in platformio.ini to use a customized version of the framework-arduino-samd-adafruit package for a custom board I’m working on. That board has two SAMD51 CPUs on it, and I’ve got the platformio.ini set up with two environments which overwrite the default package from a local .zip file for each CPU, and platformIO is clever enough to overwrite the package from the zip file when I switch environments.
The problem I now face is that if I switch to an unrelated workspace & project, the custom library is still sitting in my C:\Users\Chris.platformio\packages folder, and that project doesn’t notice that it’s a customized library and fails to build. Is there a way for PlatformIO to automagically restore the default package? I’d like my custom workspace to not break other builds, particularly for other people in the company who might have any number of other workspaces & projects. My initial thought is to maybe have a post_build step which deletes the custom platform after every build, but that seems a bit slow and clunky.
My platformio.ini:
`; ---------------------------- Project Env ----------------------------
[env]
platform = atmelsam
framework = arduino
board_build.variants_dir = variants
debug_tool = atmel-ice
upload_protocol = atmel-ice
; ---------------------------------------------------------------------
; ---------------------------- Main MCU Env ---------------------------
[env:main]
board = cep-400-main
board_build.variant = cep-400-main
; cwp: override the original framework with modified startup.c code from a local .zip file, in the same
; directory as this platformio.ini file.
platform_packages = framework-arduino-samd-adafruit @ file://framework-arduino-samd-adafruit-ml-main-cpu.zip
build_src_filter =
${env.src_filter}
-<data/*>
-<data_m8.cpp>
test_framework = unity
test_filter = main/*
lib_deps =
; Internal
Wire
SPI
; External
adafruit/Adafruit Zero DMA Library@^1.1.1
vshymanskyy/TinyGSM@^0.11.7
adafruit/SdFat - Adafruit Fork@^2.2.1
adafruit/Adafruit SPIFlash@^4.2.0
adafruit/RTClib@^2.1.1
bblanchon/ArduinoJson @ ^6.21.3
densaugeo/base64 @ ^1.4.0
; build at 0x8000 for use with SD card bootloader
board_upload.offset_address = 0x00008000
board_build.arduino.ldscript = flash_with_bootloader.ld
; ---------------------------- Data MCU Env ---------------------------
[env:data]
board = cep-400-data
board_build.variant = cep-400-data
; cwp: override the original framework with modified startup.c code from a local .zip file, in the same
; directory as this platformio.ini file.
platform_packages = framework-arduino-samd-adafruit @ file://framework-arduino-samd-adafruit-ml-data-cpu.zip
build_src_filter =
${env.src_filter}
-<main/*>
-<data_m8.cpp>
test_framework = unity
test_filter = data/*
;test_port = /dev/ttyUSB0
test_port = com7
test_speed = 9600
lib_deps =
; Internal
Wire
SPI
; External
adafruit/Adafruit Zero DMA Library@^1.1.1
sparkfun/SparkFun u-blox GNSS v3@^3.0.9
sparkfun/SparkFun u-blox GNSS Arduino Library@^2.2.24
bblanchon/ArduinoJson @ ^6.21.3
mikalhart/TinyGPSPlus@^1.0.3
board_upload.offset_address = 0x00008000
board_build.arduino.ldscript = flash_with_bootloader.ld
build_unflags = '-DUSBCON'