]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_ctfws/commitdiff
Improve firmware construction, add docs
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 29 Jun 2019 13:00:28 +0000 (14:00 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 29 Jun 2019 16:07:48 +0000 (17:07 +0100)
.gitignore [new file with mode: 0644]
README-flashing.rst [new file with mode: 0644]
mklfs.sh
mkspiffs.sh

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..3b43dcd
--- /dev/null
@@ -0,0 +1,3 @@
+_lfs_build
+firm
+spiffs-*
diff --git a/README-flashing.rst b/README-flashing.rst
new file mode 100644 (file)
index 0000000..b6d9aeb
--- /dev/null
@@ -0,0 +1,65 @@
+Prepare the Firmware
+####################
+
+Not yet really documented; build a NodeMCU firmware with the modules listed in
+``README.rst``.  Ensure that ``./firm`` points to your firmware build directory,
+as we're going to pull ``luac.cross`` and the firmware ``.bin`` therefrom.
+
+Flashing
+########
+
+Clone this: https://github.com/espressif/esptool
+
+For each of the three timers (clear, yellow, and red), hook them to USB and run
+one of ::
+
+    export BOARDNAME=red
+    export BOARDNAME=yel
+    export BOARDNAME=clr
+
+and then ::
+
+    ./mkspiffs.sh
+
+    ./esptool/esptool.py write_flash \
+     --flash_size 4MB --flash_mode dio --verify \
+     0x0      ./firm/bin/nodemcu_integer_test.bin \
+     0x3fc000 ./firm/sdk/esp_iot_sdk_v3.0/bin/esp_init_data_default_v05.bin
+
+    ./firm/tools/nodemcu-partition.py \
+     --flash_size 4MB \
+     --lfs_size 65536 --lfs_file _lfs_build/luac.out \
+     --spiffs_size 262144 --spiffs_file spiffs-${BOARDNAME}.img
+
+After flashing, the device will reboot, apply some internal changes, and reboot
+again.  By default, it hangs out for a minute after the second reboot before
+rebooting again into the CtFwS logic.  This is less than ideal but is (at least
+partly) due to an upstream issue; for the less patient, after flashing, count
+15, and then hit the RST button and the device should come up into its CtFwS
+logic.
+
+Serial Console
+##############
+
+You may want to get a serial console on the device for a little more visibility
+into what's going on.  While nwf prefers the use of kermit for this, one can
+also just use screen, as in ::
+
+    screen /dev/ttyUSB0 115200
+
+Disconnect with the screen attention chord, ``ctrl+a``, followed by the command
+``:quit``.
+
+At the Lua prompt, many things are possible.  By default, the device provides
+some visibility into internal events by emitting log messages like so::
+
+    NET        wstaconn
+    NET        wstagoip
+    CTFWS      Trying reconn...
+    NET        sntpsync
+    NET        mqttconn
+    MQTT       ctfws/game/endtime      1540688900
+
+The function ``OVL.diag()`` will provide a summary of much of the device's
+internal state.
+
index 6ca1faf71a3cdbb03db85a901a8a6c01f8f314c0..94977c7ed60a0e058604e614e9eb2b4b2f93dfe3 100755 (executable)
--- a/mklfs.sh
+++ b/mklfs.sh
@@ -2,11 +2,22 @@
 
 set -e -u
 
+[ -d firm ] || {
+       echo "./firm should be a symbolic link to the nodemcu firmware"
+       exit 1
+}
+
+[ -d core ] || {
+       echo "./core should be a checkout of nwf's core modules"
+       exit 1
+}
+
 SOURCES=(
   ctfws-lfs-strings.lua
   core/_external/lcd1602.lua
-  core/fifo/fifo.lua
-  core/net/{fifosock,nwfmqtt,nwfnet*}.lua
+  firm/lua_modules/fifo/fifo.lua
+  firm/lua_modules/fifo/fifosock.lua
+  core/net/{nwfmqtt,nwfnet*}.lua
   core/telnetd/telnetd{,-{diag,file}}.lua
   core/util/compileall.lua
   core/util/diag.lua
@@ -32,4 +43,4 @@ if ! [ -x "${LUACROSS}" ]; then
 fi
 
 (cd _lfs_build; $LUACROSS -f *.lua)
-ls -l _lfs_build/luac.out
+ls -l _lfs_build/luac.out
index d940ccc5a3b9a6e74eaac6e857b1a3eb6ad06bb8..13cfc65ac4847711591a8a97870339a54063db43 100755 (executable)
@@ -1,36 +1,45 @@
 #!/bin/bash
 
-FWDIR=${FWDIR:-/home/nwf/ee/esp/nodemcu-firmware}
-FWIMG=${FWIMG:-${FWDIR}/bin/nodemcu_integer_test.bin}
-CONFNAME=${CONFNAME:-home}
+FWIMG=${FWIMG:-firm/bin/nodemcu_integer_test.bin}
+BOARDNAME=${BOARDNAME:-home}
+
+[ -r firm ] || {
+       echo "./firm should be a symlink to a built firmware repo"
+       exit 1
+}
+
+[ -r ${FWIMG} ] || {
+       echo "No firmware image ${FWIMG}"
+       exit 1
+}
 
 FWSZ=$(stat --printf="%s" ${FWIMG})
 
-LUACROSS=${FWDIR}/luac.cross ./mklfs.sh
+# Now made external
+# LUACROSS=$(readlink -f ./firm/luac.cross) ./mklfs.sh
 
 (
        # Init is the only core Lua that does not live in LFS
        echo import core/init.lua init.lua
 
        # Grab our configuration
-       if [ -r conf/${CONFNAME}/rewrites.sed ]; then
+       if [ -r conf/${BOARDNAME}/rewrites.sed ]; then
                for i in conf/_common/*.conf.in; do
-                       sed -f conf/${CONFNAME}/rewrites.sed < $i \
+                       sed -f conf/${BOARDNAME}/rewrites.sed < $i \
                                > `dirname $i`/`basename $i .in`
                done
-       elif [ ! -r conf/${CONFNAME}/nwfmqtt.conf ]; then
+       elif [ ! -r conf/${BOARDNAME}/nwfmqtt.conf ]; then
                echo 'NO MQTT CONFIGURATION KNOWN; THIS IS UNLIKELY TO WORK!'
        fi
-       for i in conf/${CONFNAME}/*.conf; do echo import $i `basename $i`; done
+       for i in conf/${BOARDNAME}/*.conf; do echo import $i `basename $i`; done
 
        # And all our Lua files
        for i in *.lua; do echo import $i $i; done
 
        # And the LFS image with the rest of everything
-       echo import _lfs_build/luac.out luac.out
-) | ${FWDIR}/tools/spiffsimg/spiffsimg \
-     -f spiffs-${CONFNAME}.img \
-     -S 32m -U ${FWSZ} \
-     -o /dev/fd/1 -r /dev/fd/0
-
-echo
+       #  We could, and used to, but we now go via the nodemcu partition tool
+       # echo import _lfs_build/luac.out luac.out
+) | ./firm/tools/spiffsimg/spiffsimg \
+     -f spiffs-${BOARDNAME}.img \
+     -c 262144 \
+     -r /dev/fd/0