-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP8266 vs ESP32 compatibility? #2252
Comments
@Spiritdude Rene, I am one of the committers on the project. Thanks for your comments. A lot are valid. I've just been doing a lot of node.js / NodeRED coding for my Home Automation, and I am strruck by how similar in architecture the NodeNCU framework is to node.js, in that there are both non-blocking event-driven with similarities in the API callback approach. In the case of the ESP8266 implementation this event-driven approach was forced on us by the event driven architecture of the non-OS SDK. However, the ESP32 uses an implementation of RTOS. and so has relaxed some of the constraints. But yes, I feel that we should unify the APIs except where the different architectures mean that the feature / functionality set of the ESP32 is far richer, and even in thee circumstances, we should provide an API superset. And one of our other committers has opened and RFD #2243 along similar lines of thinking. I will post a more detailed response in the next few days. |
For those who code with ESP32, and want same API as of NodeMCU/ESP8266: Lua: modules which provide some compatibility:
Firmware: additionally I started to implement missing functions where Lua isn't suitable: https://github.com/Spiritdude/nodemcu-firmware/tree/dev-esp32
Regardless what will be decided about a common API, I add now code in my repos (either fw or lua) and we later can decide how those can be integrated (at some point the code has to come from somewhere). Update
|
@marcelstoer @TerryE @jmattsson I need some guidance of you "old timers" of NodeMCU . . . as you saw I'm working on a clone/fork of the dev-esp32 at https://github.com/Spiritdude/nodemcu-firmware/tree/dev-esp32 and I head now to implement Now, there are several issues I like your input and guidance:
@jmattsson: I started to walk through your contribution of I have no clue of each one's commitment in |
@Spiritdude If you look at the commit history on the ESP32 branch, then you will see that Johnny and Arnim (@jmattsson and @devsaurus) are the main committers here. I am still focusing on the ESP8266 and to be honest since I've spent the last three years building a house, I haven't had enough time for this let alone getting to grips with the ESP32. My current priorities are to do the LFS release for the ESP8266, then move on to getting Lua 5.3 out. At the moment the ESP32 Lua core is a fork of the ESP8266, and with 5.3 I want to move back to a single unified core codebase. My particular core focus is the Lua engine internals. |
Thanks Rene, I don't work with the ESP32 but I see the issues you raised are all valid. Pretty much agree with you but please don't make Lua look like the acronym that it isn't (i.e. no caps) 😉 Looking forward to you PRs. I'm sure you already saw the contribution guidelines. I have been a bit unhappy with
So, whatever else you decide to add to |
Apologies for the disjointedness of my reply, but I don't have the time to make it better at the moment.
|
@jmattsson and others.
I think there is a misunderstanding between me and most of you committers, I assume NodeMCU is a brand, and stands for an API usable for ESP8266 and ESP32 - whereas for you it seems to stand for "making Lua run on the microcontroller using existing SDK" and caring little to nothing of Lua API compatibility between ESP8266 and ESP32, am I correct? The past days I thought of what to reply, but I feel kind of blocked - I require I took your advise with metatable to do: @jmattsson and @devsaurus Are you willing to change dev-esp32 API to be compatible with ESP8266 where suitable (e.g. coherent constant names and function names) or is this a no-go and you want to be 'free' to introduce new function names and constants and want to keep the existing function names and constants? If you like to achieve better compatibility, I like to go with you into the details of each module and determine if NodeMCU/ESP8266 compatibility can be achieved (e.g. like
and then see if functions can be omitted or reimplemented in C or Lua level. If you prefer another media like email to discuss this or have other preference, let me know, my email is spiritdude at gmail. If anyone reading this has a better idea how to proceed, please let me know. PS: the issue of |
First of all...I like the idea behind nodemcu-shell, very cool. Looks like you're making good progress.
That's due to resource constraints of ESP8266.
The fact that GitHub comments don't allow threading or branching off makes it sometimes really difficult to have effective discussions on topics like this one. However, we maintainers do pretty much everything in the open i.e. hardly ever in private emails or other closed sourced discussions.
It ain't so black and white I'd say. NodeMCU may be a brand (in China), I don't know, but the folks who started all this (devkits & this firmware) went off board in summer 2015. As Johny said "backwards" compatibility just wasn't the top priority for the ESP32 API. That doesn't mean that compatibility should be carelessly dropped when it'd be easy to maintain. On the other hand re-implementing something for a new platform, and that's why "backwards" is in quotes, gives you the nonrecurring opportunity to improve the API. Most of the essential modules where implemented way before the current maintainers came aboard. The way I see it is that your nodemcu-shell use-case isn't a "mainstream" use-case. Anyone building Lua modules/libraries on top of NodeMCU would certainly be interested in a coherent API. End-users, however, wouldn't expect that and can easily be expected to adjust their Lua code I'd argue. What hasn't been discussed here yet is the option of deprecating and eventually removing ESP8266 API. We've done this on a few occasions in the past (WiFi and net modules I believe).
Personally I'd very much appreciate any effort from you to get this started. A GitHub wiki which is free for all to contribute would IMO be a good place to share and discuss: https://github.com/nodemcu/nodemcu-firmware/wiki/ BTW @jmattsson can we delete the ESP31-RTOS migration and drop the GPIO
WiFi
And we only have to do this for current inconsistencies of course. |
Yes, NodeMCU started as a Chinese company with its own registered brand, and the owner and one of his colleagues did all of the initial work on porting Lua up to around version 0.91 if I recall correctly, but there wasn't enough money in the brand to make it financially viable to maintain the sort of commitment that it would take to continue to develop the firmware, so the owner actively transferred the day-to-day control to a bunch of the active contributors. All of the committers here do this work pro-bono, so it very much a community project, though all of us use the NodeMCU firmware for work or personal use. |
@marcelstoer the math functions are commented out in the dev-esp32 branch (as well), which I meant. NodeMCU-Shell is an "app" (an example) which should run on ESP8266 and ESP32 using NodeMCU firmware, I assume many of us have ESP8266 and ESP32 devices, and I like to choose which hardware I need to run my code, I do not want to code specifically for one platform alone - I do want to reuse my code. I have Perl scripts which are 25 years old still working without changes, even running on a tiny ARM-based board. Lua has become for me a viable alternative for Perl - thanks to NodeMCU - but if I code in Lua, I like to reuse it from ESP8266, ESP32, ARM-based boards and on my servers - I don't mind writing I started this wiki page https://github.com/nodemcu/nodemcu-firmware/wiki/ESP8266---ESP32-Compatibility (I used bullet list instead of table as a start, I'm not that experienced to do an elaborate table - feel free to change it if it's more suitable). |
My take is that we should have compatibility between both platforms unless it doesn't make sense. For example, the gpio constant names could have been the same. Arguably the new names are slightly better, but I don't think that is worth the incompatibility to change them. I would be open to having a compiled in compatibility mode that created the extra functions and constants for ESP32 (to allow the running of code written for the esp8266). What I really don't want is to have the same named API which does different things or takes different arguments. |
My head really isn't anywhere near ESP32-space at the moment, so my recollections here may be off base - apologies if so. Regarding the
When I did the initial port of NodeMCU to the ESP32 it was done in the expectation that we would likely end up using the ESP32 at $work, and I was trying to get ahead of the curve. In the end we didn't go down the ESP32 path for various reasons, and my commitments elsewhere has meant I haven't had any time to dedicate to NodeMCU (be it 8266 or 32). Pull Requests for both fixes, improvements and new features are obviously welcomed, whether I'm around or not. I'm just the guy who got the ESP32 port off the ground, I am assuredly not the guy who will make it thrive, nor the Torvalds of NodeMCU on the ESP32 :) |
No activity in months an besides OP no one picked up on https://github.com/nodemcu/nodemcu-firmware/wiki/ESP8266---ESP32-Compatibility -> closing |
I just tried to test my LUA programs on the ESP32, and I realized the API of essential modules, with the same name, have changed:
wifi
andtmr
in particular (there might be more, but those I encountered).I ask, why? To use the same name "NodeMCU" and using the same module names, implies compatibility for me - is this because ESP32 NodeMCU is in development, and eventually compatibility is achieved or?
I coded JS with Mongoose OS last week, and uploaded the same JS code for ESP8266 on the ESP32, and it worked right away - I think NodeMCU as platform should achieve the same, unless this is disregarded by purpose.
Now, it won't be that hard to achieve better compatibility, so the old code works as well, e.g.
tmr.now()
andtmr.time()
doesn't exist on ESP32 but those rather trivial to implement I assume. Yet, I can't assigntmr.now = function()
on my own end in LUA (or let me know if I can), I have to choose another namespace/object name. For example I ended up withtimer.*
as wrapper for both https://github.com/Spiritdude/nodemcu-shell/blob/master/lib/timer.luaWhoever decided to break the API - if this was the case - I want to say, this is a severe decision which has direct impact on the success of "NodeMCU" as a platform - perhaps lead developers might state the more long term plans of it.
I even thought to use LUA on Orange Pi Zero or Nano Pi Neo and alike devices running Linux like Armbian, writing for NodeMCU API with LUA once and running it on multiple IoT devices; but this only works when the API is stable.
Thinking in terms of
Background: I'm new to ESP8266 & ESP32 and LUA (since a few weeks) and I really like it, especially with the NodeMCU platform - I otherwise would not have cared to code in LUA - I'm fine with JS as well (Mongoose OS or Espruino), but it discourages me that I have to keep two versions of the same LUA code or include
arch=='esp8266'
conditions because I run it on a newer processor and changed API. I currently work on a NodeMCU system platform with a shell (like bash) at its core, and an editor (like nano), running on the device itself: https://github.com/Spiritdude/nodemcu-shell (currently very experimental). I started to implement the same shell concept in JS on Mongoose OS (not yet released) and was happy to see my code running on both ESP8266 and ESP32, yet mJS (the JS engine) seems slower than LUA of NodeMCU and some important functionality is missing, like array sorting which I implemented in JS which slows down some of my code immensely, so I still consider LUA.As an overall strategy I would propose (order of priority):
only break API as an absolute last resort(just don't or rename the firmware)Thoughts?
PS: Those who plan to use
nodemcu-tool
to upload LUA code to ESP32, I have a small patch which enables it to do so: https://github.com/Spiritdude/NodeMCU-Tool (the patch is under review and soonish in one way or another adapted in the official repo https://github.com/AndiDittrich/NodeMCU-Tool - btw, the reasonnodemcu-tool
didn't work for ESP32 NodeMCU was the missingnode.info()
).The text was updated successfully, but these errors were encountered: