使用 Esplorer 为 NodeMCU 编译代码

Compiling Code for NodeMCU using Esplorer

我使用了Esplorer的内置编译器来编译.lua超过2KB的文件,无法编译。 NodeMCU 重置并且编译中止。有没有一种方法可以使用 Esplorer 或在 Esplorer 环境之外的任何其他方式编译过多的文件。

您可以在上传前在您的电脑上进行交叉编译。 https://nodemcu.readthedocs.io/en/dev/en/upload/#compiling-lua-on-your-pc-for-uploading 的文档中有一章是关于这个的。

If you install lua on your development PC or Laptop then you can use the standard Lua compiler to syntax check any Lua source before downloading it to the ESP8266 module. However, the nodemcu compiler output uses different data types (e.g. it supports ROMtables) so the compiled output cannot run on the ESP8266.

Compiling source on one platform for use on another (e.g. Intel x38 Window to ESP8266) is known as cross-compilation and the nodemcu firmware supports the compilation of luac.cross on *nix patforms which have Lua 5.1, the Lua filesystem module (lfs), and the essential GCC tools. Simply change directory to the firmware root directoy and run the command:

lua tools/cross-lua.lua

This will generate a luac.cross executable in your root directory which can be used to compile and to syntax-check Lua source on the Development machine for execution under nodemcu lua on the ESP8266.