Commit Graph

1937 Commits

Author SHA1 Message Date
Johny Mattsson 3b65262922 Less memory leaks if not coding in a rush... 2016-09-22 19:50:46 +10:00
Johny Mattsson 1f073e8b3f Added notes on stdio. 2016-09-22 18:20:40 +10: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 8e23335c0f Removed more unused legacy code. 2016-09-22 11:42:25 +10:00
Johny Mattsson 55e8c65b8d More developer notes. 2016-09-22 11:42:13 +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 fe602d2d7e Removed all currently-unused code & docs.
Heading towards having only ESP32-aware/capable code in this branch.
2016-09-21 13:47:44 +10:00
Johny Mattsson ddeb26c458 Start of developer docs for RTOS/ESP32. 2016-09-21 13:31:43 +10:00
Johny Mattsson 51fabc7439 Fixed NodeMCU boot banner.
Build for ESP32 on Travis.
2016-09-20 14:19:50 +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
Johny Mattsson b4f0681913 Updated toolchain for ESP32. 2016-09-15 13:50:00 +10:00
Johny Mattsson 6abc1c32f3 Add ESP32 builds to CI, use new toolchains. 2016-06-25 23:18:42 +10:00
Johny Mattsson 79671aa526 Teach Lua LTR about ESP32 drom0 location.
This fixes the rather unexpected Fatal Exception(9) crashes when executing
something as trivial as "=type(4)". Also ensured the #if/#else structure
will complain loudly next time we port to a new board.
2016-06-24 18:17:38 +10:00
Johny Mattsson b3e8eddf14 Sort out mapping of virtual <-> flash addresses.
The irom0_flash.bin file gets written to offset 0x40000 in flash. Said file
has the following layout

  | irom0 | text | data | rodata | chksum |

...so the previous approach of having a _flash_used_end symbol at the end of
the irom0 section no longer gives us an accurate view of how much of the flash
is used.
2016-06-24 15:40:48 +10:00
Johny Mattsson afbbeb4566 Replaced UART driver.
New driver is a three-way merger between Espressif's esp8266-rtos-sdk example
driver, Espressif's esp32-rtos-sdk not-example driver, and the previous
NodeMCU driver, plus some general clean-ups.

Basic interactivity is now available on the ESP32!
2016-06-23 18:23:04 +10:00
Johny Mattsson f9c65b945c Disabled -Wl,--gc-sections for SDK libs.
Running without interrupt vectors not considered all that useful...

Disabled flash-size-byte-setting and SPIFFS formatting on ESP32, for now
at least, as both of these appeared to corrupt the flash and prevent
subsequent boots.

Disabled UART init on ESP32 until the driver gets updated.

This now gets us to a banner on ESP32, but not yet a prompt.
2016-06-22 18:58:25 +10:00
Johny Mattsson fd9fa71541 Ensure ESP32 bins are created fresh.
Just appending to previously built bins was not a successful approach...
2016-06-21 19:16:35 +10:00
Johny Mattsson d33945b68b Moved sdk submodules for easier branch switching. 2016-06-21 18:06:04 +10:00
Johny Mattsson 4695eb3b12 Update TravisCI build instructions...
...to deal with the subdirs under bin/
2016-06-09 20:45:44 +10:00
Johny Mattsson 224788b642 Make NodeMCU compile and link for ESP32.
A fair bit of reshuffling with include paths and overrides was necessary, as
the two RTOS SDKs (ESP8266 and ESP32) don't have the same header structure
(or even libraries for that matter). Uses the xtensa-esp108-elf toolchain
to build.

Completely untested beyond linking, as I still can't flash the ESP32 module
I have :(  I'd be most surprised if it does anything useful at this point
considering I've spent almost no time on the linker script or UART setup.

Anything using espconn has been ifdef'd out since espconn is not (and
probably will not be) available. Notably this includes the entire net module
as well as coap, mqtt and enduser_setup.

Many (most?) hardware bus drivers and related modules are also ifdef'd
out for now due to hardware differences. Functions surrounding sleep,
rtc and RF modes have also been hit by the ifdef hammer. Grep'ing for
__ESP8266__ and/or FIXME is a quick way of finding these places. With
time I hope all of these will be reinstated.
2016-06-09 18:40:56 +10:00
Johny Mattsson 0df2eda6c0 Take two of Makefile cleanup.
There is no reason to even be rebuilding SDK lwIP - that was just a legacy
of the initial transition to the RTOS SDK.
2016-06-03 12:59:19 +10:00
Johny Mattsson e82e6e85b8 Cleaned up top-level Makefile.
Now doesn't recurse into the rtos-sdk for every subdir, does clean lwip, etc.
2016-06-03 12:43:14 +10:00
Johny Mattsson b8d9ad16d1 Fixed wrong macro usage. 2016-06-03 12:42:03 +10:00
Johny Mattsson a3b9ffe36a Bump nodemcu RTOS stack even higher for now. 2016-06-02 18:38:01 +10:00
Johny Mattsson af9df2ae98 Fixed output redirection regression (and improved it). 2016-06-02 18:29:00 +10:00
Johny Mattsson 860aa47dc1 Replacement system_set_os_print() function. 2016-06-02 15:49:56 +10:00
Johny Mattsson c378298000 Updated SNTP module for RTOS compatibility. 2016-06-01 17:14:08 +10:00
Johny Mattsson 740c06b48f Fix unwanted newlines in Lua output.
The old NodeMCU puts() did not do the standard newline, while the RTOS C
library one certainly does.
2016-06-01 14:15:13 +10:00
Johny Mattsson 61291bd87b Shunt tmr callbacks into the Lua RTOS task.
The os_timer callback is executed from task rtT, prio 14, so they preempt
the Lua environment whenever they fire. Ideally we should be using the
RTOS timers instead, which run at prio 2 and thus would be more suited
for our uses.
2016-06-01 13:44:57 +10:00
Johny Mattsson 239af986df Debug functions for tracking RTOS task usage.
Since configUSE_TRACE_FACILITY is not enabled :(
2016-05-31 18:46:59 +10:00
Johny Mattsson e15dfee13f Fixed missing args to printf.
Having the actual function prototype for the internal print() function
would be useful...
2016-05-31 18:42:48 +10:00
Johny Mattsson 75dbc59ba9 Fixes to task reimplementation to make UART work. 2016-05-31 13:56:47 +10:00
Johny Mattsson 56789592fa Boot to (nonresponsive) Lua prompt on RTOS!
Uart driver currently disabled as it's not (yet) compatible with RTOS.

Running Lua task with excessive stack to avoid smashing it; need to work out
what's using so much stack space.

Changed some flash reading functions to not attempt to drop an entire 4k
flash page onto the stack.

Ensure the task pump doesn't attempt to retrieve from uninitialised queues.
2016-05-30 17:56:33 +10:00
Johny Mattsson 97568e98d9 Wrap printf to avoid lots of unnecessary mallocs. 2016-05-30 14:15:29 +10:00
Johny Mattsson 4995bcb9d0 Rewrite of exception handler, take 2.
Turns out ets_printf() lied to me. When handed an aligned string in flash it
did 32bit loads on it instead of the expected 8bit loads, so just silencing
the exception was enough to give the appearance of it working.
2016-05-30 14:03:15 +10:00
Johny Mattsson 5eb7b53967 The SDK "flashchip" symbol changed from ptr to struct.
Dereferencing struct contents considered harmful...
2016-05-27 12:21:00 +10:00
Johny Mattsson e49f2bb13f Remove conflicting libc, rename c_xx and os_xx to xx.
c_strtod and c_getenv are kept since strtod doesn't appear in the SDK's libc,
and we want our own c_getenv to initialize the Lua main anyway.
2016-05-26 18:50:20 +10:00
Johny Mattsson 3a3e9ee0fd Removed left-over user exception bits. 2016-05-26 18:31:09 +10:00
Johny Mattsson 6f9c84d802 Shuffle all rodata back into IROM.
With a working exception handler all of the RTOS-SDK bits seem to be happy too.
So far.
2016-05-26 15:47:33 +10:00
Johny Mattsson 7f92bf64be Completely reworked user exception handler.
Incidentally now also a whole lot faster.
2016-05-26 15:19:20 +10:00
Johny Mattsson 5c39a1f664 Reimplemented the NodeMCU task interface on top of RTOS.
Not yet hooked up to an RTOS task, however.
2016-05-24 20:36:00 +10:00
Johny Mattsson f3e2a3afd9 Initial pass at switching to RTOS SDK.
This compiles, links, and starts the RTOS without crashing and burning.

Lua environment does not yet start due to the different task architecture.

Known pain points:

  - task implementation needs to be rewritten for RTOS (next up on my TODO)

  - secure espconn does not exist, all secure espconn stuff has been #if 0'd

  - lwip now built from within the RTOS SDK, but does not appear to include
    MDNS support. Investigation needed.

  - there is no access to FRC1 NMI, not sure if we ever actually used that
    however. Also #if 0'd out for now.

  - new timing constraints introduced by the RTOS, all use of ets_delay_us()
    and os_delay_us() needs to be reviewed (the tsl2561 driver in particular).

  - even more confusion with ets_ vs os_ vs c_ vs non-prefixed versions.
    In the long run everything should be switched to non-prefixed versions.

  - system_set_os_print() not available, needs to be reimplemented

  - all the RTOS rodata is loaded into RAM, as it apparently uses some
    constants while the flash isn't mapped, so our exception handler can't
    work its magic. This should be narrowed down to the minimum possible
    at some point.

  - with each task having its own stack in RTOS, we probably need change
    flash-page buffers from the stack to the heap in a bunch of places.
    A single, shared, page buffer *might* be possible if we limit ourselves
    to running NodeMCU in a single task.

  - there's a ton of junk in the sdk-overrides now; over time the core code
    should be updated to not need those shims
2016-05-24 16:05:02 +10:00
Marcel Stör afd974c5e9 Correct socket:send example, fixes #1303 2016-05-22 21:50:57 +02:00
Marcel Stör 498cc52ab3 Remove deploy section (#1300) 2016-05-21 17:45:33 +02:00
Arnim Läuger 2bb6e407a3 Initialize cb for unsubscribe and unref it upon socket deletion. (#1305)
Thank you.
2016-05-21 08:25:16 -04:00