VirtualKeypad-Web.ino requires some files to be loaded into the ESP8266's local file space in order to show a virtual keypad for the DSC PowerSeries style panels and keypads.
It suggests using ESP8266FS tools to create a file system and upload files.
However, this is a .jar file and is only compatible with the older 1.8 flavours of the arduino-ide. The flavour I have have running currently is 2.1.1.
In addition, the ESP8266FS is deprecated, and has been superseded by LittleFS file system API. The LittleFS tool also does not appear to function in the v2 IDE, as it also is a .jar file (Java related?)
The modern way appears to be a two step process:
- use the hidden mklittlefs to create a filesystem with resident files
- use ElegantOTA to upload the blob to the ESP8266's file system area (http://local/update)
- or use esptool to upload via the command line
In my Linux install of the Arduino IDE install, there is a tools directory called ~/.arduino15/packages/esp8266/tools/ which has several tools:
$ ls -al ~/.arduino15/packages/esp8266/tools/
total 0
drwxr-xr-x 1 rpb rpb 90 May 5 11:50 .
drwxr-xr-x 1 rpb rpb 26 May 1 21:03 ..
drwxr-xr-x 1 rpb rpb 42 May 1 21:03 mklittlefs
drwxr-xr-x 1 rpb rpb 42 May 1 21:03 mkspiffs
drwxr-xr-x 1 rpb rpb 22 May 1 21:03 python3
drwxr-xr-x 1 rpb rpb 42 May 1 21:03 xtensa-lx106-elf-gcc
Source for mklettlefs is found on earlephilhower/mklittlefs github
Anyway, a command line from mklittlefs might look like this for the required files. This creates a .bin (binary) file which is a representation of the the file system.
libraries/DSC_Keybus_Interface/examples/esp8266/VirtualKeypad-Web$ \
~/.arduino15/packages/esp8266/tools/mklittlefs/3.1.0-gcc10.3-e5f9fec/mklittlefs \
-b 4096 -p 256 -s 294912 -c data image.bin
/favicon-16x16.png
/style.css
/favicon-32x32.png
/fonts/dsc_icons.ttf
/fonts/dsc_icons.eot
/fonts/dsc_icons.woff
/fonts/dsc_icons.svg
/index.html
This binary file needs to be copied over to the filesystem partition of the ESP8266. I encountered three ways to do this:
- Using add-ons with the v1.8 of the Arduino IDE. Since the current version is v2, those add-ons no longer work
- Installing ElegantOTA or incorporating library calls to do so (which then presents a web page from the ESP8266 for uploading)
- Using the command line tool esptool for copying the file over via the serial port (this document is mostly about this method)
FireBeetle-ESP32 and mklittlefs parameters was a resource for the parameters. That site also referenced a python tool called esptool. Maybe I won't need the ElegantOTA tool after all.
esptool source has documentation.
esptool can be installed with:
$ python3 --version
Python 3.11.2
$ mkdir esptool
$ cd esptool
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install esptool
Collecting esptool
Using cached esptool-4.5.1.tar.gz (252 kB)
Preparing metadata (setup.py) ... done
$ source venv/bin/activate
Ensure no other application is running on the port (like the Arduino IDE), and perform a test:
$ esptool.py -p /dev/ttyUSB0 --chip esp8266 flash_id
esptool.py v4.5.1
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: c8:c9:a3:66:93:14
Uploading stub...
Running stub...
Stub running...
Manufacturer: 20
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...
If there is something connected you may see an error like:
Serial port /dev/ttyUSB0
A fatal error occurred: Could not open /dev/ttyUSB0, the port doesn't exist
However, in looking at the source for VirtualKeypad-Web.ino, there is a line which states:
$ grep serveStatic VirtualKeypad-Web.ino
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.html");
As a result, this requires the Spiffs file system. And this can be created with the tool at ~/.arduino15/packages/esp8266/tools/mkspiffs/3.1.0-gcc10.3-e5f9fec/mkspiffs:
$ ~/.arduino15/packages/esp8266/tools/mkspiffs/3.1.0-gcc10.3-e5f9fec/mkspiffs -b 4096 -p 256 -s 294912 -c data spiffs.bin
/favicon-16x16.png
/style.css
/favicon-32x32.png
/fonts/dsc_icons.ttf
/fonts/dsc_icons.eot
/fonts/dsc_icons.woff
/fonts/dsc_icons.svg
/index.html
The -s parameter 294912 is a number which is a multiple of 4096 and larger that then size of the files combined. The tool will complain if not enough space has been allocated.
This can them be uploaded to the ESP8266 with:
$ esptool.py --chip esp8266 --port /dev/ttyUSB0 \
write_flash --flash_mode dio \
--flash_freq 80m --flash_size 4MB 0x200000 \
../libraries/DSC_Keybus_Interface/examples/esp8266/VirtualKeypad-Web/spiffs.bin
esptool.py v4.5.1
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: c8:c9:a3:66:93:14
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00200000 to 0x00247fff...
Compressed 294912 bytes to 34730...
Wrote 294912 bytes (34730 compressed) at 0x00200000 in 4.0 seconds (effective 590.6 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
My ESP8266 has 4M of flash, and in the arduino tools menu, the board is set to a 2M filesystem size, so the offset is 2MB: 0x200000
Extras: