Commit Graph

541 Commits

Author SHA1 Message Date
Alex March 81407729a5 esp8266/modesp: Implement flash_write(), flash_erase(). 2016-02-08 11:42:24 +02:00
Damien George 5b3f0b7f39 py: Change first arg of type.make_new from mp_obj_t to mp_obj_type_t*.
The first argument to the type.make_new method is naturally a uPy type,
and all uses of this argument cast it directly to a pointer to a type
structure.  So it makes sense to just have it a pointer to a type from
the very beginning (and a const pointer at that).  This patch makes
such a change, and removes all unnecessary casting to/from mp_obj_t.
2016-01-11 00:49:27 +00:00
Paul Sokolovsky adfe4ff72a esp8266: Support CFLAGS_EXTRA. 2016-01-08 01:30:20 +02:00
Paul Sokolovsky 43fecb0acb esp8266/modesp: Allow to compile out proprietary espconn stuff. 2015-12-30 15:53:51 +02:00
Paul Sokolovsky fce0036a67 esp8266: mac() function belongs to network module per the latest API. 2015-12-27 10:03:32 +02:00
Damien George 84b245f187 lib/utils: Add pyexec_frozen_module to load and execute frozen module.
This is a convenience function similar to pyexec_file.  It should be used
instead of raw mp_parse_compile_execute because the latter does not catch
and report exceptions.
2015-12-26 12:32:33 +00:00
Paul Sokolovsky abd0fcfc86 esp8266: Remove superfluous includes. 2015-12-21 22:08:06 +02:00
Paul Sokolovsky e13d462f77 esp8266/modesp: flash_read() takes 2 args (fix typo). 2015-12-21 22:07:11 +02:00
Paul Sokolovsky 90202b4c0d esp8266/modesp: Implement flash_read(offset, size_bytes) function.
Based on vendor API documentation, untested on real hardware.
2015-11-24 23:29:26 +02:00
Paul Sokolovsky 73ff0687f2 lib/utils/printf: Move from stmhal/ .
This file contains various MicroPython-specific helper functions, so isn't
good fit for lib/libc/.
2015-11-10 18:58:58 +02:00
Damien George 40274fec9c lib/pyexec: Move header pyexec.h from stmhal directory. 2015-11-09 13:13:09 +00:00
Paul Sokolovsky 0ec51441de stmhal: pyexec.c is common module, move to lib/utils/ . 2015-10-31 19:35:10 +03:00
Damien George 731f359292 all: Add py/mphal.h and use it in all ports.
py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for.  A
port will also provide mphalport.h with further HAL declarations.
2015-10-31 19:14:30 +03:00
Paul Sokolovsky 6a09e7d7ae esp8266: Switch to standard mp_hal_ticks_ms() MPHAL function. 2015-10-29 19:40:05 +03:00
Paul Sokolovsky ebd9f550e8 esp8266: Switch to standard mp_hal_delay_ms() MPHAL function. 2015-10-29 13:03:59 +03:00
Paul Sokolovsky 5699fc9d0e esp8266: Switch to standard mp_hal_delay_us() MPHAL function. 2015-10-29 02:06:58 +03:00
Paul Sokolovsky 0dbd928cee Makefiles: Remove duplicate object files when linking.
Scenario: module1 depends on some common file from lib/, so specifies it
in its SRC_MOD, and the same situation with module2, then common file
from lib/ eventually ends up listed twice in $(OBJ), which leads to link
errors.

Make is equipped to deal with such situation easily, quoting the manual:
"The value of $^ omits duplicate prerequisites, while $+ retains them and
preserves their order." So, just use $^ consistently in all link targets.
2015-10-24 15:46:53 +03:00
Damien George f09f8097d5 esp8266: Put more code in irom0 section, to get it building again. 2015-10-20 22:59:31 +01:00
Paul Sokolovsky e0f5df579b all: Make netutils.h available to all ports by default.
Generally, ports should inherit INC from py.mk, append to it, not
overwrite it. TODO: Likely should do the same for other vars too.
2015-10-19 18:32:42 +03:00
Damien George 0334058fa4 Rename "Micro Python" to "MicroPython" in REPL, help, readme's and misc. 2015-10-12 00:06:25 +01:00
Bill Owens e2bfa471fa esp8266: Added wlan.isconnected() to maintain parity with other ports. 2015-09-15 20:07:50 +03:00
Damien George 229b908d2e esp8266: Remove "time" command from deploy target. 2015-09-12 22:22:30 +01:00
Bill Owens a66a99bfd8 esp8266: Added wifi_mode() to read and set WiFi operating mode. 2015-08-29 16:58:51 +03:00
Damien George 75b1d881ec esp8266: Use m_new/m_renew/m_del funcs instead of private gc_xxx. 2015-07-20 12:14:21 +01:00
Paul Sokolovsky ab14c30493 esp8266: modesp: Update for gc_realloc() refactor.
TODO: Contributed code in modesp incorrectly uses private gc_* API.
2015-07-19 00:28:16 +03:00
Paul Sokolovsky b19d273beb esp8266: Allow to easily override programming baudrate. 2015-07-04 00:36:10 +03:00
Damien George de8b585ab7 esp8266: Make pyb.RTC a type, and pyb.RTC() constructs an RTC object.
This is the standard way of doing things, one should construct a
peripheral object (even if it's a singleton).

See issue #1330.
2015-06-22 23:03:17 +01:00
Bill Owens 60ccb41fac esp8266: Move status() from esp module to network 2015-06-20 23:35:55 +03:00
Paul Sokolovsky a193ced7fa esp8266: README: Typo fix. 2015-06-19 21:09:53 +03:00
Paul Sokolovsky b6a08208e1 esp8266: Explicit warning that port is experimental and subject to change. 2015-06-18 11:46:43 +03:00
Radomir Dopieralski 0cba23716d ESP8266: Update the README.md to reflect what works 2015-06-18 11:42:05 +03:00
Bill Owens 686516f90a esp8266: Move scan from esp module to network 2015-06-17 23:13:12 +03:00
Bill Owens 3ce212e0a6 esp8266: Changed esp_scan to keep the current WiFi operating mode but throw an exception if WiFi is in AP only mode 2015-06-14 10:57:08 +03:00
Paul Sokolovsky 32eb4b9055 esp8266: Move connect/disconnect from "esp" module to network. 2015-06-12 17:45:28 +03:00
Paul Sokolovsky ee3fec3167 esp8266: Add skeleton "network" module.
MicroPython "network" module interface requires it to contains classes
to instantiate. But as we have a static network interace, make WLAN()
"constructor" just return module itself, and just make all methods
module-global functions.
2015-06-12 17:45:20 +03:00
Paul Sokolovsky 431603ad69 esp8266: esp_connect(): The function is now vararg.
Fixes regression from a previous commit.
2015-06-12 14:26:44 +03:00
Paul Sokolovsky a32538bb66 esp8266: Do not call espconn_create in constructor of esp.socket.
Turns out this is supposed to be called only for UDP connections.

Patch by Josef Gajdusek.
2015-06-02 22:40:06 +03:00
Paul Sokolovsky 2fc1e64319 esp8266: Fix lost chars problem when block-xfering data (e.g., when pasting).
Pasting more or less sizable text into ESP8266 REPL leads to random chars
missing in the received input. Apparent cause is that using RTOS messages
to pass individual chars one by one is to slow and leads to UART FIFO
overflow. So, instead of passing chars one by one, use RTOS msg to signal
that input data is available in FIFO, and then let task handler to read
data directly from FIFO.

With this change, lost chars problem is gone, but the pasted text is
truncated after some position. At least 500 chars can be pasted reliably
(at 115200 baud), but 1K never pastes completely.
2015-06-01 23:57:19 +03:00
Josef Gajdusek 7d8edeff4e esp8266: Update to SDK version 1.1.0 (MIT-licensed).
1. Updated linker script, now user app appears to contain exception vector
table and oesn't work (faults) without it.
2. Commened out support for GPIO pulldown, which was removed in this SDK
version without clear explanation, but apparently because it was released
without proper validation, and now turns out it doesn't work as expected,
or there's a different function there.
2015-05-30 20:58:59 +03:00
Josef Gajdusek 286ced4c2f esp8266: Add a bunch of miscellaneous methods 2015-05-28 21:38:46 +03:00
Josef Gajdusek 25a8a42447 esp8266: Add pyb.ADC class 2015-05-28 21:31:37 +03:00
Josef Gajdusek 492fd5cb6b esp8266: Enable setting CPU frequency to 160MHz 2015-05-28 21:28:29 +03:00
Josef Gajdusek 967f3230f5 esp8266: Move initialization to system_init_done_cb
Initializing too early caused some of the API functions (wifi_*) to fail
when called in main.py
2015-05-26 22:22:08 +03:00
Josef Gajdusek 59610c4004 esp8266: Add uos module
Currently implements only .uname()
2015-05-26 22:18:07 +03:00
Josef Gajdusek 1c132c8587 esp8266: Add configuration option for redirecting the built-in OS output 2015-05-13 18:03:00 +02:00
Josef Gajdusek 40c6d57804 esp8266: Actually use the decimal part of system_rtc_clock_cali_proc() 2015-05-13 17:59:36 +02:00
Damien George 304a96d7d6 esp8266: Put more literal and text obj data in irom0_0_seg.
With newer versions of esp_iot_sdk the iram1_0_seg started to overflow.
Now it doesn't.

Addresses issue #1254.
2015-05-13 14:49:14 +01:00
Damien George 4e7dc97bdc esp8266: Add module weak links; link time to utime. 2015-05-13 00:18:41 +01:00
Josef Gajdusek 103d12a877 esp8266: Add utime and pyb.RTC 2015-05-13 00:12:54 +01:00
Josef Gajdusek b47931978f esp8266: Update the linker script
Moved modesp.o to flash and increased size of the irom0_0_seg segment. The new
value was taken from NodeMCU linker script.
2015-05-13 00:12:54 +01:00
Josef Gajdusek 800d5cd16f esp8266: Implement time functions 2015-05-12 23:47:18 +01:00
Josef Gajdusek bda7041294 esp8266: Add support for frozen modules 2015-05-06 22:04:20 +01:00
Josef Gajdusek d39d96b700 esp8266: Add .onsent callback support
The function passed to socket.onsent() gets called after data is succesfully
sent by the socket.
2015-05-06 21:47:44 +01:00
Josef Gajdusek 2d56df67cd esp8266: Initialize socket->connlist to NULL
This was causing crashes in .onconnect()
2015-05-06 21:47:43 +01:00
Josef Gajdusek 28076f3d4b esp8266: Fix garbage collector by hard-coding stack end address.
As user_init() is not a true main functions, the stack pointer captured within
is not pointing at the base of the stack. This caused gc_collect being called
with sp being higher than stack_end, causing integer overflow and crashing as
gc tried to scan almost the entire address space.
2015-05-06 14:01:07 +01:00
Damien George c98c128fe8 pyexec: Make raw REPL work with event-driven version of pyexec.
esp8266 port now has working raw and friendly REPL, as well as working
soft reset (CTRL-D at REPL, or raise SystemExit).

tools/pyboard.py now works with esp8266 port.
2015-05-06 00:02:58 +01:00
Damien George 3d91b1f67f esp8266: Return CPU frequency in Hz. 2015-05-05 22:23:23 +01:00
Josef Gajdusek 82d08dccc6 esp8266: Fix endian of address returned by esp.getaddrinfo() 2015-05-05 22:19:48 +01:00
Josef Gajdusek 9e00ac89d5 esp8266: Add esp.socket class, with ESP-style socket functionality.
* UDP currently not supported
 * As there is no way (that I know of) the espconn_regist_connectcb()
   callback can recognize on which socket has the connection arrived,
   only one listening function at a time is supported
2015-05-04 11:48:40 +01:00
Josef Gajdusek 7e7039b53c esp8266: Export station status() constants 2015-05-03 22:07:00 +03:00
Damien George 7f9d1d6ab9 py: Overhaul and simplify printf/pfenv mechanism.
Previous to this patch the printing mechanism was a bit of a tangled
mess.  This patch attempts to consolidate printing into one interface.

All (non-debug) printing now uses the mp_print* family of functions,
mainly mp_printf.  All these functions take an mp_print_t structure as
their first argument, and this structure defines the printing backend
through the "print_strn" function of said structure.

Printing from the uPy core can reach the platform-defined print code via
two paths: either through mp_sys_stdout_obj (defined pert port) in
conjunction with mp_stream_write; or through the mp_plat_print structure
which uses the MP_PLAT_PRINT_STRN macro to define how string are printed
on the platform.  The former is only used when MICROPY_PY_IO is defined.

With this new scheme printing is generally more efficient (less layers
to go through, less arguments to pass), and, given an mp_print_t*
structure, one can call mp_print_str for efficiency instead of
mp_printf("%s", ...).  Code size is also reduced by around 200 bytes on
Thumb2 archs.
2015-04-16 14:30:16 +00:00
Paul Sokolovsky 3a84c8b58d string0.c: Move from stmhal/ to lib/. 2015-04-05 21:57:55 +03:00
Damien George 87c6250b4c esp8266: Add basic pyb.Pin class; supports output mode only. 2015-02-13 22:21:44 +00:00
Damien George 0b32e50365 stmhal: Make pybstdio usable by other ports, and use it.
Now all ports can use pybstdio.c to provide sys.stdin/stdout/stderr, so
long as they implement mp_hal_stdin_* and mp_hal_stdout_* functions.
2015-02-13 15:04:53 +00:00
Damien George 0bfc7638ba py: Protect mp_parse and mp_compile with nlr push/pop block.
To enable parsing constants more efficiently, mp_parse should be allowed
to raise an exception, and mp_compile can already raise a MemoryError.
So these functions need to be protected by an nlr push/pop block.

This patch adds that feature in all places.  This allows to simplify how
mp_parse and mp_compile are called: they now raise an exception if they
have an error and so explicit checking is not needed anymore.
2015-02-07 18:33:58 +00:00
Paul Sokolovsky d6f648d04f esp8266: modesp: Add status() function for connection status. 2015-02-05 00:39:02 +02:00
Paul Sokolovsky 1cd47c6315 esp8266: modesp: Add disconnect() function to disconnect from WiFi AP. 2015-02-03 02:02:29 +02:00
Paul Sokolovsky 471b2a8906 esp8266: modesp: Add connect() function to connect to WiFi AP. 2015-02-01 01:36:48 +02:00
Paul Sokolovsky 8fff7f8d38 esp8266: Add "reset" target to Makefile.
Just always keep jumper in bootloader position. After flashing, uPy
automatically executed. And to get back to bootloader, do "make reset".
2015-01-31 00:51:39 +02:00
Paul Sokolovsky eca9a9323a esp8266: Update ROM address map to vendor SDK 0.9.5. 2015-01-31 00:36:41 +02:00
Paul Sokolovsky 5fb775a0c0 esp8266: Handle exceptions in callback. 2015-01-25 17:41:06 +02:00
Paul Sokolovsky 6ec650b41f esp8266: Add "esp" module with esp8266-specific "cooperative" networking.
So far implements .scan(lambda x: print(x)) function to scan for WiFi access
points.
2015-01-25 17:10:06 +02:00
Paul Sokolovsky 438b3d26b5 esp8266: Add missing hard_reset qstr. 2015-01-18 00:37:46 +02:00
Paul Sokolovsky f1700a5154 esp8266:modpyb: Implement hard_reset(). 2015-01-18 00:30:14 +02:00
Paul Sokolovsky f12ea7c7ed esp8266: Implement task-based, event-driven interface with UART.
This enables proper interfacing with underlying OS - MicroPython doesn't
run the main loop, OS does, MicroPython just gets called when some event
takes place.
2015-01-16 19:20:17 +02:00
Paul Sokolovsky c6b8750c14 esp8266: Use dedicated heap allocated as static array.
We cannot assume that all memory belongs to us - it actually belongs to
ESP8266 OS.
2015-01-15 00:36:03 +02:00
Paul Sokolovsky 06e9cb688b esp8266: Update for readline module moved to lib/. 2015-01-12 04:27:36 +02:00
Damien George 4a5895c4eb py: Disable stack checking by default; enable on most ports. 2015-01-09 00:10:55 +00:00
Damien George 3b51b3e90f stmhal: Collect all root pointers together in 1 place.
A GC in stmhal port now only scans true root pointers, not entire BSS.
This reduces base GC time from 1700ms to 900ms.
2015-01-07 23:38:50 +00:00
Damien George b4b10fd350 py: Put all global state together in state structures.
This patch consolidates all global variables in py/ core into one place,
in a global structure.  Root pointers are all located together to make
GC tracing easier and more efficient.
2015-01-07 20:33:00 +00:00
Damien George fe7d542352 esp8266: Prefix includes with py/; remove need for -I../py. 2015-01-01 21:16:58 +00:00
Damien George 9ddbe291c4 py: Add include guards to mpconfig,misc,qstr,obj,runtime,parsehelper. 2014-12-29 01:02:19 +00:00
Paul Sokolovsky d4f80f58b8 esp8266/README: Fix typos. 2014-12-06 13:34:18 +02:00
Damien George b395220ef0 esp8266: Add README.md. 2014-11-29 15:06:20 +00:00
Damien George 3b603f29ec Use MP_DEFINE_CONST_DICT macro to define module dicts.
This is just a clean-up of the code.  Generated code is exactly the
same.
2014-11-29 14:39:27 +00:00
Damien George e636279fe0 esp8266: Move more rodata to irom section.
rodata can only go in iram/irom if it's accessed only using word loads
(ie no byte or half-word access).
2014-11-29 14:36:18 +00:00
Damien George d96e6b14c9 esp8266: Make default ESP_SDK variable work correctly.
When esp-open-sdk is built with STANDALONE=y (the default) then ESP_SDK
is set to the correct value, so that "make" just works.
2014-11-28 18:05:25 +00:00
Damien George fbea810043 esp8266: Change bignum from mpz to longlong; move some rodata to iram.
Some rodata items can go in iram/irom segment, but not others.  With
this patch ESP now has 24256 bytes of heap ram.  It passes 228 out of
248 tests from tests/basics directory.
2014-11-28 14:58:25 +00:00
Damien George 5f10065718 esp8266: Provide sensible default ESP_SDK; deploy 2 the images together. 2014-11-28 10:22:01 +00:00
Paul Sokolovsky 1bbc389d67 esp8266: Allow to override serial port. 2014-11-28 01:54:46 +02:00
Damien George 075d597464 esp8266: New port of Micro Python to ESP8266 wifi module. 2014-11-27 20:30:33 +00:00