【发布时间】:2017-01-25 21:04:01
【问题描述】:
我使用 spiffsimg 创建了一个包含多个 lua 文件的单个文件:
# ./spiffsimg -f lua.img -c 262144 -r lua.script
f 4227 init.lua
f 413 cfg.lua
f 2233 setupWifi.lua
f 7498 configServer.lua
f 558 cfgForm.htm
f 4255 setupConfig.lua
f 14192 main.lua
#
然后我使用 esptool.py 将 NodeMCU 固件和包含 lua 文件的文件刷写到 esp8266(NodeMCU 开发套件):
c:\esptool-master>c:\Python27\python esptool.py -p COM7 write_flash -fs 32m -fm dio 0x00000 nodemcu-dev-9-modules-2016-07-18-12-06-36-integer.bin 0x78000 lua.img
esptool.py v1.0.2-dev
Connecting...
Running Cesanta flasher stub...
Flash params set to 0x0240
Writing 446464 @ 0x0... 446464 (100 %)
Wrote 446464 bytes at 0x0 in 38.9 seconds (91.9 kbit/s)...
Writing 262144 @ 0x78000... 262144 (100 %)
Wrote 262144 bytes at 0x78000 in 22.8 seconds (91.9 kbit/s)...
Leaving...
然后我运行 ESPLorer 来检查状态并得到:
PORT OPEN 115200
Communication with MCU..Got answer! AutoDetect firmware...
Can't autodetect firmware, because proper answer not received.
NodeMCU custom build by frightanic.com
branch: dev
commit: b21b3e08aad633ccfd5fd29066400a06bb699ae2
SSL: true
modules: file,gpio,http,net,node,rtctime,tmr,uart,wifi
build built on: 2016-07-18 12:05
powered by Lua 5.1.4 on SDK 1.5.4(baaeaebb)
lua: cannot open init.lua
>
----------------------------
No files found.
----------------------------
>
Total : 3455015 bytes
Used : 0 bytes
Remain: 3455015 bytes
NodeMCU 固件正确刷入,但找不到 lua 文件。
我试过刷到其他位置(0x84000、0x7c000),但我只是根据github上的阅读线程猜测这些位置。
我使用 NodeMCU file.fscfg() 例程来获取闪存地址和大小。如果我只刷新 NodeMCU 固件,我会得到以下信息:
print (file.fscfg())
524288 3653632
534288 是 0x80000,所以我尝试只将 spiffsimg 文件 (lua.img) 刷新到 0x8000,然后运行相同的打印语句并得到:
print (file.fscfg())
786432 3391488
闪存地址增加了 lua.img 中的确切字节数 - 我不明白,为什么闪存地址会改变? file.fscfg返回的第一个数字是不是flash的起始地址,而是flash的结束地址?
刷入由 spiffsimg 创建的包含 lua 文件的图像文件的正确地址是什么?
【问题讨论】:
标签: lua esp8266 firmware nodemcu flash-memory