This uses MP_REGISTER_ROOT_POINTER() to register bluetooth_nimble_memory
and bluetooth_nimble_root_pointers and removes the same from all
mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register
bluetooth_btstack_root_pointers and removes the same from all
mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register mp_wifi_spi, mp_wifi_timer
and mp_wifi_sockpoll_list and removes the same from all mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register mmap_region_head and
removes the same from mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register the readline_history root
pointer array used by shared/readline.c and removes the registration from
all mpconfigport.h files.
This also required adding a new MICROPY_READLINE_HISTORY_SIZE config option
since not all ports used the same sized array.
Signed-off-by: David Lechner <david@pybricks.com>
This adds new compile-time infrastructure to parse source code files for
`MP_REGISTER_ROOT_POINTER()` and generates a new `root_pointers.h` header
file containing the collected declarations. This works the same as the
existing `MP_REGISTER_MODULE()` feature.
Signed-off-by: David Lechner <david@pybricks.com>
Some devices, such as the LightBlue BTLE app on iOS, try to use Bluetooth 5
when connecting to a device. This means that they will send a
BLE_GAP_EVT_PHY_UPDATE_REQUEST message to shift to a new physical layer.
If this event isn't handled, LightBlue (and likely other Bluetooth 5.0
central devices) will try to connect and then fail, staying in
"Connecting..." state forever. This message should be replied to with
sd_ble_gap_phy_update, as documented in
drivers/bluetooth/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API/include/ble_gap.h.
This commit handles the event. LightBlue can now successfully connect to a
BTLE device on a P10059 nRF52840 dongle running MicroPython. Two other
related events have logging added in case they are needed in the future.
Commit 0e28a1f0e5 made it possible to set
-march=armv6m. It needs to be used when freezing for rp2.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Since nlr_jump_fail() exits the process, it can leave the terminal in raw
mode which means characters are not echoed. Fix this by restoring the
original terminal mode.
Signed-off-by: David Lechner <david@pybricks.com>
When a flash write/erase is in progress, we need to ensure that the
other core cannot be using XIP.
This also implements MICROPY_BEGIN_ATOMIC_SECTION as a full mutex, which
is necessary as it's used to syncronise access to things like the scheduler
queue.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The goal is to avoid a situation where core 1 is shut down while holding
the tinyusb spinlock, which could happen during soft reset if
mp_thread_deinit is called while core1 is running tud_task().
This also fixes a latent race where the two cores are competing to
decrement and compare `vm_hook_divisor` with no mem fence or atomic
protection -- only core0 will now do this.
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>