How to configure an ESP8266 WiFi Module for use with STM32 Based Boards

Overview

These instructions are aimed at users who’s mainboard does not contain an onboard WiFi Module and an extra module has had to be connected to the EXP1/EXP2 ports.

Initial Configuration

Manual Flashing

The image to flash to the ESP8266 can be found here.

It should be flashed using esptool.py. Use the code below as an example. Change the Com port to match the ESP8266 device and make sure you give the .bin file its complete file location if its not in the same folder as esptools.

esptool.py --port COM4 write_flash 0x00000 DuetWiFiServer-esp8266-stm32f4.bin

You can also follow PCR’s instructions if you don’t get on with esptool.

If flashing a board with 16MB flash size, such as the Wemos Mini Pro, the following code should be used.
esptool.py --port COM4 write_flash --flash_size 4MB 0x00000 DuetWiFiServer-esp8266-stm32f4.bin

On a side note, I have a very handy little tool installed on my main laptop thats monitoring for any serial devices as they are plugged in and you get a popup with the Com port number. If you’re interested, it can be found here.

RRF based flashing

The WiFi UART interface will require changes to your board.txt file. You need to define the pins used by the UART (the builds provided have support for UART0 and UART3 defined, this takes the form: 8266wifi.serialRxTxPins = {RXPin, TXPin} This information has been added to the connecting via WiFi page for each board.

You will also need to hook up the ESP8266 UART pins (marked RX/TX on most modules).

Download the latest stable DuetWiFiServer-esp8266-stm32f4.bin (or the latest unstable release if using unstable releases) from here, rename it to DuetWiFiServer.bin and put it in the sys folder on the SD card.

Then send the following commands

M552 S0
M997 S1
M552 S0

Updating Existing

There are two methods to update the boards if a new version of the ESP8266 firmware is released

Manual Updating

This method follows the flashing instructions for preparation. To allow the ESP8266 to be put in reset mode, its best to disconnect it from the board.

DWC based Updating

The WiFi UART interface will require changes to your board.txt file. You need to define the pins used by the UART (the builds provided have support for UART0 and UART3 defined, this takes the form: 8266wifi.serialRxTxPins = {RXPin, TXPin} This information has been added to the connecting via WiFi page for each board.

You will also need to hook up the ESP8266 UART pins (marked RX/TX on most modules).

Download the latest stable DuetWiFiServer-esp8266-stm32f4.bin (or the latest unstable release if using unstable releases) from here and upload it to the system folder using DWC. DWC should ask you if you want to install the update. If it doesn’t, issue the command M997 S1.