PlatformIO xtensa toolchain on FreeBSD

Probably a bit of a niche question. I’d like to run PlatformIO natively on FreeBSD rather than in a VM. In particular I’m building for ESP8266 and ESP32 targets. End game is to natively build esphome.

PlatformIO does not provide a FreeBSD/AMD64 toolchain. I’ve installed the one from port “devel/xtensa-esp-elf” but am struggling to get PlatformIO to recognize and use it.
As a first step I’ve created a symlink in ~/.platformio/packages/toolchain-xtensa-esp-elf -> /usr/local/xtensa-esp-elf but PlatformIO expects a package.json file in there as well. I’ve tried to create one manually without any success.

Has anyone managed to progress further than me?
 
Hello,

development on FreeBSD for the plethora of ESP MCU types isn't easy, but if you're willing to build your own port, have a look at Tomoyuki Sakurai's (aka Trombik) inofficial FreeBSD port of his toolchain for ESP32: GitHub Repositorium .

The advantage of this FreeBSD port is obvious: support for most ESP32 Tensilica core bases variants (ESP8266, ESP32, ESP32-S2,S3) as well as RISCV32 based variants, which I prefer (ESP32-C3, -C6, -C61 and the new ESP32-P4). At this very moment, the (semi-)official port of Trombik supports ESP-IDF v5.3, v5.4. I try to make usage of v5.5, but struggling with RUST on RISCV32 part of the port.

FreeBSD's official port devel/xtensa-esp-elf is limited to those ESP32 based on the Tensilica LX cores and is limited to gcc13/ESP-IDF v5.3.

Maybe this hint is of any help.


 
FWIW, RISC-V based ESP32 chips can easily be programmed with rust on FreeBSD...
I suspect it will be quite limited, even compared to micropython.

You will lose all the power of directly accessing the running FreeRTOS (i.e ESP-IDF is the most important part of the platform).

Since Rust has basically just turned into a bindings dependency aggregator these days, you will still need a C compiler. Plus crates.io won't be functional in this space either.
 
FWIW, I needed to do something esphome in a rush, so I found two practical, not pure ways to get things done.
The first approach is to simply use podman with esphome docker container like that would do on Linux.
It's not super efficient, but it works.
Sample command line:
podman run --os=linux --network=host --rm -v "${PWD}":/config -it ghcr.io/esphome/esphome compile test.yaml

A bit later I needed to do more work and had time to better prepare for it.
So, I created an ubuntu jail using bastille (rather easy).
And then I followed Linux installation instructions.
It worked very well.

I think that this is the situation where the Linux binary compatibility shines.
No drivers, no special hardware access, no exotic system calls (mostly), no dependency on systemd or otehr complex services.
Just simple tools (like python scripts), compiler toolchains, etc.

I think that something like this should work for platformio as well.
Integrating with IDEs / GUIs, if needed, would probably be the hardest part.
Command line work should be easy to get going.
 
Back
Top