Commit Graph

75 Commits

Author SHA1 Message Date
Philip Gladstone 868f3747ea Removed some unused code. Also made chipid do something on all platforms 2022-10-06 22:49:13 -04:00
Philip Gladstone dcab2d195f Merge remote-tracking branch 'origin/dev-esp32-idf4' into usbcdc-only 2022-10-07 01:06:13 +00:00
Joo Aun Saw d24f2ae459 platform uart: really feed uart data to both console and on-data cb 2022-08-30 18:14:57 +10:00
Joo Aun Saw ca0a2b3f47 platform: platform_uart_setup handles null ptr 2022-08-29 20:53:17 +10:00
Joo Aun Saw 01b94f31dc uart: feed rx data to both lua console and on-data callback 2022-08-29 20:52:03 +10:00
Philip Gladstone fe0fd813a5 Now works when having an init.lua 2022-08-14 18:04:47 -04:00
Philip Gladstone 384aff1d09 Add support for the USB CDC Serial JTAG console 2022-08-07 16:48:46 +00:00
h2zero b8ae6ca6f8 Explicitly set RMT config::flags.
If this variable is not set in the config it may contain random data and set the clock source to the REF_CLK
resulting in timing errors, the DHTx, DS18B20 and ws2812 devices to not communicate.
2022-06-04 16:00:19 +10: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
Bernd Meyer 6db8c43480 Prevent memory leak in UART driver when message handling is slow 2021-11-04 20:54:56 +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 8e5ce49d19 Update to latest IDF master. 2021-08-24 10:24:49 +10: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 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 bc7b923646 Code cleanup to sort out warnings.
I2S constants have changed; docs updated.
2021-07-29 13:47:45 +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
f4grx bfd2259165 Avoid the use of invalid GPIOS when setting up a one-wire bus. (#2934)
Fixes #2933
2019-10-29 22:34:15 +01:00
Johny Mattsson b0558d5bbe
Fix uart regressions & bugs (#2817)
* Fix uart regressions & bugs.

Using `uart.on()` with a search character was broken in that it did
not invoke the callback on a full UART buffer as documented. Logic reworked
to match docs again.

Fixed memory leak on `task_post()` failure (eep!).

Improved logic to attempt to coalesce input bytes to reduce the number of
`task_post()` slots used up by the platform uart.

Finally, added a semaphore to prevent the platform uart from overrunning
the `task_post()` slots all the time on high baud rates (e.g. 1mbit).
With the semaphore in there, the LVM RTOS task gets a chance to actually
process the received data and free up a `task_post()` slot or two.
The above mentioned read coalescing then allows the platform uart to
immediately catch up.

Also added an error log message if the `task_post()` actually does fail.

* Don't cache the uart delims.

Doing so makes reconfiguring those settings from within the callback not
take effect until the currently buffered bytes have been processed.
2019-10-13 09:49:44 +11: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
devsaurus fa35e02481 update fatfs to 0.13c 2019-01-17 21:12:08 +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
Arnim Läuger 9bd8df4693 Use custom parition table with 1.5MB for firmware (#2567) 2018-11-23 20:16:36 +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 358379fd90 Updated ESP-IDF to latest. 2018-10-07 12:33:40 +02:00
devsaurus 45be28cf60 fix and document template partition table 2018-04-15 22:55: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 4702c1f181 align source from esp8266 port 2017-12-18 22:06:47 +01:00
devsaurus 7448d21afa Updated ESP-IDF to latest. 2017-09-12 22:22:20 +02:00
devsaurus 9f8664b8e6 Updated ESP-IDF to latest and adapt spi master. 2017-09-02 11:38:19 +02:00
devsaurus 64f8ac2876 u8g2: add rfb support 2017-07-27 23:29:37 +02:00
devsaurus 5ee043cfb9 fix pin handling for rmt channels now that GPIO output matrix is cleared with
17747b3358
2017-07-13 23:00:24 +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 1117137363 fix compile warnings 2017-05-05 22:51:21 +02:00
devsaurus fb62011ddf Add sdmmc module and enable fatfs. 2017-04-30 22:49:54 +02:00
devsaurus 31cb312c72 fix insertion of rmt end marker 2017-04-27 23:13:24 +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