Commit Graph

94 Commits

Author SHA1 Message Date
Damien George
d2384efa80 py: Automatically provide weak links from "foo" to "ufoo" module name.
This commit implements automatic module weak links for all built-in
modules, by searching for "ufoo" in the built-in module list if "foo"
cannot be found.  This means that all modules named "ufoo" are always
available as "foo".  Also, a port can no longer add any other weak links,
which makes strict the definition of a weak link.

It saves some code size (about 100-200 bytes) on ports that previously had
lots of weak links.

Some changes from the previous behaviour:
- It doesn't intern the non-u module names (eg "foo" is not interned),
  which saves code size, but will mean that "import foo" creates a new qstr
  (namely "foo") in RAM (unless the importing module is frozen).
- help('modules') no longer lists non-u module names, only the u-variants;
  this reduces duplication in the help listing.

Weak links are effectively the same as having a set of symbolic links on
the filesystem that is searched last.  So an "import foo" will search
built-in modules first, then all paths in sys.path, then weak links last,
importing "ufoo" if it exists.  Thus a file called "foo.py" somewhere in
sys.path will still have precedence over the weak link of "foo" to "ufoo".

See issues: #1740, #4449, #5229, #5241.
2019-10-22 15:30:52 +11:00
Damien George
f1d91908fa esp8266/boards: Add manifest_release.py with files for a release.
A release also sets: UART_OS = -1
2019-10-22 00:23:22 +11:00
Jim Mussared
df7f632fd7 esp8266: Allow building without a manifest. 2019-10-21 23:21:14 +11:00
Jim Mussared
8ba963cfa3 tools/makemanifest.py: Eval relative paths w.r.t. current manifest file.
When loading a manifest file, e.g. by include(), it will chdir first to the
directory of that manifest.  This means that all file operations within a
manifest are relative to that manifest's location.

As a consequence of this, additional environment variables are needed to
find absolute paths, so the following are added: $(MPY_LIB_DIR),
$(PORT_DIR), $(BOARD_DIR).  And rename $(MPY) to $(MPY_DIR) to be
consistent.

Existing manifests are updated to match.
2019-10-21 23:01:41 +11:00
Damien George
2fd3f2520d esp8266: Convert to use FROZEN_MANIFEST to specify frozen code.
Removes symlinks in modules directory, all frozen code is now specified by
manifest.py.
2019-10-15 21:36:02 +11:00
Damien George
d7a9388fe0 ports: Add new make target "submodules" which inits required modules. 2019-10-15 17:14:41 +11:00
Damien George
79ab82ea77 esp8266/modules/ntptime.py: Always close socket, and set day-of-week.
Fixes issue #5189.
2019-10-10 18:05:56 +11:00
Mike Causer
53a9b45da1 esp8266: Add per-board configs, following other ports.
The specific board can be selected with the BOARD makefile variable.  This
defaults (if not specified) to BOARD=GENERIC, which is the original default
firmware build.  For the 512k target use BOARD=GENERIC_512K.
2019-10-10 16:32:25 +11:00
Damien George
0e72cc9029 esp8266/machine_adc: Add read_u16 method and refactor. 2019-09-05 22:13:04 +10:00
Damien George
625609a737 esp8266/machine_adc: Rename pyb_adc_* to machine_adc_*. 2019-09-04 16:17:10 +10:00
Damien George
060209240b esp8266: Put new profile code in iROM. 2019-08-30 16:49:02 +10:00
Damien George
96ace8082e esp8266/machine_uart: Allow remapping UART TX/RX pins from 1/3 to 15/13.
Via the standard tx/rx arguments: UART(0, 115200, tx=Pin(15), rx=Pin(13)).

Resolves issue #4718.
2019-08-21 21:16:40 +10:00
Damien George
2d3d4f7483 esp8266/mpconfigport.h: Enable lwIP raw sockets. 2019-08-06 15:56:05 +10:00
Damien George
ef00048fed extmod/modwebrepl: Add config option to put filebuf[512] on stack/bss.
Since the esp8266 has a small stack this buffer is kept in the BSS.
2019-07-03 12:55:57 +10:00
Damien George
89a23a05b3 esp8266: Provide custom machine_time_pulse_us that feeds soft WDT.
So that the timeout for machine.time_pulse_us() can be large.

Fixes issue #2775.
2019-07-01 22:53:00 +10:00
Damien George
c80614dfc8 ports: Provide mp_hal_stdio_poll for sys.stdio polling where needed. 2019-07-01 17:10:12 +10:00
Paul m. p. P
637aa9784d esp8266/uart: Fix invalid ringbuf name when event driven REPL enabled. 2019-06-17 12:34:10 +10:00
Damien George
5357dad52e esp8266: Fix ticks_ms to correctly handle wraparound of system counter.
Fixes issue #4795.
2019-05-24 15:37:34 +10:00
Paul Sokolovsky
016d9a40fe various: Add and update my copyright line based on git history.
For modules I initially created or made substantial contributions to.
2019-05-17 18:04:15 +10:00
Damien George
99a8fa7940 esp8266/modmachine: Handle overflow of timer to get longer periods.
Can now handle up to about 298 days maximum for millisecond periods.

Fixes issue #4664.
2019-05-10 15:50:35 +10:00
Damien George
0646e607b5 ports: Convert to use pyexec_file_if_exists() to execute boot/main.py.
The stm32 and nrf ports already had the behaviour that they would first
check if the script exists before executing it, and this patch makes all
other ports work the same way.  This helps when developing apps because
it's hard to tell (when unconditionally trying to execute the scripts) if
the resulting OSError at boot up comes from missing boot.py or main.py, or
from some other error.  And it's not really an error if these scripts don't
exist.
2019-04-26 15:22:14 +10:00
Damien George
c7d19dc0ad ports/{stm32,esp8266}: Set mpy-cross native arch for frozen native code. 2019-03-14 12:22:49 +11:00
Damien George
b5f33ac2cb ports: Update to work with new oofatfs version. 2019-03-05 15:56:39 +11:00
Damien George
8ce22662fe esp8266/modmachine: Call ets_event_poll after waiti in machine.idle.
Because "waiti 0" may have waited for a while (eg 500ms) and the internal
WDT may need to be fed immediately.

Fixes issue #4459.
2019-02-28 15:44:37 +11:00
Yonatan Goldschmidt
bc4f8b438b extmod/moduwebsocket: Refactor websocket to uwebsocket.
As mentioned in #4450, `websocket` was experimental with a single intended
user, `webrepl`. Therefore, we'll make this change without a weak
link `websocket` -> `uwebsocket`.
2019-02-14 00:35:45 +11:00
Mike Causer
812969d615 all: Change PYB message prefix to MPY.
Replaces "PYB: soft reboot" with "MPY: soft reboot", etc.

Having a consistent prefix across ports reduces the difference between
ports, which is a general goal.  And this change won't break pyboard.py
because that tool only looks for "soft reboot".
2019-02-12 15:18:33 +11:00
Damien George
6e30f96b0b ports: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
Damien George
3ff3e96865 esp8266/modmachine: In lightsleep, only waiti if wifi is turned off.
Otherwise the STA interface can't do DTIM sleeping correctly and power
consumption goes up.
2019-01-31 00:05:00 +11:00
Damien George
808dc95ab8 esp8266/modmachine: Implement simple machine.lightsleep function.
Use of "waiti 0" reduces power consumption by about 3mA compared to a
time.sleep_ms call.
2019-01-30 14:05:53 +11:00
Damien George
2911e3554a esp8266/modmachine: Rename machine.sleep to machine.lightsleep.
While keeping machine.sleep as an alias for machine.lightsleep for
backwards compatibility.
2019-01-30 14:05:53 +11:00
Damien George
d7cc92383c esp8266/modmachine: Implement optional time_ms arg to machine.deepsleep. 2019-01-30 14:05:53 +11:00
Damien George
18d3a5df26 esp8266/esp_mphal: Provide mp_hal_pin_od_high_dht so DHT works reliably.
The original behaviour of open-drain-high was to use the open-drain mode of
the GPIO pin, and this seems to make driving a DHT more reliable.  See
issue #4233.
2019-01-22 00:26:04 +11:00
Damien George
36808d4e6a esp8266/main: Activate UART(0) on dupterm for REPL before boot.py runs.
So that the user can explicitly deactivate UART(0) if needed.  See
issue #4314.

This introduces some risk to "brick" the device, if the user disables the
REPL without providing an alternative REPL (eg WebREPL), or any way to
reenable it.  In such a case the device needs to be erased and
reprogrammed.  This seems unavoidable, given the desire to have the option
to use the UART for something other than the REPL.
2019-01-16 17:24:23 +11:00
Damien George
52bec93755 esp8266/machine_uart: Add rxbuf keyword arg to UART constructor/init.
As per the machine.UART documentation, this is used to set the length of
the UART RX buffer.
2018-12-05 23:31:24 +11:00
Damien George
da1d849ad1 stm32,esp8266,cc3200: Use MICROPY_GC_STACK_ENTRY_TYPE to save some RAM. 2018-12-04 18:32:10 +11:00
Damien George
62b4bebf64 esp8266/modnetwork: Wait for iface to go down before forcing power mgmt.
If the STA interface is connected to an AP then it must be fully
disconnected and deactivated before forcing the power management on.
2018-12-04 10:20:45 +11:00
Damien George
321d75e087 esp8266/modnetwork: Automatically do radio sleep if no interface active.
Reduces current of device by about 55mA when radio is sleeping.
2018-12-01 17:20:05 +11:00
Damien George
9e2dd93145 esp8266/ets_alt_task: Process idle callback if no other events occurred. 2018-12-01 17:20:05 +11:00
Damien George
51482ba925 README: Remove references to "make axtls", it's no longer needed.
Since 0be2ea50e9 axtls is automatically built
as part of the usual "make" build process.
2018-11-15 14:48:17 +11:00
Damien George
746dbf78d3 py/py.mk: When building axtls use -Wno-all to prevent all warnings.
Building axtls gives a lot of warnings with -Wall enabled, and explicitly
disabling all of them cannot be done in a way compatible with gcc and
clang, and likely other compilers.  So just use -Wno-all to prevent all of
the extra warnings (in addition to the necessary -Wno-unused-parameter,
-Wno-uninitialized, -Wno-sign-compare and -Wno-old-style-definition).

Fixes issue #4182.
2018-10-27 23:53:08 +11:00
Damien George
bbccb0f630 esp8266: Remove scanning of GC pointers in native code block.
The native code no longer holds live GC pointers so doesn't need to be
scanned.
2018-09-27 23:46:09 +10:00
Damien George
5cd2c7f2e7 esp8266/main: Increase heap by 2kb, now that axtls rodata is in ROM. 2018-09-08 00:09:03 +10:00
Damien George
eed83caf1d esp8266/Makefile: Remove build of libaxtls.a and add back tuned config. 2018-09-08 00:07:23 +10:00
Damien George
da2d2b6d88 py/mpconfig.h: Introduce MICROPY_DEBUG_PRINTER for debugging output.
This patch in effect renames MICROPY_DEBUG_PRINTER_DEST to
MICROPY_DEBUG_PRINTER, moving its default definition from
lib/utils/printf.c to py/mpconfig.h to make it official and documented, and
makes this macro a pointer rather than the actual mp_print_t struct.  This
is done to get consistency with MICROPY_ERROR_PRINTER, and provide this
macro for use outside just lib/utils/printf.c.

Ports are updated to use the new macro name.
2018-08-02 14:04:44 +10:00
Nicko van Someren
c3c914f4dd esp8266,esp32: Implement high-res timers using new tick_hz argument.
machine.Timer now takes a new argument in its constructor (or init method):
tick_hz which specified the units for the period argument.  The period of
the timer in seconds is: period/tick_hz.

For backwards compatibility tick_hz defaults to 1000.  If the user wants to
specify the period (numerator) in microseconds then tick_hz can be set to
1000000.  The user can also specify a period of an arbitrary number of
cycles of an arbitrary frequency using these two arguments.

An additional freq argument has been added to allow frequencies to be
specified directly in Hertz.  This supports floating point values when
available.
2018-07-17 13:17:23 +10:00
Damien George
bccf9d3dcf esp8266: Let machine.WDT trigger the software WDT if obj is not fed.
This patch allows scripts to have more control over the software WDT.  If
an instance of machine.WDT is created then the underlying OS is prevented
from feeding the software WDT, and it is up to the user script to feed it
instead via WDT.feed().  The timeout for this WDT is currently fixed and
will be between 1.6 and 3.2 seconds.
2018-07-03 15:31:10 +10:00
Damien George
b6e5f82ba5 esp8266/modesp: Run ets_loop_iter before/after doing flash erase/write.
A flash erase/write takes a while and during that time tasks may be
scheduled via an IRQ.  To prevent overflow of the task queue (and loss of
tasks) call ets_loop_iter() before and after slow flash operations.

Note: if a task is posted to a full queue while a flash operation is in
progress then this leads to a fault when trying to print out the error
message that the queue is full.  This patch doesn't try to fix this
particular issue, it just prevents it from happening in the first place.
2018-07-03 14:46:29 +10:00
Damien George
8f86fbfd6c ports: Enable ure.sub() on stm32, esp8266 (not 512k) and esp32. 2018-07-02 15:13:18 +10:00
Damien George
d800ed1877 esp8266/esp8266_common.ld: Put mp_keyboard_interrupt in iRAM.
This function may be called from a UART IRQ, which may interrupt the system
when it is erasing/reading/writing flash.  In such a case all code
executing from the IRQ must be in iRAM (because the SPI flash is busy), so
put mp_keyboard_interrupt in iRAM so ctrl-C can be caught during flash
access.

This patch also takes get_fattime out of iRAM and puts it in iROM to make
space for mp_keyboard_interrupt.  There's no real need to have get_fattime
in iRAM because it calls other functions in iROM.

Fixes issue #3897.
2018-06-28 12:55:54 +10:00
Damien George
bc6c56d75d esp8266/mpconfigport.h: Enable ucryptolib module for standard build.
It remains disabled for the 512k build.
2018-06-27 16:45:22 +10:00