Commit Graph

588 Commits

Author SHA1 Message Date
Damien George
9c04ef2a67 unix,stmhal,esp8266: When find'ing frozen files don't use extra slash.
This extra forward slash for the starting-point directory is unnecessary
and leads to additional slashes on Max OS X which mean that the frozen
files cannot be imported.

Fixes #2374.
2016-08-31 15:12:57 +10:00
Damien George
59a9509703 esp8266/modules/ds18x20.py: Add support for DS18S20 devices. 2016-08-29 12:45:07 +10:00
Damien George
8e9b98e974 esp8266/modules/onewire: Change onewire.read() to onewire.readinto().
This allows 1-wire drivers (eg DS18X20) to perform in-place operations and
hence do less memory allocations.
2016-08-29 12:27:21 +10:00
Damien George
9fba618356 esp8266/modules: Split onewire.py into OneWire and DS18X20 driver.
The OneWire class is now in its own onewire.py module, and the temperature
sensor class is in its own ds18x20.py module.  The latter is renamed to
DS18X20 to reflect the fact that it will support both the "S" and "B"
variants of the device.

These files are moved to the modules/ subdirectory to take advantage of
frozen bytecode.
2016-08-29 12:12:49 +10:00
Paul Sokolovsky
263aaa7030 esp8266/modmachinewdt: Implement machine.WDT class. 2016-08-28 14:48:49 +03:00
Radomir Dopieralski
d29ca28288 esp8266/modous: Add os.umount method to unmount a filesystem.
This is an object-oriented approach, where uos is only a proxy for the
methods on the vfs object.  Some internals had to be exposed (the STATIC
keyword removed) for this to work.

Fixes #2338.
2016-08-26 12:45:21 +10:00
Radomir Dopieralski
891479e62a esp8266/hspi: Enable duplex operation of hardware SPI
Without this, spi.read(1, 0xff) would use 16 clock cycles,
first to send 0xff and then to receive one byte, as visible
with a logic analyzer.
2016-08-25 21:24:22 +03:00
Damien George
d09b6b9aa1 esp8266/modpybrtc: Use 64-bit arithmetic when computing alarm expiry. 2016-08-25 14:10:25 +10:00
Paul Sokolovsky
f2a21a2489 esp8266/esp_mphal: No longer disable watchdog on startup.
Disabling it was an omission from early development stages.
2016-08-20 16:33:04 +03:00
Radomir Dopieralski
d076fae219 esp8266/modmachinespi: Add a factory method for SoftSPI/HSPI 2016-08-19 21:19:59 +03:00
Radomir Dopieralski
8e7dfea803 esp8266/modpybhspi: Add a HSPI module for hardware SPI support
This module uses ESP8266's SPI hardware, which allows much higher
speeds. It uses a library from
https://github.com/MetalPhreak/ESP8266_SPI_Driver
2016-08-19 21:19:59 +03:00
Damien George
675d1c9c60 ports: Remove typedef of machine_ptr_t, it's no longer needed.
This type was used only for the typedef of mp_obj_t, which is now defined
by the object representation.  So we can now remove this unused typedef,
to simplify the mpconfigport.h file.
2016-08-15 11:02:59 +10:00
Paul Sokolovsky
9cf2949356 esp8266/mpconfigport.h: Enable support for all special methods. 2016-08-14 01:02:35 +03:00
Damien George
8a15e0b1c7 esp8266: PULL_UP is not supported on Pin(16), so raise an exception. 2016-08-10 12:45:40 +10:00
Damien George
b203c1774e esp8266: Fix reading of pin object for GPIO16.
Pin(16) now works as an input.
2016-08-10 12:44:47 +10:00
Paul Sokolovsky
3c9510d767 esp8266/modules/flashbdev: Start filesystem at 0x90000.
To accommodate growing firmware.
2016-08-09 14:59:27 +03:00
Paul Sokolovsky
3372f69586 esp8266/esp8266.ld: Increase firmware image size to 0x90000 (576K).
Of them, 0x87000 is irom0 segment.

This is required to ship increasing number of modules and examples
developed in teh course of ESP8266 port project.
2016-08-09 14:54:26 +03:00
Paul Sokolovsky
31ad1bb606 esp8266/modmachine: Implement dummy sleep() function. 2016-08-07 16:20:01 +03:00
Paul Sokolovsky
541e76fa45 esp8266/modutime: Actually implement ticks_cpu(). 2016-08-07 16:13:51 +03:00
Paul Sokolovsky
f71f37e426 esp8266/esp_mphal.h: Add mp_hal_ticks_cpu() for reuse. 2016-08-07 16:03:00 +03:00
Paul Sokolovsky
c2070d771a esp8266/modmachine: Implement idle() function. 2016-08-07 15:51:04 +03:00
Paul Sokolovsky
6de37864a2 esp8266/scripts/inisetup: Add commented-out call to esp.osdebug(None).
That apparently will only help folks who read the docs on how to disable,
but could use a quick reminder straight in boot.py. For the developers,
it's important to have debug logging enabled in development branch
(master).
2016-08-06 15:27:38 +03:00
Paul Sokolovsky
ca59f5f208 esp8266/flashbdev: Reserve extra sysparam sector for SDK 2.0.0 compatibility. 2016-08-06 15:21:49 +03:00
Paul Sokolovsky
4a27ad040e esp8266/scripts/port_diag.py: Include esp.check_fw() call. 2016-08-04 00:43:58 +03:00
Paul Sokolovsky
e33d2383d1 esp8266/modesp: Add check_fw() function to check integrity of the firmware.
Requires firmware generated by the latest makeimg.py (which stores size
and md5 of the firmware together with the firmware itself).
2016-08-04 00:29:19 +03:00
Paul Sokolovsky
bf47b71b78 esp8266/makeimg.py: Append md5 hash to the generated binary.
md5 is calculated over the entire file, except first 4 bytes, which contain
flash parameters and may be changed by flashing tool or MicroPython flash
auto-config.
2016-08-04 00:21:05 +03:00
Paul Sokolovsky
a621333a4c esp8266/makeimg.py: Store firmware size as last 4 bytes of padding area. 2016-08-04 00:19:09 +03:00
Paul Sokolovsky
0e4cae5212 esp8266: Make APA102 driver inclusion configurable. 2016-08-01 00:03:55 +03:00
Paul Sokolovsky
88d3cd582e esp8266/eagle.rom.addr.v6.ld: Add Enable_QMode symbol from SDK 2.0.0. 2016-08-01 00:01:49 +03:00
Paul Sokolovsky
4d22ade102 esp8266: Enable btree module. 2016-07-31 02:39:59 +03:00
Paul Sokolovsky
64ad838fde esp8266/esp_mphal: Implement libc's errno.
Using __errno() function, and redirect it to use mp_stream_errno from
stream module. This is pre-requisite for integrating with 3rd-party libs,
like BerkeleyDB.
2016-07-31 02:30:05 +03:00
Paul Sokolovsky
61e77a4e88 py/mpconfig.h: Add MICROPY_STREAMS_POSIX_API setting.
To filter out even prototypes of mp_stream_posix_*() functions, which
require POSIX types like ssize_t & off_t, which may be not available in
some ports.
2016-07-30 20:05:56 +03:00
Paul Sokolovsky
ba2c503541 esp8266/mpconfigport.h: Include sys/types.h for POSIX types definitions.
As required for related functions in stream.h.
2016-07-30 17:46:36 +03:00
Paul Sokolovsky
50fea19416 esp8266/axtls_helpers: Remove abort_(), now in lib/embed/. 2016-07-30 00:36:28 +03:00
daniel-k
aa4ada943a esp8266/modpybuart: Fix UART parity setting.
The configuration bits for the UART register were wrong and the parity
couldn't be enabled, because the exist_parity member hasn't been updated. I
took this ESP8266 register description (http://esp8266.ru/esp8266-uart-reg/)
as reference.

Verification has been done with a logic analyzer.
2016-07-27 21:05:45 +03:00
Paul Sokolovsky
0d221775f5 esp8266/_boot.py: Decrease GC alloc threshold to quarter of heap size.
The idea behind decrease is: bytecode and other static data is also kept on
heap, and can easily become half of heap, then setting threshold to half of
heap will have null effect - GC will happen on complete heap exhaustion like
before. But exactly in such config maintaining heap defragmented is very
important, so lower threshold to accommodate that.
2016-07-23 13:56:24 +03:00
Paul Sokolovsky
c141584e1e esp8266/_boot.py: Set GC alloc threshold to half of heap size.
Should keep good chunk of heap unfragmented, if a user application allows
that at all.
2016-07-23 00:20:49 +03:00
Paul Sokolovsky
77f0cd8027 esp8266: dupterm_task_init() should be called before running _boot.py, etc.
Because they may use dupterm functionality (e.g. WebREPL running on boot).
2016-07-23 00:05:38 +03:00
Paul Sokolovsky
40214b9e26 esp8266: Enable MICROPY_PY_STR_BYTES_CMP_WARN. 2016-07-22 00:57:55 +03:00
Paul Sokolovsky
6aa7c805cc esp8266: Cache Xtensa-built libaxtls.a in local build dir.
Allows to build the library variant for other archs in parallel.
2016-07-16 04:56:23 +03:00
Paul Sokolovsky
bcd0e9a7fa esp8266/moduos: Add rmdir() function. 2016-07-16 03:53:55 +03:00
Paul Sokolovsky
be313ea215 esp8266: Select axTLS for SSL implementation, following recent refactor. 2016-07-13 01:59:41 +03:00
Paul Sokolovsky
380561836d esp8266/esp_mphal: Properly handle dupterm EOF after switching to readinto(). 2016-07-05 14:18:12 +03:00
Paul Sokolovsky
a22b6ebff1 esp8266/esp_mphal: call_dupterm_read: Use readinto() method.
It's memory fragmentation hazard to allocate 1-char string each time by
calling read() method.
2016-07-04 21:34:40 +03:00
Paul Sokolovsky
e07ef8f1a2 esp8266/main: Init recently added dupterm_arr_obj port state var. 2016-07-04 17:40:26 +03:00
Paul Sokolovsky
4cfe3e84b0 esp8266/README: Promote from "highly experimental" to "experimental". 2016-07-02 23:14:22 +03:00
Paul Sokolovsky
b8f45166c6 esp8266: Switch webrepl to use frozen bytecode. 2016-07-02 22:45:31 +03:00
Paul Sokolovsky
dec51e3519 esp8266: Switch webrepl_setup to use frozen bytecode. 2016-07-02 22:40:16 +03:00
Paul Sokolovsky
686367dcfc esp8266: Explicitly collect garbage in bootstrap scripts.
Leads to less fragmentation at teh time user code starts.
2016-07-02 19:22:55 +03:00
Radomir Dopieralski
35962eaab0 esp8266/modpybuart: allow setting baudrate and other params 2016-06-30 18:18:50 +02:00
Paul Sokolovsky
d1b7ba5dc1 esp8266/websocket_helper.py: Fix typo in debug output. 2016-06-30 13:34:58 +03:00
Paul Sokolovsky
6907496016 esp8266/websocket_helper.py: Avoid extra string allocations. 2016-06-30 00:02:45 +03:00
Damien George
56845b6aff esp8266/README: Describe how to build mpy-cross. 2016-06-29 14:25:12 +01:00
Damien George
db80c0ed46 esp8266: Enable frozen bytecode, with scripts in modules/ subdir.
To start with, the critical scripts _boot.py and flashbdev.py are frozen
to improve performance and reduce RAM consumption.

Saves about 1000 bytes of heap RAM for a bare boot with filesystem.
2016-06-29 13:59:19 +01:00
Robert HH
eb7637ba2e esp8266/main.c: Clear the command line history when (re)booting.
Not clearing the command line history sometimes results in strange output
when going back after a reset.
2016-06-26 12:48:19 +01:00
Paul Sokolovsky
07209f8592 all: Rename mp_obj_type_t::stream_p to protocol.
It's now used for more than just stream protocol (e.g. pin protocol), so
don't use false names.
2016-06-18 18:44:57 +03:00
Robert HH
23067a1422 esp8266: Use RTC to set date & time stamps for files.
The time stamp is taken from the RTC for all newly generated
or changed files. RTC must be maintained separately.
The dummy time stamp of Jan 1, 2000 is set in vfs.stat() for the
root directory, avoiding invalid time values.
2016-06-16 19:31:58 +03:00
Paul Sokolovsky
236838a9fc esp8266/Makefile: Enable --verify option for esptool.py write_flash.
Based on my experience, there's rather non-zero chance to have an image be
flashed incorrectly. As --verify option is now works well in teh latest
esptool.py, enable it by default.
2016-06-12 18:50:24 +03:00
Paul Sokolovsky
9f8b788fe5 esp8266: Switch floating-point arith routines to BootROM. 2016-06-12 18:44:14 +03:00
puuu
ee12581a35 esp8266: Let RTC work correctly after deepsleep.
By design, at wake up from deepsleep, the RTC timer will be reset, but
the data stored in RTC memory will not [1]. Therefore, we have to adjust
delta in RTC memory before going into deepsleep to get almost correct
time after waking up.

[1] http://bbs.espressif.com/viewtopic.php?t=1184#p4082
2016-06-06 10:51:12 +01:00
Mark
822e9ca8f3 esp8266/modnetwork: Use struct bss_info::ssid_len for ESSID length.
Instead of calling strlen(), which won't work if there're 32 chars in
returned ESSID. struct bss_info::ssid_len is not documented in SDK API
Guide, but is present in SDK headers since 1.4.0. Just in case, previous
code is left commented.
2016-06-04 22:02:01 +03:00
puuu
cafdfb7af3 esp8266/modpybrtc: Handle RTC overflow.
ESP-SDK system_get_rtc_time() returns uint32 and therefore overflow
about every 7:45h.  Let's write the last state of system_get_rtc_time()
in RTC mem and use it to check for overflow. This commit require running
pyb_rtc_get_us_since_2000() at least once within 7 hours to avoid
overflow.
2016-06-03 14:37:49 +01:00
Damien George
927388e80e esp8266: Provide a dedicated variable to disable ets_loop_iter.
So ets_loop_iter is now only disabled when using machine.disable_irq.
2016-06-01 17:26:49 +01:00
Damien George
752e952096 esp8266/rtc: Set RTC user memory length to 0 on first boot.
So that RTC.memory() returns b'' on power up if it was never set.

Fixes issue #2138.
2016-06-01 11:33:04 +01:00
Robert HH
4f3fbf09cc esp8266/moduos.c: Add stat() to the module uos of esp8266.
This implementation makes use of vfs.stat() and therefore has the same
properties. Known issues for all ports: uos.stat(".") on the top level
returns the error code 22, EINVAL. The same happens with
uos.stat("dirname/") where dirname IS the name of a directory.
2016-05-31 23:00:38 +03:00
Paul Sokolovsky
15eb1ce52d esp8266: Enable MICROPY_PY_IO_FILEIO to get compliant text/binary streams. 2016-05-31 21:46:02 +03:00
Damien George
33168081f4 extmod/machine: Add MICROPY_PY_MACHINE_PULSE config for time_pulse_us.
Since not all ports that enable the machine module have the pin HAL
functions.
2016-05-31 14:25:19 +01:00
Damien George
cff2b7a6e3 esp8266/modmachine: Add machine.time_pulse_us function. 2016-05-31 14:06:50 +01:00
Paul Sokolovsky
225562d915 esp8266/scripts/ntptime: Allow to override NTP server.
This is not part of public API, variable name may change, or it can be
replaced with a function.
2016-05-30 19:16:05 +03:00
Paul Sokolovsky
12401f337e esp8266/moduos: Add chdir() and getcwd() functions. 2016-05-29 19:44:24 +03:00
Damien George
602305b211 esp8266/uart: Properly initialise UART0 RXD pin in uart_config.
Tested and seems to work.  See #1995.
2016-05-29 10:30:27 +01:00
Damien George
6707fc94ae esp8266/modnetwork: Allow to press ctrl-C while scan() is running.
Ctrl-C will raise a KeyboardInterrupt and stop the scan (although it will
continue to run in the background, it won't report anything).  If
interrupted, and another scan() is started before the old one completes
in the background, then the second scan will fail with an OSError.
2016-05-29 09:53:04 +01:00
Damien George
84381fa0fc esp8266/modnetwork: Protect scan() callback against memory errors.
scan() allocates memory so may cause an exception to be raised.
2016-05-29 09:52:07 +01:00
Damien George
55df14f1a4 esp8266/modnetwork: scan() is only supported by STA when it's enabled. 2016-05-29 00:35:24 +01:00
Paul Sokolovsky
74e6c0337d esp8266/Makefile: Document "disable" value for UART_OS. 2016-05-27 00:44:05 +03:00
Damien George
7ebfe09fbd esp8266: Add dht.py script for high-level control of DHT11/DHT22 sensor.
TODO: should go in a more port-neutral place, like drivers/dht, but at the
moment in relies on specific esp module.
2016-05-26 17:13:03 +01:00
Damien George
45f3416816 esp8266: Enable DHT C-level driver.
Exposed as esp.dht_readinto.  Probably should go somewhere less
port-specific.
2016-05-26 17:11:43 +01:00
Damien George
4b37e775ea extmod/machine_i2c: Redo mp_hal_pin macros to use open_drain and od_low.
mp_hal_pin_config_od is renamed mp_hal_pin_open_drain, and mp_hal_pin_low
is mp_hal_pin_od_low.
2016-05-26 17:06:40 +01:00
Damien George
9a368ae831 esp8266/modmachine: Add disable_irq and enable_irq functions. 2016-05-26 15:47:47 +01:00
Damien George
849eb835f0 esp8266/ets_alt_task: Don't run ets_loop_iter if irqs are disabled.
ets_loop_iter processes pending tasks, and tasks are considered lower
priority than interrupts, so tasks shouldn't be processed if interrupts
are disabled.
2016-05-26 15:47:47 +01:00
Damien George
99b14593a6 esp8266/xtirq: Add xtirq.h for controlling xtensa irqs. 2016-05-26 15:47:47 +01:00
Damien George
7e809b4baf esp8266/modpybspi: Configure pins when initialising an SPI object. 2016-05-26 15:42:44 +01:00
Damien George
68e222afdc esp8266: Add mp_hal_pin_input() and mp_hal_pin_output() functions. 2016-05-26 15:42:27 +01:00
Paul Sokolovsky
2b05b60bbc esp8266/esp_mphal: mp_uos_dupterm_deactivate() may raise exception.
So, keep call to it protected via NLR still.
2016-05-24 15:04:59 +03:00
Paul Sokolovsky
4681b86850 esp8266/esp_mphal: Handle Ctrl+C from dupterm (e.g. WebREPL). 2016-05-24 01:37:56 +03:00
Paul Sokolovsky
116eeee6db esp8266/esp_mphal: Fix NLR buffer leak in call_dupterm_read(). 2016-05-24 01:30:28 +03:00
Paul Sokolovsky
bc2ba6b2e3 esp8266/scripts/port_diag: Dump network interface IP settings. 2016-05-24 01:27:16 +03:00
Paul Sokolovsky
cb7693bab4 esp8266/main: Update _boot module loading for recent frozen modules refactors. 2016-05-22 04:09:15 +03:00
Paul Sokolovsky
9c2217a165 esp8266: Enable collections.OrderedDict. 2016-05-22 02:57:33 +03:00
Paul Sokolovsky
0ab372585f extmod/moduos_dupterm: Dumpterm subsystem is responsible for closing stream.
Make dupterm subsystem close a term stream object when EOF or error occurs.
There's no other party than dupterm itself in a better position to do this,
and this is required to properly reclaim stream resources, especially if
multiple dupterm sessions may be established (e.g. as networking
connections).
2016-05-20 22:20:37 +03:00
misterdanb
a0a08b4be1 esp8266: Add APA102 serial individually controllable LEDs support.
APA102 is a new "smart LED", similar to WS2812 aka "Neopixel".
2016-05-19 22:29:11 +03:00
Torwag
6fa60153ea esp8266/README: Add a very first start section.
Adding a very first start section to get people going after flashing.
I tried to condense it to  a minimum to avoid as much as possible
redundancy and bloating.
2016-05-19 21:10:35 +03:00
Paul Sokolovsky
418faae8f7 esp8266/scripts/webrepl_setup: Add max password length check.
modwebrepl truncates password to 9 chars, and that led people to confusion.
2016-05-17 02:21:45 +03:00
Paul Sokolovsky
21ec1fd850 esp8266/scripts/webrepl_setup: Show password placeholder char.
That was the intent for the initial user setup, but didn't work before
due to lwIP issues. Enable now that they're fixed.
2016-05-17 00:01:41 +03:00
Paul Sokolovsky
7327d5f6f7 esp8266/scripts/port_diag: Add network diagnostic output. 2016-05-16 23:52:58 +03:00
Robert HH
a676a41cb7 esp8266/moduos.c: Addition of the rename method to module uos.
That one was missing in the module, even if it was available in the
vfs object. The change consist of adding the name and preparing the
call to the underlying vfs module, similar to what was already
implemented e.g. for remove.

Rename is useful by itself, or for instance for a safe file replace,
consisting of the sequence:

    write to a temp file
    delete the original file
    rename the temp file to the original file's name
2016-05-16 13:19:13 +02:00
Damien George
0d6d315ba6 esp8266: Change to use internal errno's. 2016-05-12 12:49:36 +01:00
Damien George
7e1f580910 esp8266: Enable uerrno module, weak linked also as errno. 2016-05-10 23:30:39 +01:00
Damien George
4f2ba9fbdc esp8266: Convert to use new MP_Exxx errno symbols.
These symbols are still defined in terms of the system Exxx symbols, and
can be switched to internal numeric definitions at a later stage.

Note that extmod/modlwip still uses many system Exxx symbols.
2016-05-10 23:30:39 +01:00
Paul Sokolovsky
d60cb8e180 esp8266/help: Add "sta_if.active(True)" command.
As reported on the forum by Roberthh.
2016-05-10 23:21:32 +03:00
Paul Sokolovsky
f16bec6bc9 esp8266/mpconfigport: Reduce various parser-related allocation params.
This gives noticeable result for parsing simple input (modelled on 32-bit
unix port):

Before:
>>> micropython.mem_total()
3360
>>> micropython.mem_total()
4472

After:
>>> micropython.mem_total()
3072
>>> micropython.mem_total()
4052

However, effect on parsing large input is much less conclusive, e.g.:

Before:
>>> micropython.mem_total()
3376
>>> import pystone_lowmem
>>> micropython.mem_total()
33006

delta=29630

After:
>>> micropython.mem_total()
3091
>>> import pystone_lowmem
>>> micropython.mem_total()
32509

delta=29418
2016-05-10 15:38:31 +03:00
Paul Sokolovsky
de5e0ed2e0 esp8266/main: Bump heap size to 28K.
This is kind of compensation for 4K FatFs buffer size which is eaten away
from it on FS mount. This should still leave enough of networking ("OS")
heap.
2016-05-09 19:02:40 +03:00
Paul Sokolovsky
13a1acc7e2 esp8266/scripts/webrepl: Add start_foreground() method.
Starts WebREPL server in foreground and waits for (single) connection.
2016-05-08 20:01:15 +03:00
Noah Rosamilia
2724bd4a94 esp8266/scripts/webrepl: Add optional password argument to webrepl.start()
This commit fixes issue #2045
2016-05-07 22:45:08 +03:00
Mike Causer
13d06a83e1 esp8266/scripts/: Add fill() to NeoPixel 2016-05-07 21:15:33 +03:00
Paul Sokolovsky
8db61e5b5a esp8266/scripts/inisetup: Don't start WebREPL on boot in master branch.
It interferes with running testsuite. master branch should be optimized for
development, so any features which interfere with that, would need to be
disabled by default.
2016-05-07 20:04:45 +03:00
Paul Sokolovsky
df2b1a4758 esp8266/scripts/: Remove use of pin.PULL_NONE.
This constant is no longer part of hardware API (replaced with just None),
and is a default, so not needed in calls.
2016-05-05 23:47:37 +03:00
Paul Sokolovsky
fb5017f9dc esp8266/main: Set sys.path to ["", "/", "/lib"]. 2016-05-03 18:25:27 +03:00
Damien George
496a601c3b esp8266: Shrink help text by a few lines, to fit in smaller windows. 2016-05-03 15:54:57 +01:00
Paul Sokolovsky
f873a5005a esp8266/scripts/ntptime: Add simple NTP client.
.time() returns seconds since MicroPython epoch (2000-01-01 00:00UTC),
.settime() sends current system time, assuming UTC timezone.
2016-05-03 16:47:42 +03:00
Damien George
8e130fcf2b esp8266/modpybpin: Make pin.irq() methods take keyword args. 2016-05-03 13:47:10 +01:00
Damien George
8a3e9036eb esp8266/modpybpin: Use None instead of PULL_NONE for no-pull config. 2016-05-03 13:13:56 +01:00
Damien George
9df6b3a2c2 esp8266/modpybpin: Use enum+array instead of struct for parsing args. 2016-05-03 12:44:28 +01:00
Damien George
b539a61490 esp8266/scripts/neopixel.py: Swap red and green in pixel accessor. 2016-05-03 11:17:37 +01:00
Paul Sokolovsky
5e94f0b43a esp8266/scripts/inisetup: Update for nic.mac() method being gone. 2016-05-03 02:16:42 +03:00
Paul Sokolovsky
35e63f0007 esp8266/modnetwork: Remove .mac() method, move to .config("mac").
Querying/setting MAC address is pretty adhoc operation to belong to
.config() instead of taking a whole method on its own.
2016-05-03 01:02:14 +03:00
Paul Sokolovsky
3944d3511f esp8266/scripts/inisetup: Enable WebREPL auto-start on boot. 2016-05-03 00:38:47 +03:00
Paul Sokolovsky
76c81cd5a6 esp8266/modesp: Add malloc() and free() functions.
Useful for testing fragmentation issues in OS heap. E.g. freemem() may
report large amount, but is it possible to actually allocate block of
a given size? Issue malloc() (followed by free()) to find out.
2016-05-03 00:35:11 +03:00
Paul Sokolovsky
2123ced3f4 esp8266/modesp: Add esf_free_bufs() debugging function.
Return number of free inernal WiFi buffers.
2016-05-03 00:26:22 +03:00
Paul Sokolovsky
3d830415bc esp8266/esp_mphal: Add ets_esf_free_bufs(), etc. functions.
Returning free number of various WiFi driver packet buffers.
2016-05-03 00:18:14 +03:00
Paul Sokolovsky
7b7c99fec1 esp8266/modnetwork: Remove deprecated wifi_mode().
Network interfaces are now controlled individually using .active() method.
2016-05-03 00:09:23 +03:00
Damien George
9215cdc7fd esp8266: Change platform name from ESP8266 to esp8266.
The port name is lowercase, and this change is made for consistency with
the docs and other ports.
2016-05-02 18:54:46 +01:00
Paul Sokolovsky
13d9d50fea esp8266/scripts/webrepl_setup: Reject too short passwords. 2016-05-02 18:48:32 +03:00
Paul Sokolovsky
26fd0ac571 esp8266/Makefile: Be sure to pass cross-compiling AR when building axtls.
Fixes build under MacOSX.
2016-05-02 01:22:42 +03:00
Paul Sokolovsky
9dd2c92d01 esp8266/README: Mention WebREPL. 2016-04-30 23:02:54 +03:00
Paul Sokolovsky
c1d1c562f3 esp8266/scripts/webrepl: Add "first connection" mode to setup password.
If there's no port_config.py file, or it lacks WEBREPL_PASS variable,
"initial setup mode" will be entered on first WebREPLconnection. User
will be asked for password, which will be written to
port_config.WEBREPL_PASS, and system restarted to work in normal mode
with password active.
2016-04-30 20:41:09 +03:00
Paul Sokolovsky
962d5a987f esp8266/scripts/webrepl: Switch to using _webrepl object wrapper.
Handling of binary protocol is untested on esp8266 so far.
2016-04-30 20:39:35 +03:00
Paul Sokolovsky
006ffe1561 esp8266/scripts/webrepl: Connection ack prompt is now printed by modwebrepl.
After password is checked.
2016-04-30 20:38:05 +03:00
Paul Sokolovsky
6ddd9f3e2b esp8266/scripts/inisetup: Create default boot.py in filesystem.
Currently it pre-imports webrepl, but doesn't start it.
2016-04-29 20:11:48 +03:00
Paul Sokolovsky
74f413bc60 esp8266/scripts/_boot: builtins is no longer used. 2016-04-29 20:04:17 +03:00
Paul Sokolovsky
d86d65f625 esp8266/scripts: Move all of initial setup to inisetup module. 2016-04-29 20:02:59 +03:00
Paul Sokolovsky
adae53d522 esp8266: Enable webrepl module. 2016-04-29 19:38:21 +03:00
Paul Sokolovsky
f8170db390 esp8266: Enable WebREPL file transfer rate limiting. 2016-04-29 19:15:26 +03:00
Paul Sokolovsky
22050a3ed0 esp8266/help: Add cheatsheet for basic WiFi configuration. 2016-04-29 00:34:08 +03:00
Paul Sokolovsky
b639ce27c7 esp8266/help: Implement help() builtin. 2016-04-29 00:17:11 +03:00
Aex Aey
af554b4ba2 esp8266/modnetwork: Make WLAN.ifconfig() read/write.
Allow setting ip, netmask, gw and dns server (also, allows getting dns).
For docs see: https://github.com/micropython/micropython/commit/06deec9
2016-04-28 23:51:04 +03:00
bsdfox
193c62226c esp8266/README: Add recently required step of 'make axtls'. 2016-04-28 21:42:04 +03:00
Paul Sokolovsky
978a429aaa esp8266: Set suitable values for axtls's RT_MAX_PLAIN_LENGTH & RT_EXTRA. 2016-04-28 17:45:22 +03:00
Damien George
8c3b5526ae esp8266/scripts/neopixel.py: Remove test function from neopixel driver.
It takes up lots of room and isn't needed.
2016-04-28 13:37:17 +01:00
Damien George
1f7cec944e esp8266/scripts/onewire.py: Simplify and improve 1-wire driver.
Changes are:
- added OneWireError exception and used where errors can occur
- renamed read/write functions to use same names as C _onewire funcs
- read_bytes is now read, write_bytes is now write
- add ability to read/write DS18B20 scratch pad
- rename start_measure to convert_temp (since that's what it does)
- rename get_temp to read_temp (consistency with other read names)
- removed test function
2016-04-28 13:33:55 +01:00
Damien George
38358a096d esp8266: Move onewire.py, neopixel.py drivers from tests/ to scripts/. 2016-04-28 12:36:45 +01:00
Damien George
a6aa35af09 esp8266: Move pyb.info() function to esp module and remove pyb module.
All functionality of the pyb module is available in other modules, like
time, machine and os.  The only outstanding function, info(), is
(temporarily) moved to the esp module and the pyb module is removed.
2016-04-28 12:23:55 +01:00
Paul Sokolovsky
0785040593 esp8266/Makefile: Enable "ussl" module.
axTLS should be built first using "make axtls".
2016-04-28 00:48:38 +03:00
Paul Sokolovsky
941ddfe559 esp8266/Makefile: Support linking with axTLS built from source. 2016-04-28 00:48:38 +03:00
Damien George
8ed3a9eb9c esp8266/tests/onewire.py: Don't run test on import. 2016-04-27 22:32:39 +01:00
Paul Sokolovsky
dc2c8f0b1a esp8266/axtls_helpers: Helper/wrapper functions for axTLS. 2016-04-27 14:54:36 +03:00
Paul Sokolovsky
648333d2d5 esp8266/Makefile: Override abort() when building axtls.
abort() is a special function known to compiler as no-return.
2016-04-27 13:41:59 +03:00
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