Commit Graph

630 Commits

Author SHA1 Message Date
Paul Sokolovsky ee7ad7e8be esp8266: Add "ota" target to produce firmware binary for use with yaota8266.
https://github.com/pfalcon/yaota8266 is a (WIP) OTA-enabled bootloader
which doesn't require reserving space 2x size of a firmware.
2016-12-14 17:44:05 +03:00
Damien George e8f2db7da3 py/runtime: Zero out fs_user_mount array in mp_init.
There's no need to force ports to copy-and-paste this initialisation
code.  If FSUSERMOUNT is enabled then this zeroing out must be done.
2016-12-14 11:40:11 +11:00
Scott Shawcroft 781633c716 Fix up Analog classes: unify them at 16 bits and adds reference_voltage member
to make for easy conversion. Fixes #14.
2016-12-13 16:09:00 -08:00
Scott Shawcroft 9ad0da6134 esp8266: Fix pyexec calls. 2016-12-12 17:11:07 -08:00
Scott Shawcroft 3972bc19c7 atmel-samd: Basic capacitive touch button support.
Currently only works on a single channel and is only enabled for boards with
SPI flash. Only really designed for hardware testing at this point.
2016-12-12 15:11:25 -08:00
Damien George 3a4ebf5768 esp8266: Enable inline Xtensa assembler.
With this patch, @micropython.asm_xtensa can be used on the esp8266 port.
2016-12-09 17:13:00 +11:00
Damien George 45a6156dfd esp8266: Enable native emitter for Xtensa arch.
This patch allows esp8266 to use @micropython.native and
@micropython.viper function decorators.  By default the executable machine
code is written to the space at the end of the iram1 region.  The user can
call esp.set_native_code_location() to make the code go to flash instead.
2016-12-09 16:51:49 +11:00
Damien George 5e393007b9 esp8266/mpconfigport_512k: Disable framebuf module for 512k build.
The 512k build recently overflowed because of the newly-enabled uselect
module.  uselect is arguable more important than framebuf for small
devices so we disable framebuf to keep the 512k build within its limit.
2016-12-08 17:31:21 +11:00
Damien George ad166857bc esp8266: Refactor to use extmod implementation of software SPI class. 2016-12-08 14:41:58 +11:00
Damien George 1eb3c66e91 extmod/machine_spi: Provide reusable software SPI class.
So long as a port defines relevant mp_hal_pin_xxx functions (and delay) it
can make use of this software SPI class without the need for additional
code.
2016-12-08 13:47:01 +11:00
Scott Shawcroft 0ae344841f atmel-samd & esp8266: Make sure pins are not already in use.
This prevents corrupting previous functional objects by stealing their pins
out from under them. It prevents this by ensuring that pins are in default
state before claiming them. It also verifies pins are released correctly and
reset on soft reset.

Fixes #4, instantiating a second class will fail.
Fixes #29, pins are now reset too.
2016-12-07 15:21:14 -08:00
puuu 4fc607a1d7 esp8266: Move websocket_helper.py from scripts to modules for frozen BC.
websocket_helper.py is used by webrepl.  If webrepl is enabled and
websocket_helper.py is not frozen bytecode it leads to heap
fragmentation.
2016-12-05 13:01:08 +11:00
Scott Shawcroft 26229efe78 Add try_lock and unlock to I2C and SPI classes to make sure things
are shared well between threads and underlying MicroPython (SPI Flash
for example.)

It is recommended to use the bus device classes to manage the locks
and other transaction state.

https://github.com/adafruit/Adafruit_MicroPython_BusDevice

Fixed #58
Fixed #59
Fixed #60
2016-12-02 15:46:12 -08:00
Damien George e50cb73b7a esp8266: Enable uselect module.
Select and poll will now work on socket objects.
2016-12-02 16:44:31 +11:00
Scott Shawcroft 6292f937da esp8266: Make work with python 3 as default python impl. 2016-11-28 19:47:59 -08:00
Scott Shawcroft ccbb5e84f9 This introduces an alternative hardware API called nativeio structured around different functions that are typically accelerated by native hardware. Its not meant to reflect the structure of the hardware.
Docs are here: http://tannewt-micropython.readthedocs.io/en/microcontroller/

It differs from upstream's machine in the following ways:

* Python API is identical across ports due to code structure. (Lives in shared-bindings)
* Focuses on abstracting common functionality (AnalogIn) and not representing structure (ADC).
* Documentation lives with code making it easy to ensure they match.
* Pin is split into references (board.D13 and microcontroller.pin.PA17) and functionality (DigitalInOut).
* All nativeio classes claim underlying hardware resources when inited on construction, support Context Managers (aka with statements) and have deinit methods which release the claimed hardware.
* All constructors take pin references rather than peripheral ids. Its up to the implementation to find hardware or throw and exception.
2016-11-21 14:11:52 -08:00
Damien George 5bdf1650de py/lexer: Make lexer use an mp_reader as its source. 2016-11-16 18:35:01 +11:00
Damien George e5ef15a9d7 py/lexer: Provide generic mp_lexer_new_from_file based on mp_reader.
If a port defines MICROPY_READER_POSIX or MICROPY_READER_FATFS then
lexer.c now provides an implementation of mp_lexer_new_from_file using
the mp_reader_new_file function.
2016-11-16 18:13:51 +11:00
Damien George 6b239c271c py: Factor out persistent-code reader into separate files.
Implementations of persistent-code reader are provided for POSIX systems
and systems using FatFS.  Macros to use these are MICROPY_READER_POSIX and
MICROPY_READER_FATFS respectively.  If an alternative implementation is
needed then a port can define the function mp_reader_new_file.
2016-11-16 18:13:50 +11:00
Damien George 6810f2c134 py: Factor persistent code load/save funcs into persistentcode.[ch]. 2016-11-16 16:14:14 +11:00
Paul Sokolovsky 59a1201da9 all: Remove readall() method, which is equivalent to read() w/o args.
Its addition was due to an early exploration on how to add CPython-like
stream interface. It's clear that it's not needed and just takes up
bytes in all ports.
2016-11-14 00:24:22 +03:00
Damien George 11957840e8 esp8266: Update 512k linker script, renaming modpyb to machine. 2016-11-09 17:16:00 +11:00
Chris Popp 52df2f889e esp8266/modnetwork.c: Expose configuration for station DHCP hostname.
The ESP SDK supports configuring the hostname that is
reported when doing a DHCP request in station mode.  This commit
exposes that under network.WLAN(network.STA_IF).config('dhcp_hostname')
as a read/write value similar to other parameters.
2016-11-09 00:33:13 +03:00
Damien George bdf33bc136 py: Move frozen bytecode Makefile rules from ports to common mk files.
Now, to use frozen bytecode all a port needs to do is define
FROZEN_MPY_DIR to the directory containing the .py files to freeze, and
define MICROPY_MODULE_FROZEN_MPY and MICROPY_QSTR_EXTRA_POOL.
2016-11-08 14:28:30 +11:00
Paul Sokolovsky 5630778f0f esp8266: Update docs for esptool 1.2.1/SDK 2.0 (--flash_size=detect). 2016-11-08 04:52:07 +03:00
Paul Sokolovsky 1cc168d487 esp8266: Include upip as a standard frozen bytecode module.
Previously, it was included only in release builds, but it's important
tool which should be always at the fingertips to be useful (and to
pump up its usage).
2016-11-08 01:34:35 +03:00
Olivier Ortigues bc4441afa7 esp8266/espneopixel.c: Solve glitching LED issues with cpu at 80MHz.
At the WS2812 driver level, a 400ns value was used for T0H (time high to
send a 0 bit) but LED specification says it should be 350ns +- 150ns.
Due to loop overhead the 400ns value could lead to T0H close to 500ns
which is too close from the limit value and gave glitches (bad data to
pixels) in some cases.  This patch makes the calculated T0H value 350ns.
2016-11-07 17:13:49 +11:00
Paul Sokolovsky e84e3e7c10 esp8266: Rework webrepl_setup to run over wired REPL. 2016-11-06 10:01:48 +03:00
Paul Sokolovsky 8bc3fc20fe esp8266: Rename "machine" module implementation to use contemporary naming.
Previously they used historical "pyb" affix causing confusion and
inconsistency (there's no "pyb" module in modern ports; but people
took esp8266 port as an example, and "pyb" naming kept proliferating,
while other people complained that source structure is not clear).
2016-11-06 01:30:19 +03:00
Damien George 7bb0f7b0f6 drivers: Add "from micropython import const" when const is used.
Following best-practice use of the const feature, to make it compatible
with Python.
2016-11-03 12:41:11 +11:00
ernitron e5f06559e6 esp8266/modules: Fix negative temperature in ds18x20 driver. 2016-11-02 22:58:49 +11:00
Paul Sokolovsky 5fae914326 esp8266/etshal.h: Adjust size of MD5_CTX structure.
Size 64 was incorrect and will lead to stack corruption. Size 88 was
verified empirically. Also, allow to skip defining it if MD5_CTX
preprocessor macro is already defined (to avoid header conflict).
2016-11-02 02:16:35 +03:00
Paul Sokolovsky 2ec70dc812 esp8266/etshal.h: Add prototypes for SPIRead/SPIWrite/SPIEraseSector. 2016-11-02 02:16:20 +03:00
Paul Sokolovsky a6c9060d81 esp8266/main: Bump heap size to 36K.
ESP8266 SDK2.0 fixes (at least, I can't reproduce it) an infamous bug
with crash during scan. 36K seams to be a safe value based on a download
test (test_dl.py), over 1GB was downloaded. More testing is needed, but
let's have other people participate by committing it now.
2016-11-02 00:22:43 +03:00
puuu b97c17e125 esp8266/modnetwork.c: Allows AP reconnection without WiFi credentials
There is no automatic reconnect after wlan.active(False);
wlan.active(True). This commit provide the possibility to run
wlan.connect() without parameter, to reconnect to the previously
connected AP.

resolve #2493
2016-11-01 06:59:41 +03:00
Paul Sokolovsky eddcf0a5de esp8266/scripts/port_diag: Add descriptions for esf_buf types. 2016-11-01 06:56:10 +03:00
Paul Sokolovsky e377f3cb40 esp8266/modnetwork: config(): Fix copy-paste error in setting "mac". 2016-10-31 00:30:26 +03:00
Paul Sokolovsky 64c6bdb8ee esp8266/modutime: Consistently convert to MP_ROM_QSTR/MP_ROM_PTR. 2016-10-29 18:48:04 +03:00
Paul Sokolovsky d86cac4b82 extmod/utime_mphal: Implement ticks_add(), add to all maintained ports. 2016-10-29 17:30:05 +03:00
Radomir Dopieralski 984a867341 esp8266/scripts: Make neopixel/apa102 handle 4bpp LEDs with common code.
The NeoPixel class now handles 4 bytes-per-pixel LEDs (extra byte is
intensity) and arbitrary byte ordering.  APA102 class is now derived from
NeoPixel to reduce code size and support fill() operation.
2016-10-25 14:21:07 +11:00
Paul Sokolovsky 2550d7dfd2 esp8266: Add support for building firmware version for 512K modules.
To build, "make 512k".

Disabled are FatFs support (no space for filesystem), Python functionality
related to files, btree module, and recently enabled features. With all
this, there's only one free FlashROM page.
2016-10-25 00:43:11 +03:00
Paul Sokolovsky e6af94d13b esp8266/modesp: Add flash_user_start() function.
As we're looking towards adding OTA support, calculation of a FlashROM
area which can be used for filesystem (etc.) may become complex, so
introduce C function for that. So far it just hardcodes current value,
0x90000. In the future the function may be extended (and renamed) to
return the size of area too.
2016-10-24 16:52:15 +03:00
Paul Sokolovsky b6c22c42ab esp8266/etshal.h: Add few more ESP8266 vendor lib prototypes. 2016-10-23 16:43:07 +03:00
Paul Sokolovsky 1b76614d41 esp8266/Makefile: deploy: Remove deprecated line. 2016-10-22 18:56:43 +03:00
Damien George 4ebdb1f2b2 py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros.
In order to have more fine-grained control over how builtin functions are
constructed, the MP_DECLARE_CONST_FUN_OBJ macros are made more specific,
with suffix of _0, _1, _2, _3, _VAR, _VAR_BETEEN or _KW.  These names now
match the MP_DEFINE_CONST_FUN_OBJ macros.
2016-10-21 16:26:01 +11:00
Paul Sokolovsky b440307b4a py/py.mk: Automatically add frozen.c to source list if FROZEN_DIR is defined.
Now frozen modules generation handled fully by py.mk and available for reuse
by any port.
2016-10-21 01:08:43 +03:00
Paul Sokolovsky 3f251efb9b esp8266/modules/webrepl: Enforce only one concurrent WebREPL connection.
Concurrent WebREPL connections were never supported, now actually check
for this.
2016-10-20 16:50:38 +03:00
Paul Sokolovsky 204222653e esp8266/main: Mark nlr_jump_fail() as MP_FASTCODE.
It's probably not strictly needed so far, but serves as an example of
MP_FASTCODE use and may be helpful in the future.
2016-10-19 00:21:14 +03:00
Paul Sokolovsky 9514d847fe esp8266: Add MP_FASTCODE modifier to put a function to iRAM.
It can be used in the following manner:

void MP_FASTCODE(foo)(int arg) { ... }
2016-10-19 00:20:10 +03:00
Paul Sokolovsky 462748de0c esp8266/esp8266.ld: Move main.o to iROM. 2016-10-19 00:12:54 +03:00
Paul Sokolovsky e7e0d91be8 esp8266/esp8266.ld: Move modmachine.o to iROM. 2016-10-19 00:04:30 +03:00
Paul Sokolovsky 6566e3f6a8 esp8266/esp8266.ld: Move help.o to iROM. 2016-10-19 00:01:14 +03:00
Paul Sokolovsky 20d0271863 esp8266/esp_init_data: Auto-initialize system params with vendor SDK 2.0.0.
SDK 2.0.0 goes into boot loop if a firmware is programmed over erased flash,
causing problems with user experience. This change implements behavior
similar to older SDKs': if clean flash is detected, default system
parameters are used.
2016-10-18 15:18:07 +03:00
Paul Sokolovsky 4d45f286eb esp8266/Makefile: Use latest esptool.py flash size auto-detection. 2016-10-18 00:06:59 +03:00
Paul Sokolovsky 799ccdc789 esp8266, stmhal, unix: MAKE_FROZEN is consistently defined in mkenv.mk. 2016-10-16 10:49:36 +03:00
Paul Sokolovsky a97284423e extmod/utime_mphal: Factor out implementations in terms of mp_hal_* for reuse.
As long as a port implement mp_hal_sleep_ms(), mp_hal_ticks_ms(), etc.
functions, it can just use standard implementations of utime.sleel_ms(),
utime.ticks_ms(), etc. Python-level functions.
2016-10-14 20:14:01 +03:00
Damien George ed878275b0 esp8266: Enable micropython.alloc_emergency_exception_buf(). 2016-10-14 01:27:53 +11:00
Damien George af8d791bd0 esp8266: Enable importing of precompiled .mpy files. 2016-10-12 11:03:58 +11:00
Damien George 11fc6553e8 esp8266: Enable sys.{stdin,stdout,stderr}.buffer for raw serial access. 2016-10-12 11:03:58 +11:00
Radomir Dopieralski db4e009217 esp8266/mpconfigport: Enable MICROPY_PY_BUILTINS_SLICE_ATTRS 2016-10-11 12:22:36 +02:00
Paul Sokolovsky 3b3612c65b esp8266: Make neopixel support configurable.
To save iRAM.
2016-10-09 00:56:46 +03:00
Damien George 23a568240d esp8266: Use mp_raise_OSError helper function. 2016-10-07 14:00:51 +11:00
dmanso 0363e1d7b5 esp8266: Add FLASH_MODE,FLASH_SIZE options for make deploy target.
Added options to make deploy so it can be used for ESP8266 boards with
other flash configurations.  For example NodeMCU DEVKIT V1.0 can now use:

    $ make FLASH_MODE=dio FLASH_SIZE=32m deploy
2016-10-07 13:18:48 +11:00
Damien George 056da75a8a esp8266: Make PY_UHASHLIB_SHA1 config depend on PY_USSL and SSL_AXTLS.
SHA1 can only be supported if ussl module is compiled in, and it uses
axtls.
2016-10-06 12:28:28 +11:00
puuu bcf60b43ee esp8266/modpybrtc.c: Implement machine.RTC.alarm_left()
Implementation of machine.RTC.alarm_left(), like described in the
documentation.
2016-10-05 12:20:30 +11:00
Paul Sokolovsky 161e9f4115 esp8266/main: Put /lib before / in sys.path.
upip will use first non-empty component in sys.path as an install path
(if MICROPYPATH envvar is not set, like it will be for baremetal targets).
2016-10-05 00:02:51 +03:00
Paul Sokolovsky 52784bf595 esp8266/modmachine: idle(): Return number of CPU cycles spent idling.
Useful to better understand esp8266 inner workings and compare behavior
in different cases.
2016-10-04 21:20:47 +03:00
Damien George b932b2dd1f extmod/machine_spi: Use delay_half, not baudrate, for internal timing.
The delay_half parameter must be specified by the port to set up the
timing of the software SPI.  This allows the port to adjust the timing
value to better suit its timing characteristics, as well as provide a
more accurate printing of the baudrate.
2016-10-04 13:43:02 +11:00
Damien George bd87375202 esp8266/moduos: Move stat/statvfs funcs to sit within #if VFS guard. 2016-10-03 21:48:32 +11:00
Damien George d434ce3fca extmod/machine_spi: Factor out software SPI code from esp8266 to extmod. 2016-10-03 16:43:44 +11:00
Damien George 5bb28c7f10 extmod/machine_spi: Simplify SPI xfer function to only take one buf len.
There is no need to take src_len and dest_len arguments.  The case of
reading-only with a single output byte (originally src_len=1, dest_len>1)
is now handled by using the output buffer as the input buffer, and using
memset to fill the output byte into this buffer.  This simplifies the
implementations of the spi_transfer protocol function.
2016-10-03 12:39:31 +11:00
Paul Sokolovsky 6ab2c5e6cc lib/interrupt_char: Factor out typical Ctrl+C handling from esp8266 port.
Utility functions for keyboard interrupt handling, to be reused across
(baremetal) ports.
2016-09-29 10:15:38 -07:00
Alex March 4fb72fe624 esp8266: Add uos.statvfs() to get filesystem status. 2016-09-27 13:49:05 +10:00
Damien George 93c4a6a3f7 all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
2016-09-22 00:23:16 +10:00
Damien George 34e0198436 esp8266: Extend system microsecond counter to 64-bits; use in ticks_ms.
So now ticks_ms can count up to the full 30 bits.  Fixes issue #2412.
2016-09-20 14:28:17 +10:00
Paul Sokolovsky 4b3f1d712b esp8266/esp_mphal: Add tentative change to mp_hal_stdin_rx_chr() to wait IRQ.
Instead of busy-looping waiting for UART input. Not enabled by default,
needs more testing.
2016-09-19 00:23:38 +03:00
Paul Sokolovsky 3fe047f08f esp8266/ets_alt_task: ets_post: Should return 0 on success, !0 - failure. 2016-09-18 23:01:58 +03:00
Paul Sokolovsky f28efa1971 py: Move frozen modules rules from esp8266 port for reuse across ports.
A port now just needs to define FROZEN_DIR var and add $(BUILD)/frozen.c
to SRC_C to support frozen modules.
2016-09-17 21:00:40 +03:00
Paul Sokolovsky 8ae885a0c6 esp8266/Makefile: Rename SCRIPTDIR to FROZEN_DIR for consistency.
With FROZEN_MPY_DIR.
2016-09-17 21:00:04 +03:00
Damien George f3b5480be7 stmhal,cc3200,esp8266: Consistently use PWRON_RESET constant.
machine.POWER_ON is renamed to machine.PWRON_RESET to match other
reset-cause constants that all end in _RESET.  The cc3200 port keeps a
legacy definition of POWER_ON for backwards compatibility.
2016-09-08 12:50:38 +10:00
Paul Sokolovsky 742d8bdbe4 esp8266/modmachine: Map PWR_ON_RESET to vendor's REASON_DEFAULT_RST.
When dealing with a board which controls chip reset with UART's DTR/RTS,
we never see REASON_DEFAULT_RST (0), only REASON_EXT_SYS_RST (6). However,
trying a "raw" module with with just TXD/RXD UART connection, on power up
it has REASON_DEFAULT_RST as a reset reason.
2016-09-07 00:59:02 +03:00
Damien George b4be5a8f34 esp8266/modnetwork: Fix wlan.scan() method so it returns all networks.
According to the Arduino ESP8266 implementation the first argument to the
wifi scan callback is actually a bss_info pointer.  This patch fixes the
iteration over this data so the first 2 entries are no longer skipped.

Fixes issue #2372.
2016-09-06 15:30:39 +10:00
Torsten Wagner 69768c97c0 esp8266/espneopixel: Disable IRQs during eps.neopixel_write.
Interrupts during neopixel_write causes timing problems and therefore
wrong light patterns.  Switching off IRQs should help to keep the strict
timing schedule.
2016-09-06 11:51:35 +10:00
Damien George 9526e24234 unix,stmhal,esp8266: When find'ing frozen files follow symbolic links.
It's useful to be able to use symbolic links to add files and directories
to the set of scripts to be frozen.
2016-09-05 12:35:05 +10:00
Delio Brignoli e2ac8bb3f1 py: Add MICROPY_USE_INTERNAL_PRINTF option, defaults to enabled.
This new config option allows to control whether MicroPython uses its own
internal printf or not (if not, an external one should be linked in).
Accompanying this new option is the inclusion of lib/utils/printf.c in the
core list of source files, so that ports no longer need to include it
themselves.
2016-09-05 12:18:53 +10:00
Paul Sokolovsky dba40afa70 esp8266/modmachine: Simplify SPI class implementation multiplexing.
modpybhspi now does the needed multiplexing, calling out to modpybspi
(bitbanging SPI) for suitable peripheral ID's. modmachinespi (previous
multiplexer class) thus not needed and removed.

modpybhspi also updated to following standard SPI peripheral naming:
SPI0 is used for FlashROM and thus not supported so far. SPI1 is available
for users, and thus needs to be instantiated as:

spi = machine.SPI(1, ...)
2016-09-04 20:33:11 +03:00
Paul Sokolovsky 7ddd1a58f6 esp8266/modmachine: Don't expose internal SoftSPI and HSPI classes.
There functionality is available via standard SPI class.
2016-09-04 19:57:16 +03:00
Paul Sokolovsky 1708fe3cc7 esp8266/modmachine: Add WDT_RESET and SOFT_RESET constants.
Both tested to work. (WDT_RESET can be seen by issuing machine.disable_irq()
and waiting for WDT reset, SOFT_RESET - by machine.reset()).
2016-09-04 19:45:58 +03:00
Paul Sokolovsky 015774a04f esp8266/modmachinewdt: Add .deinit() method. 2016-09-03 20:45:11 +03:00
Paul Sokolovsky 4a33677c97 esp8266/esp8266.ld: Move modmachinewdt to FlashROM. 2016-09-03 20:44:24 +03:00
Damien George 3be8b688c0 esp8266/modpybhspi: Simplify HSPI driver by using 1 function for xfers. 2016-09-01 16:40:12 +10:00
Damien George 5863e15a23 esp8266/modpybspi: Use generic SPI helper methods to implement SPI. 2016-09-01 16:39:42 +10:00
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