Error 139 (Segmentation Fault) Platformio Core

Hello,
I have been using platformio on a Linux system without any problem, yesterday I installed pio on a raspberry pi 0 running the latest raspbian (A derivate of Debian 9) and every time I try to pio run I get this:

Building .pioenvs/nodemcuv2/firmware.bin
Segmentation fault
*** [.pioenvs/nodemcuv2/firmware.bin] Error 139

Some specs:
My Linux Pc:

  • Ubuntu 18.10 x64
    -Platformio Core 3.6.5 + Platformio IDE Vs Code

Raspberry Pi 0:

  • Raspbian Stretch (Derivate of Debian 9) ARM
    -Platformio Core 3.6.5 (I’m running only CLI, can’t install Platformio IDE)

Board esp8266, I tried creating a project for both a NodeMcu and a wemos_d1_mini, on Linux both of them compile with no problem, on raspberry none of them compiles.

I think I tried everything but nothing seems to work, here’s what I tried so far:

  • Reinstalling platformio Core
  • Removing pio Core and installing the dev version
  • Creating a new pio project and changing the board
  • Copying the project folder from the Linux machine to the raspberry one

Here you can find the output of the pio run -v command

NodeMcu pio run -v
pi@raspberrypi:~/Documents/provaBo $ more platformio.ini
; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
pi@raspberrypi:~/Documents/provaBo $ pio run -v
Processing nodemcuv2 (platform: espressif8266; board: nodemcuv2; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html
PLATFORM: Espressif 8266 > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz 80KB RAM (4MB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 26 compatible libraries
Scanning dependencies...
No dependencies
"esptool" -eo "/home/pi/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" -bo .pioenvs/nodemcuv2/firmware.bin -bm dio -bf 40 -bz 4M -bs .text -bp 4096 -ec -eo .pioenvs/nodemcuv2/firmware.elf -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
Segmentation fault
*** [.pioenvs/nodemcuv2/firmware.bin] Error 139
Wemos D1 Mini pio run -v
pi@raspberrypi:~/Documents/provaBo2 $ more platformio.ini
; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:d1_mini_lite]
platform = espressif8266
board = d1_mini_lite
framework = arduino
pi@raspberrypi:~/Documents/provaBo2 $ pio run -v
Processing d1_mini_lite (platform: espressif8266; board: d1_mini_lite; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini_lite.html
PLATFORM: Espressif 8266 > WeMos D1 mini Lite
HARDWARE: ESP8266 80MHz 80KB RAM (1MB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 26 compatible libraries
Scanning dependencies...
No dependencies
"esptool" -eo "/home/pi/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" -bo .pioenvs/d1_mini_lite/firmware.bin -bm dout -bf 40 -bz 1M -bs .text -bp 4096 -ec -eo .pioenvs/d1_mini_lite/firmware.elf -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
Segmentation fault
*** [.pioenvs/d1_mini_lite/firmware.bin] Error 139

Any suggestion is welcome!

Can you give the output of the command file ~/.platformio/packages/tool-esptool/* please.

pi@raspberrypi:~/Documents/provaBo2 $ ~/.platformio/packages/tool-esptool/*
Segmentation fault

file please as the command in front of it.

Sorry, didn’t see that

pi@raspberrypi:~/Documents/provaBo2 $ file ~/.platformio/packages/tool-esptool/* 
/home/pi/.platformio/packages/tool-esptool/esptool:      ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=b30dec20e4ed1f9652ba81937dcc8e4c8360d0ab, stripped
/home/pi/.platformio/packages/tool-esptool/package.json: ASCII text

Ok what does

ldd /home/pi/.platformio/packages/tool-esptool/esptool

output?

pi@raspberrypi:~ $ ldd /home/pi/.platformio/packages/tool-esptool/esptool
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0xb6f33000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6de1000)
/lib/ld-linux-armhf.so.3 (0xb6f49000)

Okay so I thought there’s maybe a binary incompatibility (e.g. compiled from wrong ARM architecture version) for the esptool file, but the loader doesn’t complain :thinking:. I’ll look into it on my Pi Zero W.

Well, that’s just plain weird. It isn’t giving exec format errors, so it doesn’t look like it’s the wrong architecture. But it just-does-not-work™. If you just want to get it working, you can clone the esptool-ck repo, compile the binary and swap it in… but it doesn’t explain what’s the go here. Or you can use the binary I compiled if you trust any ol’ binary you are offered online :laughing: https://dl.bintray.com/pfeerick/armv6l/:esptool

If it is of any help, this is my output…

file ~/.platformio/packages/tool-esptool/esptool
ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=b30dec20e4ed1f9652ba81937dcc8e4c8360d0ab, stripped

versus a self-compile on a rPi ZW (raspbian stetch nov 2018)…

file ~/esptool-ck/esptool
ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=9143a614834b66afa6cdcc1550c65d181a1a51c2, stripped

Only difference appears to be the linux version and build hash? Thankfully, it’s not my fault, as it’s not the esptool ARM64 binary! :open_mouth: :laughing:

I can say that for (and I don’t know why there are two versions of the files - oh, duh… actual esptool versions!), that
tool-esptool-linux_armv6l-1.413.0.tar.gz gives the segmentation fault, but tool-esptool-linux_armv6l-1.409.0.tar.gz doesn’t.

2 Likes

Thanks!
Your binary works perfectly

If anybody has the same problem here is how to solve it:

  1. Download the binary provided by @pfeerick (https://dl.bintray.com/pfeerick/armv6l/esptool)
  2. Replace the binary in ~/.platformio/packages/tool-esptool/
  3. Make it executable

Here’s the commands to do so:

cd ~/.platformio/packages/tool-esptool/
mv esptool esptool.old
wget https://dl.bintray.com/pfeerick/armv6l/esptool
sudo chmod +x esptool

Try to run a pio project, if it works then remove the old esptool ( rm ~/.platformio/packages/tool-esptool/esptool.old )

1 Like

No problem… glad it worked for you :slight_smile: btw, I gave the wrong link above for the working distributed pio version… this is the proper link… Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog … just note it does appear to be a slightly older version of esptool 4.09 vs 4.13, if that matters.

Just need to find out why the other version doesn’t work… probably something simple!