Guide for flashing ESPHome firmware with esptools on Linux

Since ESPHomeFlasher is basically broken (No Wayland support) here a little guide. As I keep forgetting how this works and like to remind my self.

To flash ESPHome firmware with esptools first install esptools.

pip install --user esptool

or find any other way that allows you to run GitHub - espressif/esptool: Espressif SoC serial bootloader utility

Connect the ESP via USB to the PC. Monitor journalctl to know what TTY is used:

journalctl --follow

Download the modern firmware file from within the ESPHome panel of HomeAssistant:
Screenshot from 2022-09-15 21-55-24
Screenshot from 2022-09-15 21-56-14
Screenshot from 2022-09-15 21-56-58

cd to the location where the firmware was downloaded to. In my case e.g.

cd Downloads

and the firmware file is called white-factory.bin

Then flash the firmware on to the ESP with:

esptool.py --chip esp32 -p /dev/ttyUSB0 write_flash 0x0 white-factory.bin

Notes:

  • On most linux systems a default user cant write to /dev/ttyUSB0. Therefore either root (sudo) must be used, or better the user must be added to the dialout group.

    sudo usermod -a -G dialout username
    

    Afterwards one must log out and in again for this to have an effect.

  • If the firmware file doesn’t end on -factory.binit is likely not the modern version. If you flash the legacy version, the ESP will get stuck in a boot loop. I guess the difference between modern and legacy is, that legacy comes without a bootloader, but I never really checked that.

  • To check if stuff is working you can use picocom install with:

    sudo apt install picocom
    

    and then run it with:

    picocom /dev/ttyUSB0 -b 115200
    

    to close picocom press CTL+a and then CTL+q

8 Likes

An alternative could be to install esphome via pip on Linux:

pip3 install --user esphome

This way it’s not only possible to verify, compile and flash/upload yaml’s - or all three in one command:

esphome run white.yaml

but also local (serial/usb) and remote (ota) logs are possible to obtain:

esphome logs white.yaml
1 Like

Just made a test and the version I download 2 years ago (1.3.0) works on my linux workstation as well the newest version (1.4.0) which I just downloaded. There is only one bug for me (Linux Mint 20) that the file dialog after clicking “Browse” doesn’t open but instead crashing the application. :boom: I could work’a’round this by copying in the full path to the file directly into the field - that way the program just flashed the binary like it should.

1 Like