PlatformIO on freeBSD

Hello,

I’m looking for some guide or help for installing platformIO or more precisely some toolchain on freeBSD.

I’m using the freeNAS plugin for ESPHome.

freeNAS version : 11.3-U4.1
ESPHome version: 1.15.2
PlatformIO version: 4.3.4

The ESPHome plugin is correctly installed but when i try to compile, i got an error while installing xtensa:

i know there is a topic on this but they are dated from 2016 and read that was fixed so I think that I do something bad.

Thanks for help !

PlatformIO does indeed have the toolchain-xtensa package for the freebsd-amd64 architecture listed in the bintray, the latest version bing 3445d11-toolchain-xtensa-freebsd_amd64-1.40802.0.

But I think there’s a versioning error. The platform demands

But the available package version is only 1.40802.0, so that’s one less in the major and the minor doesn’t match, too…

Does the following work?

  • Download Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog
  • if the directory ~/.platformio/packages/toolchain-xtensa doesn’t exist, create it
  • extract the contents of the .tar.gz file in that new folder
  • modify ~/.platformio/packages/toolchain-xtensa/package.json , so that the version field value now is 2.40802.200502 instead of the previous 1.40802.0
  • recompile the project.

Thanks for the fast answer but it dosn’t work. I had a new error “permission denied” on package_json but when i put the good right. i got the usual error

o_O weird. That file should have normal rw permissons coming from the tar gz. I will setup a virtual machine and check whether this doesn’t work personally.

plz ask if you need some screen or information from my conf

I’ve just personally verified that this works. Installed a clean FreeBSD 12.1. Then had to install Gnome3 as desktop environment, sudo, python3, pip-3.7 and PlatformIO through pip. In a shell from the home directory, I did

wget https://bintray.com/platformio/tool-packages/download_file?file_path=3445d11-toolchain-xtensa-freebsd_amd64-1.40802.0.tar.gz
mv download_file\?file_path\=3445d11-toolchain-xtensa-freebsd_amd64-1.40802.0.tar.gz xtensa.tar.gz
cd ~/.platformio/packages/
mkdir toolchain-xtensa
mv ~/xtensa.tar.gz toolchain-xtensa/.
cd toolchain-xtensa/
tar xfv xtensa.tar.gz
nano package.json
<edit version to 2.40802.200502>

and created a new project

mkdir esp8266-test && cd esp8266-test
pio init -b nodemcuv2
nano src/main.cpp
<insert blinky sketch>
pio run

…which made me run into an error that libstdc++.so.6 wasn’t installed. This is solved incidentally by installing GCC. After a sudo pkg install gcc and a rerun of pio run:

[max@freebsd ~/esp8266-test]$ pio run 
Processing nodemcuv2 (platform: espressif8266; board: nodemcuv2; framework: arduino)
-----------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html
PLATFORM: Espressif 8266 (2.6.2) > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 3.20704.0 (2.7.4) 
 - tool-esptool 1.409.0 (4.9) 
 - tool-esptoolpy 1.20800.0 (2.8.0) 
 - toolchain-xtensa 2.40802.191122 (4.8.2)
Building .pio/build/nodemcuv2/firmware.bin
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  32.7% (used 26776 bytes from 81920 bytes)
Flash: [==        ]  24.6% (used 256844 bytes from 1044464 bytes)
Creating BIN file ".pio/build/nodemcuv2/firmware.bin" using "/usr/home/max/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" and ".pio/build/nodemcuv2/firmware.elf"
======================== [SUCCESS] Took 6.13 seconds ========================

So this trick works for me.

Maybe retry my steps and make sure you’ve edit all the right files and versions.

Note that the missing packet was also noticed by others who engineered workarounds like GitHub - trombik/platformio-freebsd-toolchain-xtensa: Trick platformio so that it thinks toolchain-xtensa, a platformio package, is installed. With recent ESP8266/Arduino (3.0.0), This workaround does not work anymore. Use https://github.com/trombik/freebsd-ports-esp-quick-toolchain/ instead., which relies on a pre-installed system-wide install xtensa-lx106-elf and symlinks it in the package directory.

Okay thanks a lot the first reply you made works but I was namin toolchain-xtensa32 and not toolchain-xtensa. Thanks for help and sorry for the trouble. I got others issues but will try to find some solutions first :slight_smile:
Thanks for your time

Feel free to open new topics if there are additional tools missing for FreeBSD. Missing support packages or versioning mistakes seemed to happen there.

Sure juste looking on internet if solution doesn’t exist first

Just if someone use the fix that @maxgerhardt gave be sure that you have the good right on the platformio packages folder with : chown {USER} path/to/.platformio/packages
it’s all working for me now thanks for all

I am having a similar issue. I dont have any version of the toolchain-xtensa installed.
when I try to wget the tar.gz file i get zsh: no matches found " wget Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog".
I know I’m late to the post here. I’m using the current stable version of Truenas with the ESPHome and HomeAssistant plugins.

Hello.
I found this file, download it
/home/homeassistant/.platformio/packages/toolchain-xtensa/package.json
{
“description”: “xtensa-gcc”,
“name”: “toolchain-xtensa”,
“system”: [“freebsd_amd64”],
“url”: “GitHub - jcmvbkbc/gcc-xtensa: gcc for xtensa”,
“version”: “2.40802.200502”
}

But i got still this same error.
Resolving nodemcuv2 dependencies…
Tool Manager: Installing platformio/toolchain-xtensa @ ~2.100300.0
Error: Could not find the package with ‘platformio/toolchain-xtensa @ ~2.100300.0’ requirements for your system ‘freebsd_amd64’

Best

This doe not suffice, you need to have the whole package binaries downloaded in there.

Yes. I have.
Ok, i “override” this by, changing version to 1.4 and it download.
But now i have another problem…

INFO Compiling app…
Processing woda (board: nodemcuv2; framework: arduino; platform: platformio/espressif8266 @ 3.2.0)

HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
Dependency Graph
|-- ESPAsyncTCP-esphome @ 1.2.3
|-- ESPAsyncWebServer-esphome @ 2.1.0
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- noise-c @ 0.1.4
|-- wMbus-lib @ 0.9.15+sha.25dfb37
Compiling .pioenvs/woda/src/esphome/components/api/api_connection.cpp.o
xtensa-lx106-elf-g++: error: unrecognized command line option ‘-std=gnu++17’
Compiling .pioenvs/woda/src/esphome/components/api/api_frame_helper.cpp.o
xtensa-lx106-elf-g++: error: unrecognized command line option ‘-std=gnu++17’

Yeah seems like the compiler you have gotten through this is not new enough to support C++17, which the platform-espressif32, and through it the Arduino-ESP8266 core, needs.

Is this really Xtensa-GCC 4.8.2? What does /home/homeassistant/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-g++ --version say?

Here.

xtensa-lx106-elf-g++ (crosstool-NG 1.20.0) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

i try to link as xtensa-lx106-elf-g++ g++ from Freebsd, but no luck
In FreeBSD i have

g++ (FreeBSD Ports Collection) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Weird how it doesn’t have xtensa in the output name there, are you sure its targeting XTensa LX106?

How do you do this? The safest way is to just overwrite all files in /home/homeassistant/.platformio/packages/toolchain-xtensa/ with the newer compiler package. (So, bin, lib, include, all of it)

I make only ln -s from system g++ to this file xtensa-lx106… but this not help.
And this what i have in platformio is this

xtensa-lx106-elf-g++ (crosstool-NG 1.20.0) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

o_O that’s not going to work at all. PlatformIO will at runtime add /home/homeassistant/.platformio/packages/toolchain-xtensa/bin to the PATH of the shell used for building and invoke xtensa-lx106-elf-g++.

You really should modify the files in /home/homeassistant/.platformio/packages/toolchain-xtensa itself.

But in home/homeassistant/.platformio/packages/toolchain-xtensa
I have filed downloaded by platformio, and this version is :

xtensa-lx106-elf-g++ (crosstool-NG 1.20.0) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

then what i need to do now ?