Commit Graph

341 Commits

Author SHA1 Message Date
Paul Sokolovsky
6afd651f1e esp8266/esp8266.ld: Put axTLS to FlashROM. 2016-04-27 00:45:09 +03:00
Paul Sokolovsky
6149ce01f8 esp8266/Makefile: Add target to build axTLS. 2016-04-27 00:35:13 +03:00
Paul Sokolovsky
90b2cfe644 esp8266/scripts/webrepl: Add "ws://" to "daemon started at" message.
To remind people it's not HTTP.
2016-04-26 12:47:24 +03:00
Paul Sokolovsky
237c519ac4 esp8266/scripts/flashbdev: Use all available Flash for filesystem.
All Flash sans firmware at the beginning and 16K SDK param block at the
end is used for filesystem (and that's calculated depending on the Flash
size).
2016-04-26 01:36:32 +03:00
Paul Sokolovsky
ef2ffc0e4e esp8266/scripts/webrepl: Print client address for incoming connections. 2016-04-26 01:00:28 +03:00
Paul Sokolovsky
c888831410 esp8266/scripts/webrepl: Print connection address.
Based on active network interfaces.
2016-04-26 00:59:30 +03:00
Paul Sokolovsky
6d103b6548 py: Move call_function_*_protected() functions to py/ for reuse.
They almost certainly needed by any C code which calls Python callbacks.
2016-04-25 19:31:17 +03:00
Paul Sokolovsky
4296a8dc5c esp8266/scripts/webrepl: Allow to override port. 2016-04-25 18:44:37 +03:00
Paul Sokolovsky
bd66b09512 esp8266/scripts/webrepl: Don't start on import.
Explicit .start() is required now.
2016-04-25 00:33:27 +03:00
Paul Sokolovsky
8db4f363e9 esp8266/scripts/webrepl: Convert to persistent daemon. 2016-04-25 00:31:43 +03:00
Paul Sokolovsky
7c40b15a3f esp8266/scripts/webrepl: WebREPL based on C-level websocket object. 2016-04-24 23:04:21 +03:00
Paul Sokolovsky
d422e56631 esp8266/scripts/websocket_helper: Disable debug output. 2016-04-22 18:19:54 +03:00
Paul Sokolovsky
eb40769613 esp8266/scripts/websocket_helper: Module encapsulating handshake sequences. 2016-04-22 18:18:27 +03:00
Damien George
b372156f74 esp8266: Change software SPI driver to use general pin HAL. 2016-04-22 10:44:06 +01:00
Damien George
67a6d31955 esp8266: Allow GPIO16 to be used as a pin in the uPy pin HAL.
Now I2C works with GPIO16 as the SCL or SDA pin.
2016-04-22 10:35:26 +01:00
Damien George
a2d5d84ecc esp8266: Convert mp_hal_pin_obj_t from pin ptr to simple integer.
Most pin I/O can be done just knowing the pin number as a simple
integer, and it's more efficient this way (code size, speed) because it
doesn't require a memory lookup to get the pin id from the pin object.

If the full pin object is needed then it can be easily looked up in the
pin table.
2016-04-22 10:04:12 +01:00
Damien George
624738ca64 extmod/machine_i2c: Allow mp_hal_pin_obj_t to be any type, not a ptr. 2016-04-22 09:56:02 +01:00
Damien George
d4f4cb6a24 esp8266/esp_mphal: Remove mp_hal_feed_watchdog.
It doesn't do anything and is not needed.  ets_loop_iter/ets_event_poll
now take care of feeding the WDT.
2016-04-21 15:30:29 +01:00
Damien George
c4e26dd19a esp8266/uart: Remove obsolete UART rx buffering code.
It's now completely replaced by the ringbuf implementation.
2016-04-21 15:27:18 +01:00
Damien George
d46bea9ffa esp8266: Implement UART.read functionality. 2016-04-21 15:19:19 +01:00
Damien George
7652ab77ef esp8266: Add uart_rx_wait and uart_rx_char functions. 2016-04-21 15:19:00 +01:00
Damien George
32d7cf6e44 esp8266: Implement basic deep-sleep capabilities.
Use the machine.deepsleep() function to enter the sleep mode.  Use the
RTC to configure the alarm to wake the device.

Basic use is the following:

    import machine

    # configure RTC's ALARM0 to wake device from deep sleep
    rtc = machine.RTC()
    rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)

    # do other things
    # ...

    # set ALARM0's alarm to wake after 10 seconds
    rtc.alarm(rtc.ALARM0, 10000)

    # enter deep-sleep state (system is reset upon waking)
    machine.deepsleep()

To detect if the system woke from a deep sleep use:

    if machine.reset_cause() == machine.DEEPSLEEP_RESET:
        print('woke from deep sleep')
2016-04-21 11:43:37 +01:00
Paul Sokolovsky
4fa1731b6e esp8266/modnetwork: .config(): Add "hidden ESSID" param. 2016-04-21 00:42:45 +03:00
Paul Sokolovsky
cc1ef76f88 esp8266/scripts/flashbdev: Correct bootloader flash size to match real size.
Flash size as seen by vendor SDK doesn't depend on real size, but rather on
a particular value in firmware header, as put there by flash tool. That means
it's user responsibility to know what flash size a particular device has, and
specify correct parameters during flashing. That's not end user friendly
however, so we try to make it "flash and play" by detecting real size vs
from-header size mismatch, and correct the header accordingly.
2016-04-20 18:07:34 +03:00
Paul Sokolovsky
584406880c esp8266/scripts/_boot: Print notice when initial setup is executed. 2016-04-20 18:01:09 +03:00
Paul Sokolovsky
2494399a42 esp8266/scripts/flashbdev: Disable debug output/checks. 2016-04-20 00:35:46 +03:00
Paul Sokolovsky
46f0641fba esp8266/modnetwork: .config(): Add "channel" param. 2016-04-20 00:25:31 +03:00
Paul Sokolovsky
8dcce92606 esp8266/scripts: Don't try to create filesystem on 512KB devices or less.
There's no space for it.
2016-04-18 17:14:00 +03:00
Paul Sokolovsky
89e56a80b8 esp8266/modesp: Add flash_size() function.
Returns FlashROM size in bytes from vendor SDK's point of view, not
physical size.
2016-04-18 17:12:57 +03:00
Paul Sokolovsky
3a5a35aaec esp8266/scripts/flashbdev: Use all available space in 1MB FlashROM for FS. 2016-04-18 01:23:04 +03:00
Damien George
d76ebde85e esp8266/modesp: Allow esp.deepsleep to take 2nd arg for RF wake opt. 2016-04-17 16:28:47 +01:00
Paul Sokolovsky
89aa7157d0 esp8266/README.md: Update feature list for current state of affairs. 2016-04-17 18:17:49 +03:00
Paul Sokolovsky
7e5715a6d5 esp8266/README.md: Typo fix. 2016-04-17 18:16:36 +03:00
Paul Sokolovsky
6f3b9933bd esp8266/esp_mphal: Protect dupterm_task_handler() from recursive exec. 2016-04-17 18:11:04 +03:00
Paul Sokolovsky
dde9abad16 esp8266/moduos: Add dupterm_notify() function.
Should be called to notify that current dupterm object has more input
data to read.
2016-04-17 18:09:52 +03:00
Damien George
73ccb3fc5b esp8266: Adapt port to use new auto-qstr generation. 2016-04-16 13:20:02 +01:00
Paul Sokolovsky
050e645ef2 esp8266/modmachine: Add reset_cause() function. 2016-04-15 22:08:04 +03:00
Damien George
091dcaea2f esp8266/moduos: Add uos.mkdir function. 2016-04-14 23:37:15 +01:00
Damien George
7d2c685544 esp8266/scripts/_boot: Mount block device on "" instead of "/".
"" is the correct name of the root directory when mounting a device there
(as opposed to "/").  One can now do os.listdir('/') and open('/abc'), as
well as os.listdir() and open('abc').
2016-04-14 22:56:21 +01:00
Paul Sokolovsky
d3ab4bc7ca esp8266/qstrdefsport.h: Mark qstr's for "esp" module. 2016-04-15 00:11:22 +03:00
Paul Sokolovsky
4f811d0e4c esp8266: Enable input() builtin. 2016-04-15 00:08:39 +03:00
Paul Sokolovsky
9b0714b24c py: Declare help, input, open builtins in core.
These are *defined* per-port, but why redeclare them again and again.
2016-04-15 00:07:56 +03:00
Paul Sokolovsky
272fad6d9c esp8266/scripts/port_diag.py: Module to collect diagnostic info.
A shortcut for users to provide background diagnostic info for bug
reports.
2016-04-14 18:54:11 +03:00
Paul Sokolovsky
0a400a6333 esp8266: Switch integer arith routines to BootROM. 2016-04-14 15:06:07 +03:00
Damien George
df3b1741b6 esp8266: Separate 1-wire timing funcs from Python module to save iRAM.
esponewire.c contains low-level timing-critical functions that go in
iRAM.  modonewire.c contains Python wrapper code.
2016-04-14 12:44:26 +01:00
Damien George
674bf1bc81 esp8266: Add hard IRQ callbacks for pin change on GPIO0-15. 2016-04-14 12:44:26 +01:00
Damien George
d9d408135d esp8266: Add dummy entries for non-existing pins to simplify pin logic.
Now pins can be easily looked up in the table using the pin number as the
index and vice versa.
2016-04-14 12:43:25 +01:00
Damien George
a9a732af1f esp8266: Remove pin_id field from C pin object.
This field is the same as phys_port and not needed.
2016-04-14 12:43:25 +01:00
Damien George
0a2e9650f5 py: Add ability to have frozen persistent bytecode from .mpy files.
The config variable MICROPY_MODULE_FROZEN is now made of two separate
parts: MICROPY_MODULE_FROZEN_STR and MICROPY_MODULE_FROZEN_MPY.  This
allows to have none, either or both of frozen strings and frozen mpy
files (aka frozen bytecode).
2016-04-13 16:07:47 +01:00
Paul Sokolovsky
959ed931a4 esp8266/esp_mphal: call_dupterm_read(): Fix order of deactivating on EOF.
First deactivate, then print diagnostic message.
2016-04-13 16:35:50 +03:00
Paul Sokolovsky
19e3c9d53a esp8266/esp_mphal: Don't swallow exceptions in dupterm's read()/write().
The idea is that if dupterm object can handle exceptions, it will handle
them itself. Otherwise, object state can be compromised and it's better
to terminate dupterm session. For example, disconnected socket will keep
throwing exceptions and dump messages about that.
2016-04-13 16:34:17 +03:00
Paul Sokolovsky
47442d9f52 lib/utils/printf: Rework overriding printer of DEBUG_printf().
By default it uses mp_plat_print, but a port may override it to another
value with MICROPY_DEBUG_PRINTER_DEST.
2016-04-13 11:53:12 +03:00
Damien George
3177ef544f esp8266: In callback helpers, pop nlr_buf on successful call.
nlr_pop must be called if no exception was raised.

Also, return value of these callback helpers is made void because ther
is (currently) no use for it.
2016-04-13 00:01:28 +01:00
Damien George
e813ea1070 esp8266: Enable framebuf module. 2016-04-12 14:06:54 +01:00
Damien George
a525493e40 esp8266: Switch from using custom I2C driver to generic extmod one. 2016-04-12 14:06:54 +01:00
Damien George
ac63ca7bc5 esp8266: Implement basic C-level pin HAL. 2016-04-12 14:06:54 +01:00
Damien George
1a65ff1b72 esp8266: Protect modpyb.h header file from multiple inclusions.
Also include py/obj.h so the header is self contained.
2016-04-12 14:06:54 +01:00
Damien George
3a37426b29 esp8266/scripts/inisetup.py: Use "-" in AP ESSID instead of space. 2016-04-12 00:47:21 +03:00
Paul Sokolovsky
260b839483 esp8266/scripts/inisetup.py: Set WPA/WPA2 AP mode with a predefined password. 2016-04-12 00:46:04 +03:00
Paul Sokolovsky
40f5ecd3a8 esp8266: Add Python modules for initial configuration.
Main entry point is _boot.py which checks whether FAT FS in flash mountable,
and if so, mounts it. Otherwise, it checks if flash is empty, and if so,
performs initial module setup: makes FAT FS, configures default AP name,
etc. As a last option, if flash is not empty, and could not be mounted,
it means filesystem corruption, and warning message with instructions is
printed in an infinite loop.
2016-04-12 00:37:04 +03:00
Paul Sokolovsky
2f5935269b esp8266/scripts/main.py: Remove stale file. 2016-04-12 00:35:13 +03:00
Paul Sokolovsky
54b89665fc esp8266/modnetwork: .config(): Add "password" param (W/O). 2016-04-12 00:18:40 +03:00
Paul Sokolovsky
7acc252e93 esp8266/modnetwork: .config(): Add "authmode" param. 2016-04-12 00:17:31 +03:00
Paul Sokolovsky
6f3fc9bfa1 esp8266/modnetwork: .config(): Check interface whose config is requested. 2016-04-12 00:16:16 +03:00
Paul Sokolovsky
f49d63a75c esp8266: Enable websocket module. 2016-04-11 21:25:43 +03:00
Paul Sokolovsky
1cc81ed449 esp8266/modesp: Add freemem() and meminfo() functions.
They call into vendor SDK functions system_get_free_heap_size() and
system_print_meminfo() respectively.
2016-04-11 01:16:38 +03:00
Paul Sokolovsky
c734de490a esp8266/main: mp_builtin_open(): Implement, using vfs_proxy_call(). 2016-04-10 16:59:19 +03:00
Damien George
6e87aeb841 esp8266: Implement multistage bootstrap sequence.
Upon start-up, _boot module is executed from frozen files to do early
initialization, e.g. create and mount the flash filesystem. Then
"boot.py" is executed if it exists in the filesystem. Finally, "main.py"
is executed if exists to allow start-on-boot user applications.

This allows a user to make a custom boot file or startup application
without recompiling the firmware, while letting to do early initialization
in Python code.

Based on RFC https://github.com/micropython/micropython/issues/1955.
2016-04-10 14:24:41 +03:00
Damien George
2c407bcf20 esp8266: Switch from terse error messages to normal ones.
Adds 2k to the code size.
2016-04-07 00:38:08 +03:00
Paul Sokolovsky
d85439fd19 esp8266/README: Add short troubleshooting section. 2016-04-07 00:21:04 +03:00
Damien George
1a0a323ca8 esp8266: Add initial implementation of machine.UART.
Currently UART(0) and UART(1) are exposed and only uart.write works.
2016-04-06 19:45:52 +03:00
Damien George
96eca22322 esp8266: Make destination for vendor OS debug output soft-configurable.
Use esp.osdebug(None) to disable, or esp.osdebug(uart_id) to send output
to a UART.
2016-04-06 00:12:58 +03:00
Paul Sokolovsky
2c8356c482 esp8266/modnetwork: require_if(): Report the actual interface required. 2016-04-05 16:09:03 +03:00
Paul Sokolovsky
de12502d89 esp8266: Move pyb.unique_id() to machine.unique_id(). 2016-04-05 00:57:49 +03:00
Paul Sokolovsky
81fd5685fc esp8266: Move pyb.hard_reset() to machine.reset(). 2016-04-05 00:20:25 +03:00
Paul Sokolovsky
69256ac0b1 esp8266: Bump heap size to 24k. 2016-04-03 19:55:45 +03:00
Paul Sokolovsky
debbaac1bd esp8266: Update flashing instructions in README. 2016-04-03 16:04:18 +03:00
Paul Sokolovsky
919b70b7ec esp8266: Switch back to flashing combined firmware (single file).
With gap between segments minimized, there's not much padding to flash,
so no big speed overhead.
2016-04-03 15:48:46 +03:00
Paul Sokolovsky
8d2bcaf3cd esp8266: Minimize gap between Inst/DataRAM segments and FlashROM segment.
With .rodata being in FlashROM now, gap can be much smaller now. InstRAM
can be max 32K, and with segment headers, that already makes it more than
32K. Then there's some .data still, and the next Flash page boundary is
0x9000. That figure should be more or less future-proof.

TODO: Refactor makeimg to take FlashROM segment offset from file name.
2016-04-03 15:45:14 +03:00
Paul Sokolovsky
9698a60591 esp8266/ets_alt_task: Comment out debug output. 2016-04-03 01:04:01 +03:00
Paul Sokolovsky
fcd6862597 esp8266: Bump iROM size to 512k.
Needed for frozen scripts, and for future growth of binary.
2016-04-03 00:57:27 +03:00
Paul Sokolovsky
ef0c5db2ed esp8266: Move .rodata where it belongs with -mforce-l32 help. 2016-04-03 00:51:51 +03:00
Paul Sokolovsky
333a63efaa esp8266/README: Add link to docs. 2016-04-03 00:01:31 +03:00
Damien George
a0cb4eda9a esp8266: Use VM_HOOK to call ets_loop_iter within the VM.
Starting with a divisor of 10, pystone_lowmem gives a score of 256.
2016-04-02 01:34:32 +03:00
Damien George
6a051a8e0b esp8266/uart: Get ctrl-C working now that event-based REPL is disabled. 2016-04-01 14:53:01 +03:00
Damien George
fb6cc96951 esp8266/uart: Comment out old, unused rx buffering code.
This was originally used for non-event based REPL processing.  Then it
was unused when event-based processing was activated.  But now that event
based is disabled, and non-event based is back, there has been new ring
buffer code to process the chars.
2016-04-01 14:30:47 +03:00
Paul Sokolovsky
fc4c43a72e esp8266: Switch to non event-driven REPL to support paste mode. 2016-04-01 14:22:28 +03:00
Paul Sokolovsky
785cf9a61f esp8266: Support dedicated REPL loop (aka pull-style).
Event-driven loop (push-style) is still supported and default (controlled
by MICROPY_REPL_EVENT_DRIVEN setting, as expected).

Dedicated loop worked even without adding ets_loop_iter(), though that
needs to be revisited later.
2016-04-01 14:02:36 +03:00
Paul Sokolovsky
777232c9a5 esp8266: Disallow recursive calls to REPL.
Before this change, if REPL blocked executing some code, it was possible
to still input new statememts and excuting them, all leading to weird,
and portentially dangerous interaction.

TODO: Current implementation may have issues processing input accumulated
while REPL was blocked.
2016-04-01 12:53:50 +03:00
Paul Sokolovsky
5531437941 esp8266: Move PHY mode constants from modesp to modnetwork. 2016-04-01 12:10:11 +03:00
Damien George
4b597a1c1a esp8266: Reset term_obj on reboot.
Also, term_obj can be NULL if socket enables REPL duplication signalling
before os.dupterm is called, so it should be checked.
2016-03-31 19:56:52 +03:00
Paul Sokolovsky
98af891610 esp8266: Implement input part of dupterm handling.
The idea is following: underlying interrupt-driven or push-style data source
signals that more data is available for dupterm processing via call to
mp_hal_signal_dupterm_input(). This triggers a task which pumps data between
actual dupterm object (which may perform additional processing on data from
low-level data source) and input ring buffer.
2016-03-31 19:49:55 +03:00
Paul Sokolovsky
61fa7c8152 esp8266: Switch back to accumulating input data via ring buffer.
But now it's generic ring buffer implemented via ringbuf.h, and is intended
for any type of input, including dupterm's, not just UART. The general
process work like this: an interrupt-driven input source puts data into
input_buf, and then signals new data available via call to
mp_hal_signal_input().
2016-03-30 18:50:38 +03:00
Paul Sokolovsky
2e75a17bab esp8266: Fix issue when current repl line was garbage-collected.
Reference it from root pointers section.
2016-03-30 18:13:03 +03:00
Damien George
9475cc59e6 esp8266: Support synchronous wifi scanning.
That is: aps = if0.scan()

TODO: make sure that returned list has tuple with values in "standard"
order (whatever that standard is).
2016-03-30 11:35:03 +03:00
Paul Sokolovsky
d88250c06e esp8266: Reduce heap size for now to avoid random segfaults on WiFi connect. 2016-03-29 21:14:41 +03:00
Paul Sokolovsky
c4506ed869 esp8266: Let esp8266 "os" messages go to standard (REPL) UART.
That's definitely helpful for debugging.
2016-03-29 21:10:10 +03:00
Paul Sokolovsky
402a743821 esp8266/esp_mphal: Add support for debug UART-only output.
Helpful when debugging dupterm support (because otherwise all output is
spooled to dupterm too).

To use:

mp_printf(&mp_debug_print, "...");
2016-03-29 11:48:43 +03:00
Paul Sokolovsky
8fc5e56a6a esp8266: Enable uos.dupterm() method. 2016-03-29 11:41:23 +03:00
Paul Sokolovsky
c961889e34 esp8266: Add basic support for duplicating REPL output. 2016-03-29 11:13:32 +03:00