The optimisation that allows a single check in the VM for either a pending
exception or non-empty scheduler queue doesn't work when threading is
enabled, as one thread can clear the sched_state if it has no pending
exception, meaning the thread with the pending exception will never see it.
This removes that optimisation for threaded builds.
Also fixes a race in non-scheduler builds where get-and-clear of the
pending exception is not protected by the atomic section.
Also removes the bulk of the inlining of pending exceptions and scheduler
handling from the VM. This just costs code size and complexity at no
performance benefit.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
To override it a board must define MICROPY_BOARD_FATAL_ERROR to a function
that takes a string message and does not return.
Signed-off-by: Damien George <damien@micropython.org>
The file `ports/unix/moduos.c` uses `errno` so it needs to include
`errno.h`, otherwise a compiler error can occur.
Signed-off-by: David Lechner <david@pybricks.com>
Ensure that nimble and cyw43-driver are initialised when the board requires
it. Also make these work with `make submodules`.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Commit 9670a156da missed one renaming of
MICROPY_PY_WIZNET5K to MICROPY_PY_NETWORK_WIZNET5K which prevented the
Wiznet interface from being enabled.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This includes:
- Configuration file for the cyw43-driver.
- Integration of cyw43-driver into the build, using lwIP.
- Enhancements to machine.Pin to support extension IO pins provided by the
CYW43xx.
- More mp-hal pin helper functions.
- mp_hal_get_mac_ascii MAC address helper function.
- Addition of rp2.country() function to set the country code.
A board can enable this driver by setting MICROPY_PY_NETWORK_CYW43 in their
cmake snippet.
Work done in collaboration with Graham Sanderson and Peter Harper.
Signed-off-by: Damien George <damien@micropython.org>
It is more reliable and scales better when more components need it.
Work done in collaboration with Graham Sanderson and Peter Harper.
Signed-off-by: Damien George <damien@micropython.org>
Prior to this commit the following code would lock up the device when
Ctrl-D is entered at the REPL:
import gc, _thread
def collect_thread():
while True:
gc.collect()
_thread.start_new_thread(collect_thread, [])
Fixes part of #8494.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This gets basic machine.lightsleep([n]) behaviour working on the rp2 port.
It supports:
- Calling lightsleep without a specified period, in which case it uses xosc
dormant mode. There's currently no way to wake it up from this state,
unless you write to raw registers to enable a GPIO wake up source.
- Calling lightsleep with a period n in milliseconds. This period must be
less than about 72 minutes and uses timer alarm3 to wake it up.
The RTC continues to run during lightsleep, but other peripherals have
their clock turned off during the sleep.
It doesn't yet support longer periods than 72 minutes, or waking up from
GPIO IRQ.
Measured current consumption from the USB port on a PICO board is about
1.5mA when doing machine.lightsleep(5000), and about 0.9mA when doing
machine.lightsleep().
Addresses issue #8770.
Signed-off-by: Damien George <damien@micropython.org>
This ROM level is not yet fully defined, but it at least enables
MICROPY_PY_SYS_TRACEBACKLIMIT. The coverage build should have everything
enabled, so it makes sense to use this ROM level for it.
Signed-off-by: Damien George <damien@micropython.org>
So that the default configuration for the dev and coverage variants
includes all options set by MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES.
Note that enabling MICROPY_PY_SYS_STDIO_BUFFER on unix doesn't do anything
because unix doesn't use shared/runtime/sys_stdio_mphal.c.
Signed-off-by: Damien George <damien@micropython.org>
The default is the same as before: MICROPY_PY_USELECT=0 and
MICROPY_PY_USELECT_POSIX=1. But now this can be easily overridden at the
make command-line using, eg:
make VARIANT=dev CFLAGS_EXTRA=-DMICROPY_PY_USELECT=1
Signed-off-by: Damien George <damien@micropython.org>
Prior to this commit, running scan() without any APs available would give:
>>> wl.scan()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: Wifi Unknown Error 0x0102
Signed-off-by: Damien George <damien@micropython.org>