If you've ever tried to use SPIFFS on the Dev version of the SparkFun ESP8266 Thing, you will quite likely have encountered the error message "SPIFFS Not Defined for SparkFun ESP8266 Thing Dev" as soon as you tried to upload a disk image using the ESP8266 Sketch Data Upload tool from the Arduino environment. This blog has some background info on this, but for those who are impatient, I'll give you the solution first.
The Problem
The SparkFun ESP8266 Thing Dev board definition is missing some essential details for the SPIFFS Data Upload tool to work correctly. Why SparkFun didn't include these in the board files is beyond me, there seems to be no technical reason behind it. Maybe it was just forgotten and maybe it will be fixed in the future. Maybe it is already fixed by the time you read this :-)
The Solution
Very simple: add the missing details. First locate your ESP8266 boards definition file. Under Windows, it should be in C:\Users\<your user name>\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\boards.txt. First make a copy of this file, could be handy in case things get messed up. Open this file with an editor that can deal with non-DOS line endings, such as WordPad. You will find using Notepad (Windows' default choice for a .txt file) confusing since it won't show the lines properly.
In the boards.txt file, look for the line that starts with "thingdev.build.flash_freq" (Use Ctrl-F for this or you will spend a long time scrolling and looking). This brings you straight into the right spot in the right section for the SparkFun Thing Dev board. Now right below this line, add the following lines:
thingdev.build.spiffs_start=0x6B000
thingdev.build.spiffs_end=0x7B000
thingdev.build.spiffs_blocksize=4096
thingdev.build.spiffs_pagesize=256
Save the boards.txt file, reboot the Arduino environment and now the upload tool should be working fine. Bear in mind though that the SPIFFS Data Upload Tool is famous for giving problems when being used while the Arduino Serial Monitor is active, so make sure that the latter is closed, or not even started to begin with.
Congratulations, you now have a working setup for a SPIFFS Data Upload transaction on your SparkFun ESP8266 Thing Dev board. If you have no clue what just happened here, read the background info below.
SPIFFS, is that some kind of TV Snack?
In the case of ESP8266 based boards, it is a piece of magic to use part of your EEPROM as some sort of external hard disk. From the firmware on your board, you can access files and even modify them, and since they are stored on EEPROM, changes will survive power cycles. It is also possible to write an entire disk image to the ESP8266 in a way similar to programming the software into your board. For this, you create a subdirectory "Data" in the folder of your sketch and then you put all the neccessary files in that folder. Do not create any subdirectories in the Data folder as the SPIFFS tooling is simple and won't deal with subdirs. Once you're ready putting the files in that Data folder, you can upload them to your board by selecting Tools / ESP Sketch Data Upload in your Arduino environment.
The upload tool can be obtained from here: https://github.com/esp8266/arduino-esp8266fs-plugin and a nice overview of how to use SPIFFS can be found here: http://www.instructables.com/id/Using-ESP8266-SPIFFS/Having a file system available on a board like this could be handy for a number of reasons. Using the ESP8266 as a web server comes to mind first, although I think for that you shouldn't go with a SparkFun board for that application (see also "A word of warning" further down below). But these "Things" are meant to be used as IoT boards and it is getting more common for IoT back-end servers to require certificates for things to authenticate to that server. Being able to put certificates in a simple file system is more practical than putting them in code as some sort of string constant.
To Dev Or Not To Dev, what's the difference?
This has been confusing some people for a while already, so don't feel ashamed :-) The difference is not that big, but the regular Thing assumes you have a USB to Serial converter for programming and preferably one with a specific pinout, so it can be hooked up straight to some of the Thing's external connectors. So it DOES have a USB connector, but this does nothing beyond powering the board from it. The Dev version has an onboard FTDI chip, which does that USB to Serial converting magic for you. In other words, the dev board can be programmed directly through the USB connector. There are some other minor differences in the implementations of the programming in respect to the Auto Reset / Auto programming circuitry, but you probably won't be to interested in that. What matters here is that for both boards, the ESP8266 is automatically put in programming mode by the Arduino Environment, so no need for these finger twitching toggle-reset-while-holding-down-prog-button exercises.
Looking further into the schematics, you will find that the Dev version sacrificed the LiPo charging functionality for the built-in USB converter. If you really need that LiPo charger, you're probably best off developing on a Dev board and then go through the USB to Serial hassle once with a regular Thing.
A word of warning on SPIFFS and the SparkFun Thing boards
The SparkFun ESP8266 Thing boards have many qualities, but EEPROM size is not one of them. In total, there is only 512 KB available, of which supposedly 64 KB are available for your SPIFFS filesystem. This can probably tweaked in some ways, but you will quite likely need most of that EEPROM for your software, leaving that mere 64 kB for your files. You can't really do much about it until you take out your soldering equipment and replace the EEPROM chip for a larger one. In which case you might just as well order an ESP8266 board from another supplier, that comes with a bigger EEPROM chip straightaway.
Top Comments