This is a brainstorming development blog of creating a NodeMCU/Linux “firmware” or rather environment. The main aim would be that NodeMCU Lua code runs on multiple hardware
- NodeMCU/ESP8266 (mature)
- NodeMCU/ESP32 (infant, API partially diverts from ESP8266 API)
and new on
such as
- Raspberry Pi, Raspberry Pi Zero,
- Orange Pi Series (e.g. Orange Pi Lite or Zero),
- NanoPi Series (e.g. NanoPi Neo)
essentially any board or device which is capable to run a Linux distribution and has low level GPIO, I2C and alike interfaces to use.
Base modules which need to be implemented:
- adc
- bit (built-in)
- file: mostly implemented, vastly untested
- gpio: partially implemented, untested
- i2c: skeleton only
- math (built-in)
- net: partially implemented, vastly untested
- node: mostly implemented
- ow (1-Wire)
- sdmmc
- sigma delta
- sjson: partially implemented
- spi
- struct (built-in)
- tmr: mostly implemented but not well tested
- u8g2
- uart
- wifi
or check the detailed state of modules of NodeMCU/Linux.
Supported boards (2018/03/12):
Board | OS | Success |
---|---|---|
NanoPi NEO | Armbian 5.38 | BUILDS, BOOTS, STARTUP |
Orange Pi Zero | Armbian 5.27 | BUILDS, BOOTS, STARTUP |
Orange Pi Lite | Armbian 5.27 | BUILDS, BOOTS, STARTUP |
Raspberry Pi Zero | Raspbian 9.1 | BUILDS, BOOTS, STARTUP |
Update 2018/03/11: Raspberry Pi Zero (Raspbian 9.1) support added, a few changes were required, thanks to @devsaurus who tested and provided patch for LuaNode build. New options:
-s
or--silent
: hide boot banner-e
or--execute
: all arguments are executed, e.g.nodemcu -e 'table.foreach(_sysinfo,print)'
Update 2018/03/05: experimentally using LuaNode backend (#!/usr/bin/luanode
) to take advantage of async IO, timers and network functionality: tmr.create():*
mostly working but not much tested yet. net.createConnection()
and net.createServer()
somewhat working, but vastly untested.
First session of NodeMCU Shell (right) running on NodeMCU/Linux (left) running on my laptop:
Update 2018/03/04: preliminary tmr.create():*
infrastructure prepared, not yet functional (requires non-blocking environment).
Update 2018/03/02: node.setcpufreq()
added, with loose settings (e.g. choosing next close frequency out of a table), for example NanoPi Neo (Allwinner H3) lists following frequency table (which might be limited by the current cpu policy):
... NodeMCU/Linux 0.0.3 powered by Lua 5.1, Device ID: 4310175 / 0x41c49f armv7l (4 cores, 240-1200MHz) modules: node tmr file gpio i2c rtctime sjson bit struct math cpu freq table [MHz]: 60, 120, 240, 312, 408, 480, 504, 528, 576, 600, 624, 648, 672, 720, 768, 816, 864, 912, 960, 1010, 1060, 1100, 1150, 1200, 1250, 1300, 1340, 1440, 1540 I [0.158] execute init.lua I [0.159] dofile ./init.lua ...
Update 2018/03/01: detailed function overview of which part is implemented at NodeMCU/Linux Wiki, more complete node.*
and file.*
functions.
Update 2018/02/27: sjson added, first automated tests with luaunit, added file.stat() and file.list(), and released code to github.com/Spiritdude/nodemcu-linux .
Update 2018/02/26: cpu
benchmark on various hardware:
- Acer Laptop: 54684 LuaKIPS (Intel i7-6700HQ / 8 cores @2.60GHz)
- Orange Pi Lite: 3604 LuaKIPS (Allwinner H3 @480MHz)
- Orange Pi Zero: 1870 LuaKIPS (Allwinner H2 @240MHz)
- NanoPi Neo: 1853 LuaKIPS (Allwinner H3 @240MHz)
- ESP8266: 645 LuaKIPS (@180MHz)
- ESP32: 746 LuaKIPS (@240MHz)
Running NodeMCU/Linux on Orange Pi Zero, Orange Pi Lite, and NanoPi Neo:
Update 2018/02/25: The code isn’t released yet, but will show up within the next days or 1-2 weeks at https://github.com/Spiritdude/nodemcu-linux
First test (Version 0.0.2) with following modules present (some only partially implemented): node
, tmr
, file
, gpio
(untested), rtctime
, bit
(built-in) and math
(built-in) running NodeMCU/Linux (nodemcu
) within the “NodeMCU Shell” project directory, and manually call a “shell” command cpu
which does a simple benchmark: