Commit Graph

30 Commits

Author SHA1 Message Date
Jade Mattsson d483fd94d8 Upgrade IDF to 5.3.1 2024-10-14 11:57:23 +11:00
serg3295 a78abd41b4
Add node.info() (#3655) 2024-07-31 09:43:15 +02:00
Jade Mattsson 3b9ef17d33 Added node.chipmodel().
Updated and removed incorrect node module documentation.
2024-05-21 16:22:51 +10:00
Jade Mattsson 4cdebe7191
Initial support for ESP32-C6 and ESP32-H2, plus assorted fixes & improvements (#3646)
* Proof-of-concept multi-type console support via stdio

* Address crashes on linput's use of printf.

On an empty line input, a C3 with UART console would panic while attempting
to output the new Lua prompt. The backtrace shows a xQueueSemaphoreTake
with uxItemSize==0 as the panic cause, deep inside the uart driver, invoked
via vfs_uart and vfs_console layers, from printf.
Similarly, the printf for outputting a backspace/erase sequence would also
trigger a panic.

This workaround (of not mixing fflush() with printf) is likely merely hiding
a deeper issue, but it appears to be consistent. Plus, printf with no args
and a user-supplied format string is a no-no and should be fixed anyway.

* Work around IDF inconsistency with stdout buffering.

* Increase console task stack size.

Seems on Xtensa it ended up not being enough.

* Switch to single-byte console reads.

* Stop cheating and feed Lua from the right context.

* Work around IDF buffering stdout even when told not to, on ACM consoles.

* Initial build support for esp32c6.

Plus fixup of module selection for a variety of targets.

* Update github actions to node 20 versions.

* Update github build to deal with Lua 5.3 being default.

* Address fatal compiler warning.

Newer IDF toolchain is stricter, and we'd apparently failed to build test
the Lua-5.1 path for some time.

* Initial build support for esp32h2.

* Upgrade IDF to v5.1.3

* Fix left-over incorrect type in uzlib.

* Avoid null pointer crashes when debugging startup.

* Workaround for using wifi module on S2 with USB-CDC console.

---------

Co-authored-by: Jade Mattsson <github@frozenlogic.org>
2024-04-26 17:35:22 -04:00
Johny Mattsson 6798f027f3 Upgrade to IDF v5.1.2 2024-02-02 14:50:57 +11:00
Johny Mattsson f126b6fe91 Initial migration to IDFv5.0
Plenty of dependency adjustments, printf format specificier updates,
FreeRTOS type and macro name modernisation, not to mention API changes.

Still plenty of legacy/deprecated drivers in use which will need updating.

The following features have been removed due to no longer being available
from the IDF:
  - ADC hall effect sensor reading
  - Configuration of SD SPI host via sdmmc module (now must be done first
    via the spimaster module)
  - FAT partition selection on external SD cards; only the first FAT
    partition is supported by the IDF now

On the other hand, the eth module now supports the following new chipsets:
  - KSZ8001
  - KSZ8021
  - KSZ8031
  - KSZ8051
  - KSZ8061
  - KSZ8091
  - Possibly additional models in the LAN87xx series (the IDF docs aren't
    clear on precisely which models are handled)

Further, the sdmmc module is now available on the ESP32-S3 as well.
2024-01-30 11:34:03 +11:00
Johny Mattsson 38ccd7b2ba Upgrade IDF to v4.4.2
Slightly reworked embed_lfs.sh to better cope with attribute size changes
in future compiler versions, without needing to be updated again.

RMT register naming changed once again...
2022-10-12 16:14:40 +11:00
h2zero c75ec760aa Fix node.compile fwrite size check.
The return value from fwrite was being checked against the size of the data rather than the number of bytes written.
This caused node.compile() to falsely return failure.
2022-06-04 15:55:00 +10:00
Philip Gladstone 8f9295b09e
Update to the released version of idf4.4 (#3498)
* Update to the released version of idf4.4

* Try to get the CI Build to work in all cases
2022-01-25 20:54:17 -05:00
Johny Mattsson a0c9085cca Make node.output() RTOS thread safe.
Also removed old, very unsafe node.osoutput(). We're now integrating cleanly
with the IDF/newlib way of redirecting stdout.

Added necessary depends in Kconfig to ensure VFS support is enabled, as
otherwise you'd only get a mysterious crash when attempting to enable
output redirection.
2021-11-04 22:24:01 +11:00
Johny Mattsson a2ba49e36b Switch to IDF-provided VFS and standard `io` module.
The IDF-provided VFS resolves several issues:

 - The IDF components having a different view of the (virtual) file system
   compared to the Lua environment.

 - RTOS task/thread safety. Our legacy VFS was only ever safe to use
   from the LVM thread, which limited its usability. Upgrading it
   would have effectively required a reimplementation of the IDF VFS,
   which would have been a bigger task with larger on-going maintenance
   issues.

 - We're no longer needing to maintain our own SPIFFS component.

 - We're no longer needing to maintain our own FATFS component.

 - The legacy of the 8266's lack of standard C interface to the file system
   is no longer holding us back, meaning that we can use the standard
   Lua `io` module rather than the cobbled-together swiss army knife
   also known as the file module.

Of course, the downside is that we'll either have to declare a backwards
breakage in regard to the file module, or provide a Lua shim for the old
functions, where applicable.

Also included is some necessary integer type fixups in unrelated code,
which apparently had depended on some non-standard types in either the
SPIFFS or FATFS headers.

A memory leak issue in the sdmmc module was also found and fixed while
said module got switched over to the Espressif VFS.

Module documentation has been updated to match the new reality (and I
discovered in some places it wasn't even matching the old reality).
2021-10-20 21:49:11 +11:00
Johny Mattsson 185855b69a Brought over node.setonerror() functionality.
Now properly triggering restart on non-interactive errors.
2021-08-26 11:33:42 +10:00
Johny Mattsson 93140a89a5 Swap to luaL_pcallx for C module callbacks.
Bring on that stacktracey goodness!
2021-08-24 00:11:31 +10:00
Johny Mattsson 3af14a367b Rework modules handling to support ESP32-S2/S3 too. 2021-08-22 21:25:24 +10:00
Johny Mattsson 17df207a5f Port Terry's Lua 5.1 + 5.3 work from the esp8266 branch.
Changes have been kept to a minimum, but a serious chunk of work was
needed to move from 8266isms to IDFisms.

Some things got refactored into components/lua/common, in particular
the LFS location awareness.

As part of this work I also evicted our partition table manipulation
code, as with the current IDF it kept breaking checksums and rendering
things unbootable, which is the opposite of helpful (which was the
original intent behind it).

The uart module got relocated from base_nodemcu to the modules component
properly, after I worked out how to force its inclusion using Kconfig alone.
2021-08-22 02:03:05 +10:00
Johny Mattsson f123d46209 Add ESP32C3 support/coexistence.
The uzlib and parts of Lua had to be switched over to use the
C standard int types, as their custom typedefs conflicted with
RISC-V toolchain provided typedefs.

UART console driver updated to do less direct register meddling
and use the IDF uart driver interface for setup. Still using our
own ISR rather than the default driver ISR. Down the line we
might want to investigate whether the IDF ISR would be a better
fit.

Lua C modules have been split into common and ESP32/ESP32-S
specific ones. In the future there might also be ESP32-C3
specific modules, which would go into components/modules-esp32c3
at that point.

Our old automatic fixup of flash size has been discarded as it
interferes with the checksumming done by the ROM loader and
results in unbootable systems. The IDF has already taken on
this work via the ESPTOOL_FLASHSIZE_DETECT option, which handles
this situation properly.
2021-08-11 17:32:47 +10:00
Johny Mattsson 16ef39e255 idf4: overhaul to new build system, part 1 of 3
Yet to come:
  - part 2: dealing with deprecated and removed APIs
  - part 3: making it actually work again
2021-07-15 16:27:03 +10:00
Marcel Stör 3acb6b7c79
Add node.bootreason (#3413) 2021-04-02 08:03:17 +02:00
tomsci d5f0094576
Add node.sleep()(#3370)
Supporting wakeup from (non-EXT1) GPIO, UART, ULP, timer and touch
2021-01-17 09:00:12 +01:00
Kit Klein 830366188d
Add node.osoutput() method for ESP32 (#3363) 2021-01-05 12:34:35 +01:00
tomsci fa2348f36b
Support for GPIO wakeup in node.dsleep() (#3115) 2020-08-22 10:32:45 +02:00
Johny Mattsson eaac369dec
LFS support for ESP32 NodeMCU (#2801)
* Port LFS from ESP8266 to ESP32
2019-07-22 19:13:43 +10:00
Javier Peletier 1d8c4554fc node: node.output() (#2637) 2019-01-31 22:03:41 +01:00
tomsci d2345f2beb esp32: Add node.uptime() function using esp_timer_get_time() (#2533)
* esp32: Reinstate tmr.now() function using esp_timer_get_time()

Also added larger limit before wrapping if Lua's number type supports
it.

* Renamed tmr.now() to node.uptime()

Added second return value to indicate timer wrap
2018-11-10 14:53:10 +01:00
Johny Mattsson dbc8d791c6 Added node.chipid() based on esptool's formula. 2017-03-02 22:29:40 +11:00
Johny Mattsson d48265348a Fixed various warnings. 2016-11-27 13:28:48 +11:00
Johny Mattsson c4911ca391 Updated to latest IDF.
This fixes the panic-on-restart issue and the crash-on-uart-input-before-flash-mapped issue.

Node module updated to reflect new function names for sleep/restart.
2016-11-25 10:51:49 +11:00
Johny Mattsson 16e19442c1 Added node.osprint().
Implemented in terms of esp_log_level_set() at this point.
2016-09-28 17:57:29 +10:00
Johny Mattsson 6349fc8622 Most of the node module from dev.
node.dsleep() no longer takes options.
node.output() not yet supported (needs syscall registration/chaining support)

Dynamic CPU frequency changing not currently supported in the IDF.
Various chip IDs not currently available/obtainable.
Boot reason completely revamped in ESP32, will need new code.
2016-09-26 18:04:24 +10:00
Johny Mattsson 9bbf8f43fb Successfully boot barebones NodeMCU on ESP32 (only).
RTOS driver evicted as it did not play nice with stdio etc.

Implemented a minimal driver to fully support Lua console on UART0. Output
on UART0 done via stdout (provided by the IDF). Input and setup handled
via driver_console/console.c. In addition to the direct input function
console_getc(), the driver also registers in the syscall tables to enable
regular stdio input functions to work (yay!). The Lua VM is still using the
direct interface since it's less overhead, but does also work when going
through stdin/fd 0.

Auto-bauding on the console is not yet functional; revisit when the UART docs
are available.

Module registration/linking/enabling moved over to be Kconfig based. See
updates to base_nodemcu/include/module.h and base_nodemcu/Kconfig for
details.

The sdk-overrides directory/approach is no longer used. The IDF is simply
too different to the old RTOS SDK - we need to adapt our code directly instead.

Everything in app/ is now unused, and will need to be gradually migrated
into components/ though it is probably better to migrate straight from the
latest dev branch.
2016-09-20 13:35:56 +10:00