PlatformIO Community

Building Marlin for the STM32 on FreeBSD

Using the FreeBSD package system I installed py-pip, which I then used to install platformio:

pkg install py-pip;
pip install platformio

After downloading Marlin and adding

default_envs = STM32F103RET6_creality

to Marlin’s platformio.ini I tried to build it using “pio run”.

However, there were no appropriate packages available for download for the STM32F103RET6_creality environment I needed.

I downloaded the gcc-arm-embedded package for FreeBSD-11, since it is the oldest supported version and binaries compiled for it can run on the more recent versions if the compatibility packages are installed. The package can be downloaded from here:

(although the version numbers will change as the package is updated).

Then I created a directory toolchain_gccarmnoneeabi in ~/.platformio/packages and extracted a portion of the gcc-arm-embedded tar file from its subdirectory gcc-arm-embedded-8-2020-q2-update into the new directory.

The contents of the new directory were then:

arm-none-eabi/ bin/ lib/ share/

I then added a package.json copied and edited from a corresponding linux package, changing the system name to “freebsd_amd64”.

This seemed to do the trick, although before things compiled properly I needed to edit numerous “static inline __always_inline” statements to remove the “__always_inline”, most of which were in framework-arduinoststm32-maple but two of which were in Marlin itself.

I have yet to test the compiled binary, and will not do so for a week or two, but everything worked as far as platformio itself was concerned.

This was on version 5.0.1 of platformio.

I do understand the reasons for preparing packages of binaries for various systems and including them in the online repositories that platformio can install from, but for systems such as FreeBSD or Linux for which these binaries are already prepared and maintained elsewhere, it would probably be more useful to simply require that the packages be installed through the usual means (such as the FreeBSD package or ports system). The downloadable packages of binaries could then be replace by symbolic links. Even if this technique were not generally adopted providing instructions and a script to automate the link generation might be a way to make platformio more generally available. Nothing I needed to do to get this working on FreeBSD was difficult except for the part of figuring out where to put everything.

The idea I wanted to try out turned out to be much easier to implement than I expected, so I was able to test the firmware I compiled on FreeBSD using the setup described above today.

I installed the image uneventfully and it is working properly.