• 1
    Step 1

    DISCLAIMER: This may well not be the best way to achieve this, but its what I ended up with hacking together bits and pieces.

    TEMP UPDATE: Unkown why, but possibly an update of the arduino core, but things have changed and no longer function. Some progress made, still trying to map out what changed and what needs fixing. Will target wokring with latest 1.6.11
    There seems to be some furter inconsistencies in how Arduino handles 3rd party programmers. And until its resolved I'll hold off on putting more effort into documenting this.


    Start off by flashing https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266AVRISP to the ESP module. I also modified the code to allow the ESP to accept OTA updates, and provide a rudimentary UART bridge. The 8266avrisp code is also in the Arduino ESP8266 package as an example.

    Next up I set my Inhaos Uno LC board to 3.3V supply voltage using the jumper. I will later add level shifting to allow programming a 5V target too. The Uno LC is a nifty variant of the Uno R3 which has selectable 3.3V and 5V operation, as well as both female and male headers for the pins.

    Connect the SPI bus and reset line. I used GPIO15 for reset, and the user SPI is fixed, all as per the example code.

    ESP8266Wemos D1Arduino
    GPIO 15D8Reset
    GPIO 14D513/SCK
    GPIO 13D711/MOSI
    GPIO 12D612/MISO
    GNDGNDGND

    Unfortunately on windows avrdude did currently not support using sockets to program the AVR, linux worked fine, and with the help of #Arduino on irc.freenode.net I was provided an experimental binary that also worked on windows. People can be awesome!

    To make this work from the IDE, a few things are needed. Firstly we need to have Arduino IDE look for network ports, this is achieved by adding boardname.upload.via_ssh=true to the board definitions, for the boards we want to use. I created a new Uno entry with this line.

    Secondly we need to make Arduino tell Avrdude to use -Pnet:10.10.0.185:328 instead of -PCOM32. Using the network ports, COM32 is automatically replaced with 10.10.0.185, so far so good! I tried adding an new programmer entry. And setting esp8266avrisp.program.extra_params=-Pnet{serial.port}:328 (as 328 was the port used in the 8266avrisp example). This did not work as I had hoped. I also experienced that Using Tools->Burn bootloader and Sketch->Upload using programmer didn't actually use the same programmer, this may be why adding a programmer entry didn't work.

    Given that I had an experimental avrdude.exe, which lacked USB support, i created a whole new Hardware package and modified the platform.txt to allow me to use the modified avrdude, with the correct parameters and to also ensure that I downloaded the bootloader together with the firmware, if not the firmware would overwrite the bootloader. An alternative would be to set fuses to protect the bootloader, but I wanted to avoid modifying the original Arduino boards. Luckily newer versions of the Arduino IDE generates a .hex file that has the bootloaded already included, so I ended up with:
    tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -D -p{build.mcu} -c{upload.protocol} -Pnet:{serial.port}:328 -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.with_bootloader.hex:i"

    Speaking of preserving the bootloader, my motivation for using the ESP8266AVRISP code was to flash a board that did not have room for a bootloader and needed ISP programming. If only interested in wifi programming from the Arduino IDE, using the bootloader and ESP-link is probably a better solution. You will still need to add .via_ssh=true, and change the esp-link mDNS to arduino for the IDE to list your network port, and connect a reset pin from the esp-link to the target Arduino. The esp-link solution is more stable if you can fit the bootloader. However sometimes you need the extra space, some times you have something connected to the UART pins that prevents the bootloader functioning properly, and sometimes you just need ISP to restore bootloaders and fuses. Enter ESP8266AVRISP!

    So now I can choose the custom Arduino/Genuino Uno-esp8266 entry from the board menu, select the network port that the esp8266avrisp broadcasts and flash the firmware to the Arduino without disconnecting any open serial connection. But most importantly, I can add a battery to the esp8622 and be truly wireless, connect the esp8266avrisp to those hard to reach Arduinos, and sit at the comfort of my desk to upload the firmware. And I can even look at the Arduinos serial port to debug the new bugs I just uploaded.

    When programming we see that the Arduino IDE is indeed connecting avrdude to net:10.10.0.185:328, and its also using the hacked version that works with sockets on windows. Hopefully a working release is available soon. Meanwhile Linux works great too.


    Using the modified ESP8266AVRISP example, I added a rudimentary UART bridge, so I can also connect to 10.10.0.185:23 using telnet or RealTerm, and not worry about closing the terminal before starting an upload.

    Picture shows my Inhaos Uno LC (and the keen observer will tell its jumper is set to 5V and not 3.3V, and the Vcc line is still connected to the WeMos D1 mini 3.3V. This was a mistake.. It also leads me to the topic of recent articles showing the ESP8266 "officially" has 5V tolerant GPIO, the supply still need to be kept at 3.3V. And the datasheet and FAQ still say GPIO is not 5V tolerant. In less than a day my conclusion is I will continue to use proper level shifting. Anyways, the Arduino board is powered by a USB battery pack, the ESP8266 is leching power off the 6 pin ISP connector, and in return providing new firmware and a UART bridge. I tried laying out the wire wrap wires so connections are identifiable:So while there is a few hoops to jump through, by creating the boards.txt, platform.txt and programmers.txt files, its rather convenient to just plug in the ESP8266 to an Arduino and walk away. Do make sure the supply has the capacity to power both circuits. Alternatively you can power the ESP8266 and feet power to the target Arduino, bot ways work with this simple setup.

    I'll hold off on publishing the .txt files for the IDE as I am currently not 100% sure if I'm doing something wrong, expecting the wrong behaivour of the IDE or there is a bug in the IDE.