/esp8266-webconf-mDNS-OTA

Arduino code sample to configure the ESP8266 via http and update Over-the-Air (OTA)

Primary LanguageArduinoOtherNOASSERTION

esp8266-webconf-mDNS-OTA

Arduino code sample to configure the ESP8266 via http and update Over-the-Air (OTA).

Linux build status

Information

For using this Arduino sketch you need the Arduino ESP8266 Environment. Stable and Staging releases are not supported now. You have to use the current git master branch or any branch after 6978b6a
The over the air (OTA) flashing stuff works only for flash size higher or equal than 1 MB. You can check your flash size by getting the flash chip id with the esptool python script:

esptool.py --port [Serial port] flash_id

For more information please read the esp8266 wiki page.

Usage

Flashing file system

Create Image

First we have to crate a binary file from data folder. I use the mkspiffs tool for this with the following command:

mkspiffs -c ./data/ file.bin

This works for 64K SPIFFS and standard page and block size very well, but for higher SPIFFS size you have to customize the settings with the following options for the ESP8266 Generic module:

flash size SPIFFS options real size (KBytes)
512kB 64k nothing 64
1M 64k nothing 64
1M 128k -s 0x20000 128
1M 256k -s 0x40000 256
1M 512k -s 0x80000 -b 0x2000 512
2M 1M -s 0xFB000 -b 0x2000 1004
4M 1M -s 0xFB000 -b 0x2000 1004
4M 3M -s 0x2FB000 -b 0x2000 3052

You can get more information at the ESP8266 Arduino reference page.

Flashing Image

After that we need to flash this binary image to the file system address into flash:

esptool.py --port /dev/ttyUSB0 write_flash [Address] file.bin

Addresses

The address is depending on your flash chip size. Here are some values for you:

  • 512K (64K SPIFFS): 0x6B000
  • 1M (64K SPIFFS): 0xEB000
  • 4M (1M SPIFFS): 0x300000

For other flash sizes you can get the address information from your arduino esp8266 installtion linker files located in arduino_esp/hardware/esp8266com/esp8266/tools/sdk/ld/eagle.flash.[X]m[Y].ld. [X] means the flash size and [Y] the spiffs size. This files contains a variable like _SPIFFS_start. The start address for your file system is: _SPIFFS_start - 0x40200000

Troubleshooting

If OTA updates do not work you can try to clear the hole chip. I use a linux shell for the commands. At first create empty binary image:

dd if=/dev/zero of=clear.img bs=1024 count=1024

This creates a 1 MB image with zeros. For another chip size you have to change the count paramter.

Flash the empty image over serial:

esptool.py --port /dev/ttyUSB0 --baud 921600 write_flash 0x00000 clear.img

After that we can flash the program:

  • creating SPIFFS image
  • flashind SPIFFS image
  • flashing Code
  • Happy using ;-)

License

For license information please see License