Access ESPHOME file system to retrieve .elf build file


I am having a issue with one of my ESP32 doing ramdon and periodic resets (CPU Software Reset). However in order to debug what might be causing this (there is a lot of code yaml + lambda) I need to get access to the firmware.elf (the .bin file will not work) file that ESPHome is building to compare with the crash logs.

When new firmware is built I can see that is it being stored here:
Compiling /data/esp32-mycode/.pioenvs/esp32-mycode/src/main.cpp.o
Linking /data/esp32-mycode/.pioenvs/esp32-mycode/firmware.elf

But I have no idea how to access this /data/ folder? I tried with SSH but the addons folder seems to be empty. Couldn’t find anything on google for this.

I have a standard HASS installation running from SD card on Raspberry Pi3 with ESPHome Add-On.

Thanks for your help.

Unfortunately in this case you will need to build outside of the home assistant/esphome add on and instead build it from your operating system command line. See the info here on how to do that:

and here:

Thanks for your reply but ideally I just want to use the add on and not have to build elsewhere using the command line.

Is there really no way I can access that filesystem for the add on and get the .elf file once it’s built? What is the restriction here?

Well, there is another way I guess. A bit convoluted but if you install the Portainer add on, you can access the esphome container using the console function. Then while in the conatiner you can then cd to the actual build path you show above and copy the elf file to the /config directory which is a direct mapping to the homeassistant config directory. You can then use ssl or scp to get the file from the home assistant directory to your host os for debugging.

I assume you know that all add ons are individual docker containers so all their activities occur within their own built in environments. They normally interact with the outside world with exposed ports, directories, etc. Whatever the builder setup. In this case no ssh/ftp ports are exposed so you can’t connect directly to it via those apps so the next best thing is to copy the file out.

You don’t need portainer to enter the container.

docker exec -it [containername] bash

This worked perfectly - THANK YOU SO MUCH!!!

For anyone else finding this post this is the proceedure I followed:

Installed SSH & Web Terminal add-on and setup. Disabled protection mode temporarily. Open the web UI and paste:

echo ] | (sudo docker ps --format "{ {{json .ID}} : {{json .Names}} }" | paste -sd',' && cat) | (echo [ && cat)

Find the one with esphome in the name e.g. addon_5cxxxe3b_esphome

Then execute:

docker exec -it addon_5cxxxe3b_esphome bash

type ls for list of directories - you should see /config/ and /data/

type cd /data/esp32-mycode/.pioenvs/esp32-mycode/ where esp32-mycode is the name of your esphome device (use ls again if unsure)

then execute this to copy the firmware file to the /config/ directory:

cp firmware.elf /config/

The config directory is synced with the home assistant one so if you view the normal file browser add-on for HASS you should see the firmware.elf file and be able to download it from there.

Thanks again all.

1 Like

That is a lot of stuff to type (and remember). How about

docker ps|grep esphome