Kenny's Blog

29 Mar 2021

Easier arduino flashing with esp-link

One thing that can be a pain while doing embedded development is having to be physically connected to the hardware that you’re developing. I don’t currently have a dedicated office or a workbench so it can be kinda clunky moving hardware to wherever I’m working (living room, couch, kitchen, etc).

In the past I’ve just used a raspberry pi as a mobile development station, but that can be a bit power hungry. A new alternative I’ve found is just to use a ESP8266 with esp-link, do my development on a server and flash my embedded devices over wifi. This works pretty well as the ESP8266 board I’m using is much less power hungry than a raspberry pi, and builds are really snappy since I’m using my main server for development.

I just end up powering the ESP8266 using a usb battery phone charger. It turns out the vreg on the esp8266 is pretty good as well, so I can power the embedded device I’m running using the esp device as well. I’m using an ESP-12 module (one of those generic D1 mini boards off amazon). Flashing instructions can be found here: https://github.com/jeelabs/esp-link/blob/master/FLASHING.md

Setting up the esp was relatively easy, I followed the serial flashing instructions here: https://github.com/jeelabs/esp-link/blob/master/FLASHING.md#initial-serial-flashing

One thing that’s a pain is that if you flash the esp using the default firmware, you have to use another device to connect to the wifi access point (AP) it generates on boot to connect it to your wifi network at home. I just ended up using my android phone, instead of disconnecting my laptop from my home wifi network. But, I’ve found an alternative is to just build your own version using the included makefile: https://github.com/jeelabs/esp-link/blob/master/Makefile

There are a couple of options you can configure with your own wifi credentials, eliminating the need for AP mode:

# The Wifi station configuration can be hard-coded here, which makes esp-link come up in STA+AP
# mode trying to connect to the specified AP *only* if the flash wireless settings are empty!
# This happens on a full serial flash and avoids having to hunt for the AP...
# STA_PASS ?= 

Another thought

Today, I physically disconnect the USB cable to power off the device, but I wonder if I can have some wireless setup in the future where I can do all of this wirelessly with a mcu that is on standby most of the time. I might have to change the power setup a bit, but it might be possible.