How to download libraries


I’ve developed a project in the past with platformio core 4.x and are moving it now to 5.0.

In this process I want to make a copy of all platform packages and libraries that are necessary for compile the project on a raspberry pi and flash it into a sleepypi. Specifcally I’ll be using a Raspberry Pi 3B+ and a Sleepypi 2 and run the code inside a Docker container.

In my earlier version I just let platformio install the necessary dependencies itself. From the terminal output I think there are the following things to download:

  • atmelavr @ 3.0.0
  • toolchain-atmelavr @ 1.50400.190710
  • framework-arduino-avr @ 5.1.0
  • tool-scons @ 4.40001.0
Platform Manager: atmelavr @ 3.0.0 has been installed!
The platform 'atmelavr' has been successfully installed!
The rest of the packages will be installed later depending on your build environment.
Tool Manager: Installing platformio/toolchain-atmelavr @ ~1.50400.0
Unpacking  [####################################]  100%          
Tool Manager: toolchain-atmelavr @ 1.50400.190710 has been installed!
Tool Manager: Installing platformio/framework-arduino-avr @ ~5.1.0
Tool Manager: framework-arduino-avr @ 5.1.0 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40001.0
Tool Manager: tool-scons @ 4.40001.0 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Atmel AVR (3.0.0) > SpellFoundry Sleepy Pi 2
 - framework-arduino-avr 5.1.0 
 - toolchain-atmelavr 1.50400.190710 (5.4.0)

What I would like to know now is:

  • Where can I find these libraries (dependencies? platforms?) to download them to my drive for further install from file
  • Anything I have to be aware of there, if I want to run this on a Raspberry Pi? (like take the ARM version, or so)
  • How can I install these depencies from a file? (I suspect as detailed here)

To be clear, my goals are:

  • Offline install from file
  • Fix it to a specific version (that i have downloaded)

Frameworks (framework-arduino-avr), tools and toolchains are “packages” in PlatformIO speak and stored in the <user directory>\.platformio\packages directory (User directory being C:\Users\<user> for Windows and /home/<user>/ for Linux). Platforms (platform-atmelavr) are stored in <user directory>\.platformio\platforms. The download source of these packages can be found in the bintray.

The Raspberry Pi should have all the packages available (toolchains for ARM etc) for compiling an Arduino AVR project without problems. Just take care to not copy package files for Windows to the ARM-based Raspbi, as that is binary unexecutable. Otherwise I see no concerns

There is no pio package install <some package.tar.gz / zip> command that I’m aware of to install a package to ~/.platformio/packages. So if you want an “offline install” you would need to copy the (binary compatible versions) of the specific ./platformio/packages/ folders to the target machine yourself.

For platforms, there is pio platform install which can take a file:// address. For libraries, you’ve already posted the command yourself.

I were you, I would do something like:

  • setup a Raspbi
  • install PlatformIO via pip3
  • download the to-be-compiled project and compile it (with resources auto-downloaded from the internet)
  • make a snapshot of the entire ~/.platformio folder (nicely includes packages, platforms, and other internal stuff)
  • make a snapshot (or have zip file) for each library used in the projecet

Then to replicate the setup in a docker or something, just:

  • create a container that has the PlatformIO CLI installed already
  • copy over the ~/.platformio/ snapshot obtained earlier to the target container
  • copy over the library zip files used in the project
  • copy over the to-be-compiled project
  • go into the project folder and execute the pio lib install file://<library zip> commands for each library to get them installed locally in the project
  • compilation by pio run should then not need any internet access for packages or libraries and just compile the project