Commit Graph

46 Commits

Author SHA1 Message Date
Jade Mattsson b78477f2b0 Fix 2x SPIFFS mounting/formatting related issues.
- If the initial filesystem mounting fails, then a subsequent file.format()
  does not mount it afterwards, necessitating a node.restart(). In the normal
  case, after file.format() the filesystem is mounted and ready for use.
  We now explicitly remount after a format to gain consistent behaviour.

- If using USB CDC, the auto-format on first boot interferes with USB
  enumeration, resulting in a failed startup. We now avoid doing an
  auto-format if the USB CDC console is enabled. The behaviour is
  configurable/overrideable via Kconfig.
2024-10-17 15:24:02 +11:00
serg3295 a78abd41b4
Add node.info() (#3655) 2024-07-31 09:43:15 +02:00
Jade Mattsson 53da95b5ae Fix uart.on('data') on console
With the switch to use the IDF's stdin for feeding the Lua VM, we
unintentionally lost the ability to use uart.on('data') on the console uart.
This is since we no longer install the nodemcu uart driver on said uart.
In order to resolve this shortcoming, this commit refactors the uart.on('data')
delimiter handling and moves it away from platform.c into uart.c where it
really belongs. A new function, uart_feed_data(), is introduced, which is used
both by the nodemcu uart driver task as well as the nodemcu console driver
task (assuming the console is in fact a uart).

The linebuffer allocation/freeing is still in response to
uart.start()/uart.stop(), but it is now in uart.c rather than
platform.c.

The whole uart integration is still too tightly coupled between the platform
component and the module component's uart.c, but this makes it slightly
better at least.
2024-05-21 16:22:51 +10:00
Christoph Thelen 14cdff107f
Update rmt translator (#3629)
* Choose the number of RMT buffers in the ws2812 module.

The number of buffers required for optimal operation should be selected
by the ws2812 module, not the caller.

* Add parameters for RGB LED bit times.

This patch adds compatibility for different RGB LEDS besides the WS2812.
ESP evaluation boards like the ESP32-C3-DevKitM-1 use an SK68XXMINI-HS
RGB LED which does not respond to the timings of this module.
The patch adds optional parameters for the bit timings to the write
function. If the new parameters are not supplied, the old values are used.
An example for the SK68XXMINI-HS is provided in the documentation.

* Remove restrictions from RTM translator.

The old RMT translator was not able to split the bits of the source
data into the size requested by the RMT transmitter. Either all 8 bits
of an input byte were translated or none.
The new routine removes the restriction by delivering exactly the
requested amount of data to the transmitter, which results in a more
balanced buffering of translated data under load.

* Add a parameter for the RGB LED reset time.

This patch introduces a new optional parameter for the reset time
in the RGB LED communication. The default is 51.2 microseconds. A
value of 0 sends no reset signal, which allows a small optimisation
for consecutive write commands.

Please note that the reset time of the old code should be 50
microseconds, as the define WS2812_DURATION_RESET suggested. Due to the
restrictions of the old RMT translator routine, it was slightly
increased to 51.2 microseconds. This patch keeps the value of 51.2
microseconds to be as compatible as possible.

* Minimize the time drift between RMT channels.

Place all RMT channels in a group to minimize the time drift between
the signals. Please note that this feature is not available on all
platforms.

* Fix the description of the SK6812 LED in the example code.

The SK6812 expects the data for the green LED first, then red and
finally blue. It should be described as a GRB LED.
2024-02-07 17:56:17 -05: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 670bf2d6a6
Make UART buffer sizes configurable. (#3500)
Also corrects assumption about number of UARTs available.
2022-01-26 11:32:24 +11:00
Christoph Thelen 8b1ef35b66
Consider RMT channel limitations at allocation time. (#3481)
* Consider RMT channel limitations at allocation time.

The ESP32-C3 is limited to TX on channel 0-1 and RX on channel 2-3.
2022-01-07 14:50:28 +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 fbef7feae1 Discard old console driver.
The IDF provides all we need these days, and the old driver was just
needlessly conflicting with the IDF settings and setup.

This also simplifies our uart input path as we no longer need to
duplicate the raw byte handling for when "run_input" is false.
2021-08-23 23:00:54 +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 7c07f91483 Reset user version values
Undos changes from #3135
2020-09-17 18:17:24 +02:00
Nathaniel Wesley Filardo dd3b217df2
Kconfig: rename LUA_MODULE_* to NODEMCU_CMODULE_* (#3135)
Using the NODEMCU_ namespace prefix makes it obvious that these are not
part of Lua proper (contrast, e.g., LUA_BUILTIN_STRING).  Using
"CMODULE" gives us room to differentiate between modules whose
implementation is in C and whose implemenation is in Lua ("LMODULE").

The ESP8266 branch can adopt the same convention when it moves to
Kconfig; see https://github.com/nodemcu/nodemcu-firmware/issues/3130
2020-08-23 22:49:18 +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
devsaurus e30904b607 force common intr alloc flags for all platform components that use rmt
remove ESP_INTR_FLAG_IRAM to fix #2564
2019-05-31 23:34:15 +02:00
devsaurus 5faf76b762 update to u8g2 2.25.10
- new displays
- binding for updateDisplay() and updateDisplayArea()
- use user_ptr instead of hal workaround
2019-04-28 22:26:37 +02:00
Javier Peletier 577e2ea8b2 uart: added uart.getconfig() (#2633) 2019-01-29 22:28:37 +01:00
Skirmantas Lauzikas 3257e557d4 ESP32: add support for RS485 (#2559)
* ESP32: add support for RS485

This commit adds support for switching UART mode to RS485/IRDA.
Also included are patches for memory leaks then handling UART events other than data.

* ESP32: Documentation for uart.setmode()
2018-11-30 12:07:05 +01:00
devsaurus dc0c6ff65d pack-port bits and pieces in spiffs.c:
- implement file.size for spiffs (#1516)
- fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
- Handle error condition in file.read() (#1599)
2018-11-04 08:49:17 +01:00
devsaurus fdb96f51be update file and vfs to master 2018-11-04 00:42:08 +01:00
devsaurus 45c63a8236 Add ucg module. 2018-10-07 16:31:28 +02:00
devsaurus 8d0a8a5763 refactor task wdt handling to platform layer 2018-04-04 09:25:47 +02:00
devsaurus 8d843e5beb fix task wdt to handle PANIC situations and spiffs formatting 2018-04-02 21:17:18 +02:00
devsaurus 64f8ac2876 u8g2: add rfb support 2017-07-27 23:29:37 +02:00
devsaurus a56a7b2775 init ws2812_chains during platform_init 2017-06-20 23:09:14 +02:00
devsaurus a8ff8f059d Add u8g2 module. 2017-06-13 18:38:09 +02:00
zelll 329bd73b63 ESP32: uart 1/2 supports (#1982)
* uart 1/2

* call -> pcall in uart_on_* functions

* fix docs

* fixed console driver when using custom console uart

* fixed line_inverse and error callback

* fixed a crash when uart.start() called more than one time
2017-06-13 18:33:32 +02:00
devsaurus fb62011ddf Add sdmmc module and enable fatfs. 2017-04-30 22:49:54 +02:00
zelll b7fa8c592f ADC extension for ESP32 (#1927)
* added adc extension

* add adc_number, for adc2
2017-04-24 21:36:01 +02:00
devsaurus 018a67a710 establish flushing of uart to leverage buffering putchar() 2017-04-18 22:43:03 +02:00
devsaurus 1866e6f457 Add ws2812 module. 2017-04-14 19:56:27 +02:00
devsaurus 927ee7fc5f Add dht module. 2017-04-14 19:18:38 +02:00
devsaurus e2fdd4adbe Manage RMT channel resources with alloc()/release(). 2017-04-01 10:09:10 +02:00
devsaurus 961c1c72b2 Add ow module. 2017-03-17 07:50:31 +01:00
devsaurus f5632f41f9 extend i2c master with hardware interfaces for synchronous and asynchronous operation 2017-02-04 20:14:13 +01:00
devsaurus 381726f103 add i2c module 2017-02-02 21:40:36 +01:00
devsaurus 4fcb1404b6 add simga_delta module 2017-01-13 22:34:24 +01:00
Johny Mattsson d369953328 Auto-create SPIFFS partition if not found.
The heuristics could probably be improved a lot, but this is better than
nothing at least.
2016-09-22 18:19:39 +10:00
Johny Mattsson 60339b812b SPIFFS partition support, file module from dev.
Now uses the designated partition (type 0xC2, 0x00) unconditionally.
2016-09-22 17:18:22 +10:00
Johny Mattsson 0fe0096c04 Platform flash layer updated for ESP32.
It would appear my ESP3212 only has a 2MB flash chip despite the
bootloader saying 4MB.
2016-09-22 14:56:40 +10:00
Johny Mattsson 6cd3111d79 Platform interface to flash partition info. 2016-09-22 13:09:56 +10:00
Johny Mattsson 6f54c38e53 Grabbed fatfs from dev branch, and IDF-ified it. 2016-09-21 18:21:44 +10:00
Johny Mattsson 4f1b33d522 Grabbed latest spiffs + vfs layer from dev branch.
Also included the recent LVM fix.

Platform flash layer not yet functional.
2016-09-21 18:14:15 +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
Johny Mattsson a463d764eb WIP ESP32 IDF port.
Currently the UART driver break boot (or at least output).
2016-09-16 18:11:42 +10:00