Commit Graph

3041 Commits

Author SHA1 Message Date
robert-hh
13dceaa4ea esp32/machine_uart: Change sendbreak time to be at least 15 bit times.
It used to be 10 bit times, which is too short.  The break state must be
longer than a regular character time, at least 13 bit times.  This is now
implemented by reducing the baudrate while sending the "0".  The break time
will now vary with data length and parity setting, but will at least be 15
bit times.

Tested with a GENERIC_SPIRAM, GENERIC_C3 and UM_TINYS2 board.
2022-08-23 17:22:15 +10:00
glenn20
e6e60f4330 esp8266/modnetwork: Add support for WLAN.config(protocol=XX) option.
Following esp32.  This is preferred to using the phy_mode() function.
2022-08-23 16:33:19 +10:00
glenn20
0507f239e8 esp32/modnetwork: Add network.MODE_LR constant.
Adds the MODE_LR constant to the network module to support Espressif's
long-range communication protocol.
2022-08-23 16:33:03 +10:00
glenn20
76f2e3e62b esp32/network_wlan: Add support to set/get the wifi protocol.
Add 'protocol' option to WLAN.config() to support setting/getting the wifi
protocol modes: MODE_11G|MODE_11G|MODE_11N.
2022-08-23 16:32:30 +10:00
glenn20
98d1c50159 esp32/network_wlan: Use esp_wifi_set/get_channel to config wifi channel.
Set the channel with esp_wifi_set_channel(), which adds support for setting
the channel of the STA interface

Get the channel with esp_wifi_get_channel() which returns the actual wifi
channel of the radio, rather than the configured channel.
2022-08-23 16:28:49 +10:00
robert-hh
47c45d0e7f rp2/machine_wdt: Check for the maximum timeout value of watchdog.
The value will be checked for timeout <= 8388.  Notes were added to the
documentation.
2022-08-23 16:26:29 +10:00
robert-hh
54eaa8c8a6 stm32/mphalport: Add mp_hal_get_spi_obj() helper function.
The function spi_from_mp_obj() is kept since it is used by the cc3k driver.
2022-08-23 14:59:48 +10:00
robert-hh
c3305c49e4 stm32: Add definitions required for lwIP version of Wiznet NIC. 2022-08-23 14:58:13 +10:00
robert-hh
717924001d stm32: Switch Wiznet to use lib/wiznet5k and extmod/network_wiznet5k.
Instead of the old Wiznet driver in drivers/wiznet5k.
2022-08-23 14:57:54 +10:00
Chris Waggoner
b1efc1340a mpy-cross,unix: Include alloca.h for NetBSD. 2022-08-23 13:39:18 +10:00
Nicholas H.Tollervey
af54d2ce9f
javascript: Rename this port to 'webassembly'. 2022-08-22 12:03:39 +01:00
Damien George
8f4c108025 all: Remove MICROPY_PY_IO_FILEIO config option.
Since commit e65d1e69e8 there is no longer an
io.FileIO class, so this option is no longer needed.

This option also controlled whether or not files supported being opened in
binary mode (eg 'rb'), and could, if disabled, lead to confusion as to why
opening a file in binary mode silently did the wrong thing (it would just
open in text mode if MICROPY_PY_IO_FILEIO was disabled).

The various VFS implementations (POSIX, FAT, LFS) were the only places
where enabling this option made a difference, and in almost all cases where
one of these filesystems were enabled, MICROPY_PY_IO_FILEIO was also
enabled.  So it makes sense to just unconditionally enable this feature
(ability to open a file in binary mode) in all cases, and so just remove
this config option altogether.  That makes configuration simpler and means
binary file support always exists (and opening a file in binary mode is
arguably more fundamental than opening in text mode, so if anything should
be configurable then it should be the ability to open in text mode).

Signed-off-by: Damien George <damien@micropython.org>
2022-08-18 11:54:17 +10:00
Efi Weiss
98bd7e33b3 unix/modusocket: Support proto and flags arguments to getaddrinfo.
Signed-off-by: Efi Weiss <efiwiss@gmail.com>
2022-08-17 12:02:42 +10:00
Angus Gratton
a16a330da5 nrf,stm32: Don't enable debug info by default if LTO is on.
It seems sometimes gcc with LTO will generate otherwise valid assembly
listings that cause 'as' to error out when generating DWARF debug info; see
https://sourceware.org/bugzilla/show_bug.cgi?id=29494

Therefore, don't enable -g by default if LTO is on.

Enabling LTO=1 DEBUG=1 is still possible but may result in random errors
at link time due to 'as' (the error in this case is "Error: unaligned
opcodes detected in executable segment", and the only other easy workaround
is CFLAGS+=-fno-jump-tables which may increase code size significantly).

Follows on from fdfe4eca74
2022-08-15 22:55:34 +10:00
Damien George
ec24cd1d25 mpy-cross,unix: Remove .gitignore file.
Now that all build artefacts are placed in a build/ directory the gitignore
is no longer needed.

Signed-off-by: Damien George <damien@micropython.org>
2022-08-12 16:38:04 +10:00
Jim Mussared
28aaab9590 py/objstr: Add hex/fromhex to bytes/memoryview/bytearray.
These were added in Python 3.5.

Enabled via MICROPY_PY_BUILTINS_BYTES_HEX, and enabled by default for all
ports that currently have ubinascii.

Rework ubinascii to use the implementation of these methods.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-12 12:44:30 +10:00
Damien George
6c67fbc280 zephyr/machine_uart: Use mp_obj_str_get_str to get device name.
This checks that the argument is actually a string.

Signed-off-by: Damien George <damien@micropython.org>
2022-08-11 23:18:02 +10:00
Damien George
787bd99919 nrf/modules/ubluepy: Use mp_obj_str_get_data to extract str data.
Instead of GET_STR_DATA_LEN, which is intended to be a private macro.

Signed-off-by: Damien George <damien@micropython.org>
2022-08-11 23:18:02 +10:00
Jim Mussared
94a19f1062 windows/Makefile: Update test dependency on $(PROG).
PR #9012 (b2e8240268) changed the output to
$(BUILD)/$(PROG) but the tests are still looking for $(PROG).

Also remove the now-unnecessary override of $(PROG) in the standard
variant.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-11 16:53:43 +10:00
David Lechner
888e831bf7 docs: Update links for Arm GCC toolchain.
The separate A and RM toolchains have been discontinued and replaced
by a single toolchain. This updates the links to the RM toolchain to
the new toolchain.

Signed-off-by: David Lechner <david@pybricks.com>
2022-08-11 14:27:06 +10:00
Jacob Siverskog
0546a12238 rp2: Correctly determine path to arm-none-eabi-size.
Figure out path to arm-none-eabi-size the same way it's done for the
other binaries, instead of assuming it to be in the user's $PATH.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2022-08-11 14:23:28 +10:00
Phil Howard
71f6eb5ac9 rp2: Mark gc_heap NOLOAD for faster boot.
Create a new linker section .unitialized_bss for bss that does not need
zero-initialising.

Move gc_heap to this section, which saves ~30ms from rising edge of RESET
to setting a pin HIGH in MicroPython.

Zero fill happens in Pico SDK crt0.S before ROSC is configured.  It's very,
very slow.

Signed-off-by: Phil Howard <phil@gadgetoid.com>
2022-08-11 14:16:29 +10:00
omogenot
6e51dbd95a rp2/boards/W5500_EVB_PICO: Add new board definition for W5500_EVB_PICO.
Signed-off-by: github@mymeterinfo.info
2022-08-11 14:12:55 +10:00
David Yang
b6651a7a89 unix/modjni: Add missing const qualifier. 2022-08-11 14:09:16 +10:00
Daniel Jour
9c6fd974f7 minimal/Makefile: Avoid terminal reset, use BUILD variable.
stty can provide the current terminal settings, so that they can be
stored in a shell variable and restored after running the firmware. This
avoids the complete "blanking" of the terminal, and thus also removes the
need for the sleep call.

The run target now references the firmware file using the BUILD variable
instead of using the hard coded "build/" path.
2022-08-11 14:07:18 +10:00
Damien George
d53c3b6ade unix/variants: Remove variant suffix from executable filename.
The executable now lives in the build directory, and since the build
directory already contains the variant name there is no need to also add
it to the executable.

Signed-off-by: Damien George <damien@micropython.org>
2022-08-11 13:34:34 +10:00
Daniel Jour
47c84286e8 all: Fix paths to mpy-cross and micropython binaries.
Binaries built using the Make build system now no longer appear in the
working directory of the build, but rather in the build directory.  Thus
some paths had to be adjusted.
2022-08-11 13:31:13 +10:00
Damien George
5cfbf18d5f javascript/Makefile: Remove obsolete disable of array-bounds warning.
This was fixed in bb70874111

Signed-off-by: Damien George <damien@micropython.org>
2022-08-10 14:31:15 +10:00
Damien George
f72d3cec23 rp2/machine_spi: Add mp_hal_get_spi_obj helper function.
And remove the now-obsolete spi_from_mp_obj() function.

Signed-off-by: Damien George <damien@micropython.org>
2022-08-10 14:05:02 +10:00
Andrew Leech
6804b6f54f stm32/boards/NUCLEO_WB55: Add error handling to firmware update scripts.
In-the-field use of these FUS/WS firmware update scripts has exposed some
weak points, causing corrupted FUS/WS firmware to be flashed to the unit.

The problems are mostly caused with the ST GUI application, but sometimes
from un-recognised failures during bin file transfer to the WB55 prior to
running the rfcore_firmware.py script.  Other failures were caused by
incorrect load addresses being used, again both from user error copying the
address from the HTML release notes to the GUI tool, but also from
similarly not updating the address correctly in rfcore_firmware.py

To guard against these errors and make it easier to prepare different
versions, this commit adds a few features to the rfcore firmware update
tools:
- When creating the bin file, automatically parse the release note in the
  folder to get the correct address.
- Add a footer to the bin file containing the name, version, CRC, address
  etc.
- Before flashing rfcore, check if the same version is already installed.
- Verify the CRC and obfuscation key before flashing bin.
- Log the name and version of file being flashed.
2022-08-08 23:42:20 +10:00
Ian Davies
fbe9417b90 extmod/ntptime: Factor out ntptime module from esp8266 port.
The ntptime module was previously only included in the ESP8266 port.  This
commit factors that module out into the extmod directory, makes it support
different epochs, and includes it in the rp2 port.
2022-08-06 00:08:32 +10:00
Ian Davies
b560b9fe71 rp2/mbedtls: Enable certificate validity time validation. 2022-08-06 00:08:01 +10:00
David Lechner
10f85fee18 stm32/boards/LEGO_HUB_NO7: Add LEGO Hub No. 7 board definition.
This adds support for the LEGO Hub No. 7, aka LEGO Technic Small hub, aka
LEGO SPIKE Essential hub.  This board is largely similar to Hub No. 6:

- Same MCU (STM32F413 - different packaging with fewer pins).
- Same Bluetooth chip (TI CC2564).
- Same IMU chip.
- Similar external flash chip - 4MiB instead of 32MiB.
- 2 I/O ports instead of 6.
- No display - only status and battery LEDs.
- Different LED driver chip.
- Only 1 button which is also the power button.
- No speaker.

Signed-off-by: David Lechner <david@pybricks.com>
2022-08-06 00:01:31 +10:00
David Lechner
0f0f2351bb stm32/boards/LEGO_HUB_NO6/cc2564: Make timer configurable.
This adds configurable macros to define the timer and channel used to
provide the Bluetooth 32768 MHz clock.  This will allow code to be shared
with LEGO_HUB_NO7.

Signed-off-by: David Lechner <david@pybricks.com>
2022-08-06 00:01:28 +10:00
David Lechner
f69af16619 stm32/boards/LEGO_HUB_NO6/spiflash: Pick command type at runtime.
This changes spiflash.py to read the flash chip ID at runtime to select the
read/write/erase commands.  This will allow the code to be shared with
LEGO_HUB_NO7 which doesn't use the 32-bit commands.

Also remove an unused constant while we are touching this.

Signed-off-by: David Lechner <david@pybricks.com>
2022-08-06 00:01:24 +10:00
David Lechner
9a51273d96 stm32/boards/LEGO_HUB_NO6/appupdate: Detect filesystem size at runtime.
This changes appupdate.py to get the filesystem size at runtime.  This will
allow the code to be shared with LEGO_HUB_NO7 which has a similar flash
chip with a different size.

Signed-off-by: David Lechner <david@pybricks.com>
2022-08-06 00:01:10 +10:00
David Lechner
7cc6df3303 stm32/boards/LEGO_HUB_NO6: Use named pins.
This changes all uses of pins to use the alias names of the pins.  This
makes the code easier to understand and will also allow sharing more code
with LEGO_HUB_NO7.

Signed-off-by: David Lechner <david@pybricks.com>
2022-08-05 23:57:35 +10:00
David Lechner
6152bbe3dd stm32/boards/LEGO_HUB_NO6: Fix typo in README.
This fixes a typo in the build directory path.

Signed-off-by: David Lechner <david@pybricks.com>
2022-08-05 23:57:15 +10:00
Jim Mussared
579f330508 py/mkenv.mk: Use micropython-lib from submodule by default.
Also adds micropython-lib to 'make submodules' when using a frozen manifest
(for make and cmake).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-03 00:08:41 +10:00
Jim Mussared
19f5da9e1b esp32/Makefile: Force micropython-lib as a required submodule.
Also use mkrules.mk's submodule target rather than duplicating the call to
`submodule sync`.

Until we can find a way to use idf.py/cmake to discover submodules we have
no way to discover optional or board-specific submodules so need to err on
the side of including everything.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-03 00:07:35 +10:00
Jim Mussared
9a7ac41be6 rp2/Makefile: Always use cmake to discover submodules.
Used to be special-cased for Pico, but now everything depends on
micropython-lib if it's using a frozen manifest.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-03 00:05:54 +10:00
Jim Mussared
be83c08f46 ports: Always append to GIT_SUBMODULES.
Avoids overwriting submodules required by base makefiles.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-03 00:05:26 +10:00
Angus Gratton
fdfe4eca74 ports: Always include debug information in the ELF.
For bare metal ARM & xtensa targets, passing -g will make the ELF file
larger but doesn't change the binary size.  However, this means tools like
gdb, addr2line, etc can extract source-level information from the ELF.

Also standardise -ggdb to -g, these produce the exact same ELF file on
arm-none-eabi-gcc and will use DWARF format for all these ports.
2022-07-29 11:24:00 +10:00
David Lechner
3c32ca6e77 unix/unix_mphal: Allow overriding hal time functions.
This adds #ifdefs around each of the mp_hal_* time functions for the unix
port.  This allows variants to override individual functions as needed.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-29 11:06:12 +10:00
Peter Harper
45ab801c30 rp2/cyw43_configport: Add event hook into cyw43_delay_ms.
Still see some USB issues apparently caused by delays loading wifi
firmware.  cyw43_delay_ms is used to wait in the driver, so we should call
the event hook in there.

Fixes #8963.
2022-07-27 13:42:21 +10:00
Jim Mussared
092784da19 ports: Remove unused mp_type_{fileio/textio} macros in mpconfigport.h.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-26 18:07:22 +10:00
robert-hh
0c45a28d24 rp2/rp2_pio: Fix StateMachine.restart when PIO program is shared.
The state machines were not properly restarted in the case that the same
PIO program was shared among multiple StateMachine instances.  This is
because only the first StateMachine to use the program would set the
rp2_state_machine_initial_pc variable.

See https://forum.micropython.org/viewtopic.php?f=21&t=12776&p=69464#p69464
2022-07-26 02:00:01 +10:00
Damien George
f64862a766 rp2/cyw43_configport: Set CYW43_WIFI_NVRAM_INCLUDE_FILE value.
Required for latest cyw43-driver.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-26 01:39:30 +10:00
Peter Harper
33d6994d4c rp2/cyw43_configport: Set CYW43_EVENT_POLL_HOOK value.
This should allow USB to work while we're loading WiFi firmware.

Fixes issue #8904.
2022-07-26 01:39:08 +10:00
Tim Gates
f736afb577 drivers,ports: Fix a few typos in comments.
Fixes:
- Should read `definitions` rather than `defintions`.
- Should read `resolution` rather than `resoultion`.
- Should read `inefficient` rather than `inefficent`.
- Should read `closed` rather than `closded`.

Signed-off-by: Tim Gates <tim.gates@iress.com>
2022-07-23 23:24:24 +10:00
Rob Knegjens
d2e4cf00cc unix: Enable MICROPY_GC_SPLIT_HEAP on coverage build.
With a new option to evenly split the GC heap over multiple areas.  This
adds code coverage for gc_add() and code associated with
MICROPY_GC_SPLIT_HEAP.
2022-07-23 00:43:08 +10:00
Damien George
5dbb822ca4 esp32/mpconfigport: Enable BLE synchronous events and pairing/bonding.
Signed-off-by: Damien George <damien@micropython.org>
2022-07-22 17:41:21 +10:00
Jim Mussared
4cf9928902 cc3200: Fix various array-based compiler warnings.
1. Add -Wno-array-bounds to avoid false positive on gcc 12.1; see related
   issue #8685.
2. Remove always-true not-NULL-check (Msg.Rsp.Args.Common.Bssid is an array
   not a pointer).
3. Fix pointer-to-freed-stack in wlan_set_security.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-21 16:26:04 +10:00
Jim Mussared
a053827084 extmod/network_ninaw10: Move ninaw10 root pointer registrations here.
Originally in drivers/ninaw10/nina_wifi_bsp.c but that isn't a QSTR source.

Also remove outdated commment about root pointers in mpconfigport.h.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-21 16:21:50 +10:00
Jim Mussared
8b4298a4bf rp2/mpbthciport: Remove mp_bthci_uart from set of root pointers.
This is a statically-allocated UART (see machine_uart.c), and doesn't
contain any heap pointers other than the ringbufs (which are already root
pointers), so no need to track it additionally.

Saves needing to add mpbthciport.c to the QSTR sources.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-21 16:19:42 +10:00
robert-hh
2e2fc8f60f nrf/main: Call usb_cdc_init() before executing boot.py and main.py.
Otherwise, there is no USB available when running main.py, and main.py
cannot be interrupted with Ctrl-C.
2022-07-20 17:17:17 +10:00
iabdalkader
768cbea507 nrf/boards/arduino_nano_33_ble_sense: Update deploy instructions. 2022-07-20 17:16:15 +10:00
robert-hh
678cb5a585 renesas-ra/softtimer: Switch to use softtimer code from shared/runtime. 2022-07-19 13:46:28 +10:00
robert-hh
c781899438 stm32/softtimer: Switch to use softtimer code from shared/runtime. 2022-07-19 12:33:19 +10:00
robert-hh
80339f1a33 ports: Adapt mimxrt, nrf and rp2 ports to work with latest TinyUSB.
rp2: change tud_task() to tud_task_ext().

mimxrt: use lib/tinyusb/src/portable/chipidea/ci_hs/dcd_ci_hs.c instead of
lib/tinyusb/src/portable/nxp/transdimension/dcd_transdimension.c.

nrf: add a definition for the changed tud_task().  tud_task() is changed
to tud_task_ext(), and the #define for backward compatibility is in
src/device/usbd.h.

The items I know which are fixed with this version:
- Fix for the SAMD USB lock-up.
- Support the MIMXRT11XX series of MCUs.
- Fix a wrong pin definition for MIMXRT1050_EVKB.

Tested with the MIMXRT boards, rp2 Pico, SAMD boards, nrf board.
2022-07-19 11:27:21 +10:00
David Lechner
03fb671833 unix/mpconfigport: Allow overriding MICROPY_EVENT_POLL_HOOK.
This allows variants to supply their own `MICROPY_EVENT_POLL_HOOK`.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-19 11:24:42 +10:00
David Lechner
c947c25294 unix/Makefile: Only checkout libffi submodule when used.
This moves the libffi submodule variable modifier inside of the if
statement where it is actually used so that the submodule will only be
checked out if it is actually being used.

A new DEPLIBS variable is also introduced to prevent building the libffi
submodule when not needed.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-19 11:17:16 +10:00
stijn
d05377c060 windows/msvc: Support compressed ROM text for error messages.
Enable it in the dev variant as well for consistency with the
makefile-based dev variant.
2022-07-18 23:25:38 +10:00
stijn
c4adeb2e08 windows: Provide a definition for MP_ALWAYSINLINE. 2022-07-18 23:24:46 +10:00
Damien George
b89422ceaa extmod: Always use custom mbedtls error message code.
All ports that use mbedtls use the custom error messages in
mp_mbedtls_errors.c.  This commit simplifies the build so that ports don't
need to explicitly add this file, it's now used by default when mbedtls is
enabled.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 22:55:22 +10:00
Damien George
b87f796ef5 unix/Makefile: Only include axtls in GIT_SUBMODULES list when enabled.
Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 22:45:38 +10:00
Damien George
13c78ab6fe unix/mpconfigport: Switch ussl from axtls to mbedtls.
The reasons to make this switch are:
- The axtls library is not being maintained/updated, mbedtls is.
- So CI and tests can run against mbedtls, which is now the main TLS
  library used by the ports (eg stm32, rp2, mimxrt, esp32). Only esp8266
  uses axtls.

Increases unix standard build on x86-64 by about 89000 bytes.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 22:43:01 +10:00
Damien George
26dec1fafb unix/mbedtls: Add custom config for mbedtls.
Based on existing bare-metal config from stm32.  Also uses shorter error
messages from lib/mbedtls_errors.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 22:42:51 +10:00
Damien George
e30e7ced6f unix/mpconfigport: Make MICROPY_EVENT_POLL_HOOK call usleep directly.
So that MICROPY_EVENT_POLL_HOOK can be used without including py/mphal.h.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 18:12:39 +10:00
Angus Gratton
1d23c01dd6 stm32/Makefile: Workaround LTO linker order bug in binutils <2.35.
Assembly files with weak symbols need to be linked first to avoid issues
with the weak symbols being incorrectly linked instead of strong ones.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83967 and
https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966

This is the workaround suggested in comment 10 of the gcc-arm-embedded bug.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2022-07-18 16:12:08 +10:00
David Lechner
68f46342aa shared/runtime/pyexec: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register repl_line
instead of using a conditional inside of mp_state_vm_t.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:52:01 +10:00
David Lechner
7e4b205cb0 py/mpstate: Drop MICROPY_PORT_ROOT_POINTERS from mp_state_vm_t.
All in-tree uses of MICROPY_PORT_ROOT_POINTERS have been replaced with
MP_REGISTER_ROOT_POINTER(), so now we can remove both
MICROPY_PORT_ROOT_POINTERS and MICROPY_BOARD_ROOT_POINTERS from the code
and remaining config files.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:51:16 +10:00
David Lechner
ccda7686a4 zephyr: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register port-specific root
pointers for the zephyr port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:35 +10:00
David Lechner
186be074a7 teensy/teensy_hal: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register pyb_stdio_uart and removes
the same from mpconfigport.h.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:35 +10:00
David Lechner
2d8589f1a5 teensy/mpconfigport: Drop unused root pointers.
pin_class_mapper and pin_class_map_dict are not used in the teensy port and
can be removed.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
816e4537f2 stm32: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers in the stm32 port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
ffa22b8f97 rp2: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers in the rp2 port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
575fa61c6d renesas-ra: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers in the renesas-ra port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
f8805e2416 renesas-ra/mpconfigport: Drop pyb_hid_report_desc root pointer.
pyb_hid_report_desc is not used anywhere in the renesas-ra port (probably
was copied from stm32 port).

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
c09e31dabb pic16bit/pic16bit_mphal: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register keyboard_interrupt_obj
and removes the same from mpconfigport.h.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
8a69c54211 nrf: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers for the nrf port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
a316a8fdb3 mimxrt: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers in the mimxrt port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
e2d4db96da esp8266: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers in the esp2866 port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
b63282c361 esp32: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all root pointers in the
esp32 port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
226e969ad3 cc3200: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root
pointers for the cc3200 port.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
095ad87adf cc3200/mpconfigport: Remove mp_const_user_interrupt.
mp_const_user_interrupt was listed as a root pointer but not used anywhere
in the code base, so it can be removed.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:34 +10:00
David Lechner
a3703584fe extmod/modnetwork: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register mod_network_nic_list and
removes the same from all mpconfigport.h.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:25 +10:00
David Lechner
e531b72b56 extmod/nimble: Use MP_REGISTER_ROOT_POINTER().
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>
2022-07-18 13:50:14 +10:00
David Lechner
8fa6191f95 extmod/btstack: Use MP_REGISTER_ROOT_POINTER().
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>
2022-07-18 13:49:51 +10:00
David Lechner
ac86e8449a drivers/ninaw10/nina_wifi_bsp: Use MP_REGISTER_ROOT_POINTER().
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>
2022-07-18 13:49:28 +10:00
David Lechner
e5631d9595 unix/alloc: Use MP_REGISTER_ROOT_POINTER() for mmap_region_head.
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>
2022-07-18 13:49:09 +10:00
David Lechner
81dbea1ce3 shared/readline: Use MP_REGISTER_ROOT_POINTER().
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>
2022-07-18 13:48:49 +10:00
David Lechner
fc3d7ae11b py/make_root_pointers: Add MP_REGISTER_ROOT_POINTER parser/generator.
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>
2022-07-18 13:48:23 +10:00
robert-hh
cca2305211 nrf/drivers/usb: Fix reading of a single USB CDC character. 2022-07-17 00:13:15 +10:00
robert-hh
be6f0f3b3b nrf/mpconfigport: Call tud_task() in MICROPY_EVENT_POLL_HOOK.
So that the interrupt character can interrupt a long-running loop, like a
sleep.
2022-07-17 00:12:34 +10:00
robert-hh
c985a0b514 nrf/drivers/usb: Add a tud_cdc_rx_cb() callback to check interrupt char. 2022-07-17 00:12:03 +10:00
robert-hh
60539ea162 nrf/drivers/usb: Probe for interrupt char in USB CDC task.
And ensure that the input queue is empty when scheduling the interrupt.
2022-07-17 00:11:14 +10:00
Stuart Langridge
30c7f1790b nrf/drivers/bluetooth: Handle PHY_UPDATE messages, used in Bluetooth 5.
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.
2022-07-16 23:46:30 +10:00
iabdalkader
262f4a4855 nrf/mpconfigport: Remove obsolete module declarations.
External module declarations are no longer used/needed after the
introduction of MP_REGISTER_MODULE.
2022-07-15 22:54:25 +10:00
Jim Mussared
74794d42b8 rp2/CMakeLists: Use armv6m mpy-cross arch for rp2.
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>
2022-07-12 23:50:19 +10:00
David Lechner
093c4b6b26 unix/main: Restore tty settings on nlr_jump_fail().
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>
2022-07-12 17:20:37 +10:00
Peter Harper
9f0f7e34c7 rp2/mphalport: Fix missing storage_read_blocks symbol in debug build.
When building `make BOARD=PICO_W DEBUG=1` the cyw43-driver requires
storage_read_blocks().

Signed-off-by: Peter Harper <peter.harper@raspberrypi.com>
2022-07-12 16:56:38 +10:00
Jim Mussared
c5563aa024 rp2/mpconfigport: Make networking options consistent across boards.
Enable the same set of networking features on boards with wifi/ethernet.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-12 16:28:44 +10:00
Jim Mussared
662dc8602b rp2: Make atomic sections suspend the other core (if active).
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>
2022-07-12 16:20:21 +10:00
Jim Mussared
daff597753 rp2: Run USB stack task exclusively from core 0.
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>
2022-07-12 16:17:19 +10:00
Damien George
1329155b96 stm32/sdram: Include boardctrl.h for fatal-error handler.
Signed-off-by: Damien George <damien@micropython.org>
2022-07-11 14:47:46 +10:00
Damien George
9af6a275dd stm32/boardctrl: Allow boards to override fatal-error handler.
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>
2022-07-08 23:47:29 +10:00
Damien George
9f8087b448 esp8266/boards: Enable reverse-special-methods on GENERIC board.
It increases the firmware size by 292 bytes.

Addresses issue #5897.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-08 23:06:16 +10:00
Damien George
d7a162516e esp32/modmachine: Fix machine.freq to allow maximum 160MHz on ESP32-C3.
Fixes issue #8824.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-08 22:46:51 +10:00
iabdalkader
6753c53318 nrf/modmachine: Add machine.idle() function.
This improves the compatibility of the nrf port machine module with common
drivers, by adding a machine.idle() alias for lightsleep.
2022-07-08 12:37:59 +10:00
iabdalkader
5c31a6c023 nrf/boards/arduino_nano_33_ble: Add Arduino Nano 33 BLE sense board. 2022-07-07 23:58:03 +10:00
David Lechner
07cae9178f nrf/Makefile: Drop unused MPY_CROSS and MPY_TOOL variables.
These variables are no longer used in the nrf Makefile and can be removed.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-05 23:51:26 +10:00
Damien George
d27e58449b stm32/mboot: Remove redundant code in mboot_state_change function.
This code was made redundant in 87fbceef26

Signed-off-by: Damien George <damien@micropython.org>
2022-07-05 23:47:54 +10:00
David Lechner
5ab7dfe6db unix/moduos: Include errno.h.
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>
2022-07-05 23:44:07 +10:00
IhorNehrutsa
1ea82b6dcc esp32,esp8266: Rename WLAN dhcp_hostname config to hostname.
But retain old name for backwards compatibility.
2022-07-05 23:40:32 +10:00
Jim Mussared
2efaebc899 rp2/boards/ARDUINO_NANO_RP2040_CONNECT: Add urequests module.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-05 23:03:02 +10:00
Jim Mussared
11ef618bbc rp2/CMakeLists: Don't override cyw43-driver unless necessary.
This supresses a warning from pico-sdk when the board isn't using this
driver.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-05 23:00:43 +10:00
Jim Mussared
5f4143dd40 rp2/CMakeLists: Give error if required submodules are missing.
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>
2022-07-05 23:00:36 +10:00
Jim Mussared
651b370484 rp2/Makefile: Regenerate cmake if generated Makefile missing.
`CMakeCache.txt` can exist even if cmake failed. Use `Makefile` instead.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-05 22:47:06 +10:00
Damien George
85be3d3da8 rp2/mpconfigport: Factor core event handling to EVENT_POLL_HOOK_FAST.
Signed-off-by: Damien George <damien@micropython.org>
2022-07-05 16:11:42 +10:00
Damien George
4b9a2abbde rp2/main: Set default AP auth mode to WPA2_AES_PSK.
Signed-off-by: Damien George <damien@micropython.org>
2022-07-05 11:07:16 +10:00
Damien George
3d76292f37 rp2/boards/GARATRONIC_PYBSTICK26_RP2040: Change pico-sdk board name.
This follows a similar renaming in pico-sdk.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-05 09:45:44 +10:00
Jim Mussared
6519b1b95e stm32/Makefile: Fix setting of define that enables WIZNET5K driver.
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>
2022-07-02 00:21:36 +10:00
Damien George
99c2589778 rp2/boards/PICO_W: Add new Pico W board, an RP2040 with WiFi.
Work done in collaboration with Graham Sanderson and Peter Harper.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-30 17:03:51 +10:00
Damien George
50e46552c0 rp2: Integrate CYW43xx WiFi driver.
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>
2022-06-30 17:03:51 +10:00
Damien George
c001cfa603 rp2/mpnetworkport: Convert network task scheduling to use PendSV IRQ.
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>
2022-06-30 17:03:47 +10:00
Damien George
7cdad05e54 rp2/rp2_flash: Add asserts for size of flash filesystem partition.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-30 16:03:21 +10:00
Damien George
c95f99105a rp2/lwip_inc: Enable lwIP status callback.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-30 16:03:21 +10:00
Damien George
11f920f8ad rp2/mbedtls: Enable some more mbedtls options.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-30 16:03:21 +10:00
Jim Mussared
797a83ac3e rp2/mpthreadport: Ensure core1 doesn't hold gc lock in deinit.
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>
2022-06-30 11:53:25 +10:00
Damien George
b004e7e397 rp2/modmachine: Implement lightsleep() with optional sleep period.
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>
2022-06-30 11:40:17 +10:00
Damien George
afa4d0a4b7 unix/variants/dev: Allow all config options to be overridden.
They can be overridden on the make command line, for example.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-29 12:48:33 +10:00
Damien George
510bea9383 unix/variants/coverage: Change config to use ROM level everything.
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>
2022-06-29 12:48:33 +10:00
Damien George
fad978ae5f unix/variants: Enable remaining options on dev,coverage from ROM extra.
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>
2022-06-29 12:23:11 +10:00
Damien George
fe55d3e016 unix/variants: Move setting of MICROPY_PY_USELECT to port config file.
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>
2022-06-29 12:22:56 +10:00
Damien George
ccaf197807 esp32/network_wlan: Don't raise exception when scan returns no results.
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>
2022-06-28 13:18:07 +10:00
Angus Gratton
dd77dbd4f7 stm32/boards: Enable LTO by default on boards with smaller flash size.
Signed-off-by: Angus Gratton <gus@projectgus.com>
2022-06-28 10:32:39 +10:00
Angus Gratton
e76d88b531 stm32/Makefile: Enable link-time-optimisation via LTO=1 make option.
When tested, this reduces default MP binary sizes by approx 2-2.5%, and
very marginally increases performance in benchmarks. Build times seem very
similar to non-LTO when using gcc 12.

See #8733 for further discussion.

Signed-off-by: Angus Gratton <gus@projectgus.com>
2022-06-28 10:31:32 +10:00
Angus Gratton
2c015375d1 stm32: Use a separate symbol name for the bootloader state pointer.
Prerequisite for enabling Link Time Optimisation.

The _bl_state address is the same as _estack, but _estack is referred to as
a uint32_t elsewhere in the code. LTO doesn't like it when the same symbol
has two different types.

Signed-off-by: Angus Gratton <gus@projectgus.com>
2022-06-28 10:25:08 +10:00
Koen De Vleeschauwer
432b65f178 stm32/usb: Expose USB HID device instance via usbd_hid_get().
This is needed to implement a HID device in user C modules.
2022-06-24 18:33:26 +10:00
Philipp Ebensberger
4ce1adab31 mimxrt/boards: Remove conditional assignment of flash type/size.
Removes conditional assignment because respective variables should only be
set in board makefile fragments.  Hence no conditional assignment needed.
2022-06-24 17:58:27 +10:00
Philipp Ebensberger
434974ec77 mimxrt/Makefile: Fix some minor formatting inconsistencies. 2022-06-24 17:58:27 +10:00
Philipp Ebensberger
c957c76f4d mimxrt/Makefile: Rework floating point config.
Reworks source file and compile flags selection for floating point support.
2022-06-24 17:58:27 +10:00
Philipp Ebensberger
bec0524dbf mimxrt/Makefile: Rework board flash type handling.
Reworks handling and configuration of different board flash types in the
Makefile, linker scripts and board makefile fragments.
2022-06-24 17:58:27 +10:00
Philipp Ebensberger
84339aa8ec mimxrt/Makefile: Modify handling of SDCARD option.
Removes separate `if` case in Makefile for setting SDCARD option define.
2022-06-24 17:58:27 +10:00
Philipp Ebensberger
b1aec393b1 mimxrt/Makefile: Modify handling of SDRAM option.
Replaces preprocessor macro for SDRAM option from #ifdef to #if in order to
allow always setting the define `MICROPY_HW_SDRAM_AVAIL` just with the
appropriate value 0/1.  This eliminates one `if` in the Makefile.
2022-06-24 17:58:27 +10:00
Philipp Ebensberger
fbc50196ad mimxrt/Makefile: Refactor Makefile and divide it into sections.
Reworks grouping of Makefile variables and reorders variable values in
alphabetic order.
2022-06-24 17:58:25 +10:00
Christian Walther
ba21f76f89 esp32/modesp32: Add wake_on_ulp() so ULP can wake CPU from deepsleep.
Add esp32.wake_on_ulp() to give access to esp_sleep_enable_ulp_wakeup(),
which is needed to allow the ULP co-processor to wake the main CPU from
deep sleep.
2022-06-23 17:31:01 +10:00
Christian Walther
cf550ad9d1 esp32/boards: Increase 512 bytes limit on ULP programs to 2040.
Allow esp32.ULP.load_binary() to use the maximum amount of memory available
again, which is 2040 bytes unless MICROPY_HW_RTC_USER_MEM_MAX is
customized.

This value regressed in 3d49b157b8
2022-06-23 17:24:59 +10:00
robert-hh
5f4539b0ca esp32/machine_uart: Implement the functionality of timeout_char arg.
Using it for the rx-timeout.  The value is given as ms, which is then
converted to character times.  A value of less than a character time will
cause the rx call to return immediately after 1 character, which may be
inefficient at high transmission rates.

Addresses #8778.
2022-06-23 17:13:41 +10:00