Wykres commitów

2922 Commity (888e831bf78518c367d40a6b77b29c6aab13a7f0)

Autor SHA1 Wiadomość Data
iabdalkader 0adf0dd3d7 stm32/modmachine: Allow boards to provide custom bootloader code.
And expose the machine_bootloader() C function so it can be used elsewhere.
2022-06-17 13:36:55 +10:00
iabdalkader 921dd94676 nrf/main: Add startup and early-init board hook macros.
Following stm32 for naming and location of the hooks.  Also allow a board
to provide custom .c files to implement code for these hooks.
2022-06-17 13:23:45 +10:00
Damien George 5233fb3a3d extmod/machine_i2c: Only use WRITE1 option if transfer supports it.
When MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 is enabled the port's hardware
I2C transfer functions should support the MP_MACHINE_I2C_FLAG_WRITE1
option, but software I2C will not.  So add a flag to the I2C protocol
struct so each individual protocol can indicate whether it supports this
option or not.

Fixes issue #8765.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-17 11:57:57 +10:00
Damien George 096954337f stm32/mboot: Only include UI code if at least one board LED is defined.
Otherwise the board must provide dummy definitions of MBOOT_LED1.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-16 14:31:09 +10:00
Damien George d75892c0b0 zephyr/modusocket: Fix function object wrapper for listen method.
This was missed by 919f696ad2

Signed-off-by: Damien George <damien@micropython.org>
2022-06-15 11:38:09 +10:00
Andrew Scheller cedb93c179 docs: Update Raspberry Pi URLs from .org to .com. 2022-06-14 11:41:13 +10:00
iabdalkader 99d3a73d59 nrf/modules/uos/microbitfs: Fix MICROPY_MBFS build to use mp_obj_malloc.
Changes introduced in 0e7bfc88c6 missed
changing this call to mp_obj_malloc.
2022-06-11 21:09:58 +10:00
Damien George f63b4f85aa py/parse: Work around xtensa esp-2020r3 compiler bug.
This commit works around a bug in xtensa-esp32-elf-gcc version esp-2020r3.

The bug is in generation of loop constructs.  The below code is generated
by the xtensa-esp32 compiler.  The first extract is the buggy machine code
and the second extract is the corrected machine code.  The test
`basics/logic_constfolding.py` fails with the first code and succeeds with
the second.

Disassembly of section .text.push_result_rule:

00000000 <push_result_rule>:
  ...
  d6:   209770       or      a9, a7, a7
  d9:   178976       loop    a9, f4 <push_result_rule+0xf4>
                     d9: R_XTENSA_SLOT0_OP   .text.push_result_rule+0xf4
  dc:   030190       rsr.lend        a9
  df:   130090       wsr.lbeg        a9
  e2:   a8c992       addi    a9, a9, -88
  e5:   06d992       addmi   a9, a9, 0x600
  e8:   130190       wsr.lend        a9
  eb:   002000       isync
  ee:   030290       rsr.lcount      a9
  f1:   01c992       addi    a9, a9, 1
  f4:   1494e7       bne     a4, a14, 10c <push_result_rule+0x10c>
                     f4: R_XTENSA_SLOT0_OP   .text.push_result_rule+0x10c

Disassembly of section .text.push_result_rule:

00000000 <push_result_rule>:
  ...
  d6:   209770       or      a9, a7, a7
  d9:   178976       loop    a9, f4 <push_result_rule+0xf4>
                     d9: R_XTENSA_SLOT0_OP   .text.push_result_rule+0xf4
  dc:   030190       rsr.lend        a9
  df:   130090       wsr.lbeg        a9
  e2:   000091       l32r    a9, fffc00e4 <push_result_rule+0xfffc00e4>
                     e2: R_XTENSA_SLOT0_OP   .literal.push_result_rule+0x18
  e5:   0020f0       nop
  e8:   130190       wsr.lend        a9
  eb:   002000       isync
  ee:   030290       rsr.lcount      a9
  f1:   01c992       addi    a9, a9, 1
  f4:   1494e7       bne     a4, a14, 10c <push_result_rule+0x10c>
                     f4: R_XTENSA_SLOT0_OP   .text.push_result_rule+0x10c

Work done in collaboration with @jimmo.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-09 13:56:30 +10:00
Damien George 3452ee58d3 stm32/boards/LEGO_HUB_NO6: Add comment to readme about powering off.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-09 13:24:08 +10:00
Damien George 45a0c6da5b stm32/mboot: Remove MP_WEAK on led funcs and make some of them static.
Both led_init and led_state are configurable via MBOOT_BOARD_LED_INIT and
MBOOT_BOARD_LED_STATE respectively, so don't need to be MP_WEAK.

Furthermore, led_state and led0_state are private to ui.c so can be made
static.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-09 13:24:08 +10:00
Damien George bd5152c928 stm32/mboot: Add board-configurable SysTick hook.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-09 13:24:08 +10:00
Damien George 85597aa68e esp32/machine_pin: Only expose IO20 on esp32 for IDF 4.3.2 and above.
This IO was enabled in IDF commit 68f8b999bb69563f2f3d1d897bc073968f41f3bf,
which is available in IDF release v4.3.2 and above.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-08 18:29:01 +10:00
Damien George bd375df02c extmod/extmod.cmake: Require components to be explicitly enabled.
Otherwise include directories are added unconditionally to the build
variables if the component (submodule) is checked out.  This can lead to,
eg, the esp32 build using lib/lwip header files, instead of lwip header
files from the IDF.

Fixes issue #8727.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-08 13:03:34 +10:00
Damien George ac3fb974bc unix/variants: Enable seeding random module on import in dev, coverage.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 23:41:49 +10:00
Damien George d2f018bff1 unix,windows: Factor out code that generates random bytes to a new func.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 23:41:30 +10:00
stijn 5bb2a85d74 windows: Use BCryptGenRandom to implement os.urandom.
Fix urandom not working on windows (there's no /dev/urandom) by using
a proper cryptographic random function (same one as CPython >= 3.11).
2022-06-07 23:32:30 +10:00
robert-hh 5cc2dd4f5d mimxrt/machine_uart: Fix an inconsistency for UART.init() arg handling.
With keyword arguments only or just a single non-keyword argument,
UART.init() did not perform the settings.
2022-06-07 18:21:46 +10:00
Clayton Mills 767f2ce9a7 stm32/usbd_conf: Remove disable of SYSCFG clock.
System config block contains hardware unrelated to USB.  So calling
`__SYSCFG_CLK_DISABLE()` during `HAL_PCD_MspDeInit()` has an adverse effect
on other system functionality.

Removing call to `__SYSCFG_CLK_DISABLE()` to rectify this issue.

This call was there since the beginning of the USB CDC code, added in
b30c02afa0.
2022-06-07 18:09:58 +10:00
Clayton Mills 0d8d911950 stm32/powerctrl: Disable sys tick interrupt in stop mode on some STM32s.
According to ST Errata ES0206 Rev 18, Section 2.2.1, on STM32F427x,
STM32F437x, STM32F429x and STM32F439x.

If the system tick interrupt is enabled during stop mode while certain
bits are set in the DBGMCU_CR, then the system will immediately wake
from stop mode.

Suggested workaround is to disable system tick timer interrupt when
entering stop mode.

According to ST Errate ES0394 Rev 11, Section 2.2.17, on STM32WB55Cx and
STM32WB35Cx.

If the system tick interrupt is enabled during stop 0, stop 1 or stop 2
while certain bits are set in DBGMCU_CR, then system will immediately
wake from stop mode but the system remains in low power state. The CPU
therefore fetches incorrect data from inactive Flash, which can cause a
hard fault.

Suggested workaround is to disable system tick timer interrupt when
entering stop mode.
2022-06-07 18:08:02 +10:00
Damien George 14105ff5b1 stm32/machine_i2c: Enable timingr constructor keyword on H7 MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 17:05:05 +10:00
Damien George a0dae1dda2 stm32/flash: Remove FLASH_OPTR_DBANK condition in L4, H7 get_bank func.
This was added by mistake in 8f68e26f79 when
adding support for G4 MCUs, which does not using this get_bank() function.

FLASH_OPTR_DBANK is only defined on G4 and L4 MCUs, so on H7 this
FLASH_BANK_2 code was being wrongly excluded.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 16:55:18 +10:00
Damien George 9670a156da all: Rename MICROPY_PY_WIZNET5K to MICROPY_PY_NETWORK_WIZNET5K.
To match MICROPY_PY_NETWORK_CYW43 and MICROPY_PY_NETWORK_NINAW10.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 16:55:18 +10:00
Damien George 66dfe17b18 rp2/CMakeLists: Simplify qstr sources when enabling extmod components.
Also remove redundant modusocket.c and modnetwork.c sources, they are
already added by extmod/extmod.cmake.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 16:55:18 +10:00
Damien George a446a7bdef rp2/mpnetworkport: Fix lwip alarm callback timing to use microseconds.
The callback passed to add_alarm_in_ms must return microseconds, even
though the initial delay is in milliseconds.  Fix this use, and to avoid
further confusion use the add_alarm_in_us function instead.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 16:55:18 +10:00
Damien George c58dc7f091 pic16bit: Use 1 byte for qstr hash len and include header to fix build.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 16:55:18 +10:00
iabdalkader 2111ca0b8f rp2/boards/ARDUINO_NANO_RP2040_CONNECT: Update USB PID.
This PID is allocated for the Arduino Nano RP2040 running MicroPython.
2022-06-03 16:12:44 +10:00
Andrew Leech ffe5f2efe2 rp2/Makefile: Build in debug mode with "make DEBUG=1".
Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03 14:34:29 +10:00
Andrew Leech 1b80aa9ce3 rp2/boards/W5100S_EVB_PICO: Add Wiznet W5100S-EVB-Pico board.
Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03 14:34:29 +10:00
Andrew Leech bca816f5ac rp2: Add support for using Wiznet hardware as an Ethernet NIC.
Uses the extmod/network_wiznet5k driver to provide network connectivity.

Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03 14:34:29 +10:00
Andrew Leech 15fea3a1ff rp2: Integrate lwIP network stack.
Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03 14:34:18 +10:00
Andrew Leech 7d9cc69645 rp2/Makefile: Use cmake for "make submodules" task when needed.
Because the submodule list can be updated by cmake files.

Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03 14:29:11 +10:00
Andrew Leech 05f927b624 rp2/machine_pin: Add mp_hal_pin_interrupt C interface.
So C can can easily configure a pin interrupt and callback.

Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03 14:29:11 +10:00
Andrew Leech 9bd6169b72 rp2/mbedtls: Add support for ssl module with MICROPY_SSL_MBEDTLS.
Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03 14:29:06 +10:00
Andrew Leech 494e8ba722 nrf/mpconfigport: Fix MICROPY_VFS IO build support. 2022-06-03 12:39:43 +10:00
Andrew Leech c5878dd1f9 nrf/mpconfigport: Enable extra features as defined by ROM levels.
This commit enables extra features from the ROM levels and further
simplifies mpconfigport.h.  The changes are:

- NRF51822 & BLUETOOTH_SD -> MICROPY_CONFIG_ROM_LEVEL_MINIMUM
    - no changes

- NRF51822 -> MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES
    - MICROPY_PY_IO = 1

- NRF52832 -> MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES
    - MICROPY_PY_IO = 1

- NRF52840, NRF9160 -> MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES
    - MICROPY_COMP_MODULE_CONST = 1
    - MICROPY_COMP_TRIPLE_TUPLE_ASSIGN = 1
    - MICROPY_OPT_MPZ_BITWISE = 1
    - MICROPY_PY_ALL_SPECIAL_METHODS = 1
    - MICROPY_PY_BUILTINS_EXECFILE = 1
    - MICROPY_PY_BUILTINS_SLICE_ATTRS = 1
    - MICROPY_PY_BUILTINS_STR_CENTER = 1
    - MICROPY_PY_BUILTINS_STR_PARTITION = 1
    - MICROPY_PY_BUILTINS_STR_SPLITLINES = 1
    - MICROPY_PY_CMATH = 1
    - MICROPY_PY_COLLECTIONS_ORDEREDDICT = 1
    - MICROPY_PY_FRAMEBUF = 1
    - MICROPY_PY_IO = 1
    - MICROPY_PY_MATH_SPECIAL_FUNCTIONS = 1
    - MICROPY_PY_SYS_STDIO_BUFFER = 1
    - MICROPY_PY_UCTYPES = 1
    - MICROPY_PY_UHEAPQ = 1
    - MICROPY_PY_UJSON = 1
    - MICROPY_PY_URE = 1
    - MICROPY_PY_UZLIB = 1
    - MICROPY_REPL_EMACS_KEYS = 1
2022-06-03 12:37:12 +10:00
Andrew Leech 13f5d38f2e nrf/mpconfigport: Set MICROPY_CONFIG_ROM_LEVEL defines for each MCU.
This commit is a no-op change to simplify existing config.
2022-06-03 12:36:40 +10:00
Andrew Leech 8fb01be6cf stm32/rfcore: Remove extra layer of buffering on BLE IPCC.
Whole packets are now pushed up to the higher layer of the BLE stack,
instead of buffering the packets so individual bytes can be requested.
2022-06-03 11:58:43 +10:00
Takeo Takahashi dd83f48fb2 renesas-ra/machine_pin: Remove code for unsupported Pin features.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-06-03 10:57:48 +10:00
robert-hh a0432ed9cb mimxrt: Update port to work with new nxp_driver v2.10.
The nxp_driver v2.10 allows for/requires some changes to the code:

- Remove some part of pwm_backlog.*, which is provided by the lib now.
- Change eth.c: the newer versions have additional parameters of the
  library versions.
- Change sdcard.c: use TransferBlocking instead of TransferNonblocking.
- Add some support for the MIMXRT1176 device.
- Set the clocks for UART, I2C, Timer.
- Integrate the I2S module and fix a rebase error.
- Use blocking transfer only for SPI.  It's faster and interferes less with
  other modules.
- Use the clock_config.c files of library v2.8.5.  The mimxrt files keeps
  the clock_config.c files from Verson 2.8.5.  With clock_config.c from
  v2.10, the boards do not work.  Refactoring of the clock set-up is on the
  to-do list.
- Enable expiry timers for UART, I2C and SPI, avoiding a stall in library
  code.
- The clock_config.* files are moved from the board-specific directories to
  the boards directory and given a MCU related name.
2022-06-03 10:48:49 +10:00
Damien George efe23aca71 all: Remove third argument to MP_REGISTER_MODULE.
It's no longer needed because this macro is now processed after
preprocessing the source code via cpp (in the qstr extraction stage), which
means unused MP_REGISTER_MODULE's are filtered out by the preprocessor.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 16:31:37 +10:00
Damien George 47f634300c py: Change makemoduledefs process so it uses output of qstr extraction.
This cleans up the parsing of MP_REGISTER_MODULE() and generation of
genhdr/moduledefs.h so that it uses the same process as compressed error
string messages, using the output of qstr extraction.

This makes sure all MP_REGISTER_MODULE()'s that are part of the build are
correctly picked up.  Previously the extraction would miss some (eg if you
had a mod.c file in the board directory for an stm32 board).

Build speed is more or less unchanged.

Thanks to @stinos for the ports/windows/msvc/genhdr.targets changes.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 16:29:53 +10:00
Damien George 340872cfdd stm32/boards/LEGO_HUB_NO6: Add helper scripts to update app firmware.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 15:22:16 +10:00
Damien George 87ca431f3f stm32/boards/LEGO_HUB_NO6: Implement robust filesystem-load updates.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 14:30:51 +10:00
Damien George d84ebc31f7 stm32/boards/LEGO_HUB_NO6: Use multi-colour LED for mboot status.
This gives more information to the user when doing updates from SPI flash.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 14:30:51 +10:00
Damien George fae9205594 stm32/boards/LEGO_HUB_NO6: Add support for mboot to access SPI flash.
The following changes are made:
- Use software SPI for external SPI flash access when building mboot.
- Enable the mboot filesystem-loading feature, with FAT FS support.
- Increase the frequency of the CPU when in mboot to 96MHz, to increase the
  speed of SPI flash accesses and programming.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 14:30:51 +10:00
Damien George 36211baf0e stm32/boards/LEGO_HUB_NO6: Make all SPI flash transfers use 32-bit addr.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 14:30:51 +10:00
Damien George 87fbceef26 stm32/mboot: Pass initial_r0 to early-init and get-reset-mode funcs.
This allows a board to modify initial_r0 if needed.

Also make default board behaviour functions always available, named as
mboot_get_reset_mode_default and mboot_state_change_default.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 14:30:51 +10:00
Damien George e64947dc90 stm32/mboot: Make 0x70ad0000 values named constants with macros.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 14:30:51 +10:00
Damien George 9246099935 stm32/mboot: Add update_app_elements to return mboot fsload elements.
In case the elements should not be passed directly to machine.bootloader.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 14:30:51 +10:00
Damien George 1296a01f4c stm32/mboot: Move remaining led_state_all call into mboot_state_change.
This was missed in b2deea6762

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 14:30:51 +10:00
Damien George 54f1694ab6 drivers/bus: Rename MP_SPI_ADDR_IS_32B to MICROPY_HW_SPI_ADDR_IS_32BIT.
And allow it to be configured externally, if needed.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 14:30:51 +10:00
Jared Hancock 2f4aca0381 mimxrt/mphalport: Fix strict aliasing error with unique id. 2022-06-02 12:50:14 +10:00
Damien George 6bda80d811 esp32/machine_i2c: Implement write-then-read I2C transfers.
I2C transfers are much more efficient if they are combined, instead of
doing separate writes and reads.

Fixes issue #7134.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-01 13:20:30 +10:00
robert-hh 1df7678674 mimxrt/boards: Extend the deploy_teensy.md instructions. 2022-05-27 13:23:46 +10:00
robert-hh c7accf7666 mimxrt/boards/OLIMEX_RT1010: Document the initial deploy procedure.
The procedure given here will work whether or not the DevKit motherboard is
used and is equipped with the support MCU.  It is laborious but works.
2022-05-27 13:23:46 +10:00
Damien George cca08922d9 py/emitinlinethumb: Make ARMv7-M instruction use dynamically selectable.
This follows on from a5324a1074 and allows
mpy-cross to dynamically select whether ARMv7-M instructions are supported
in @micropython.asm_thumb functions.

The config option MICROPY_EMIT_INLINE_THUMB_ARMV7M is no longer needed, it
is now controlled by MICROPY_EMIT_THUMB_ARMV7M.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-26 11:54:48 +10:00
iabdalkader 4946dc5f8c teensy/mpconfigport.h: Remove obsolete macros. 2022-05-26 11:17:46 +10:00
iabdalkader 0bdfceacbe extmod/network_ninaw10: Add support for socket events callback. 2022-05-26 11:15:07 +10:00
iabdalkader 875caca504 rp2/boards/ARDUINO_NANO_RP2040_CONNECT: Enable webrepl. 2022-05-25 16:05:50 +02:00
iabdalkader a22d0bda52 rp2/boards/ARDUINO_NANO_RP2040_CONNECT: Disable internal errno.
* Internal errno can't be used with Nina module due to an issue
with esp-idf config.
2022-05-25 16:05:50 +02:00
iabdalkader 4bcffbd1c6 rp2/mpconfigport.h: Allow boards to override internal errno config. 2022-05-25 16:05:50 +02:00
iabdalkader d037e75991 rp2/mpconfigport.h: Enable static scheduler nodes. 2022-05-25 16:05:50 +02:00
Damien George 6e71cde6aa ports: Use default VFS config for import_stat and builtin_open.
For ports with MICROPY_VFS and MICROPY_PY_IO enabled their configuration
can now be simplified to use the defaults for mp_import_stat and
mp_builtin_open.

This commit makes no functional change, except for the following minor
points:
- the built-in "open" is removed from the minimal port (it previously did
  nothing)
- the duplicate built-in "input" is removed from the esp32 port
- qemu-arm now delegates to VFS import/open

Signed-off-by: Damien George <damien@micropython.org>
2022-05-25 13:04:45 +10:00
Damien George 5956466c0e py/builtin: Clean up and simplify import_stat and builtin_open config.
The following changes are made:

- If MICROPY_VFS is enabled then mp_vfs_import_stat and mp_vfs_open are
  automatically used for mp_import_stat and mp_builtin_open respectively.

- If MICROPY_PY_IO is enabled then "open" is automatically included in the
  set of builtins, and points to mp_builtin_open_obj.

This helps to clean up and simplify the most common port configuration.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-25 13:04:45 +10:00
Damien George 26b1d31eda Revert "stm32/rfcore: Intercept addr-resolution HCI cmd to work arou..."
This reverts commit 2668337f36.

The issue with potential breaking of the BLE RX path in the radio is fixed
since WS v1.12.0.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-25 11:02:35 +10:00
Takeo Takahashi 79f3b8731b renesas-ra/modmachine: Add missing MP_REGISTER_MODULE for umachine.
Fix the issue that umachine is not available.

Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-05-25 00:05:30 +10:00
David Lechner c012318d74 unix: Implement `-X realtime` command-line option on macOS.
This adds a new command line option to the unix port `-X realtime` to
enable realtime priority on threads.  This enables high precision timers
for applications that need more accurate timers.

Related docs:
https://developer.apple.com/library/archive/technotes/tn2169/_index.html

Fixes issue #8621.

Signed-off-by: David Lechner <david@pybricks.com>
2022-05-24 00:51:47 +10:00
David Lechner be5657b64f ports: Rename thread_t to mp_thread_t.
This adds the `mp_` prefix to the `thread_t` type.  The name `thread_t`
conflicts with the same in `mach/mach_types.h` on macOS.

Signed-off-by: David Lechner <david@lechnology.com>
2022-05-24 00:51:23 +10:00
Damien George c70f96f1c5 esp32: Track allocated iRAM and free it on soft reset.
This makes sure all iRAM allocated for native code is freed on soft reset.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-19 17:31:56 +10:00
Daniël van de Giessen ef16796f49 esp32/machine_pin: Fix ESP32C3 IDFv4.4.1 build.
Use new constants as seen in ESP-IDF commit b25fb1.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2022-05-19 16:47:13 +10:00
Algy Tynan 5dac142a1a esp32/boards/LILYGO_TTGO_LORA32: Remove ID from TTGO Lora32 board json.
Generic ID creates an incorrect link on the MicroPython download page.
Remove the ID to fix the link.

Signed-off-by: Algy Tynan <algy@tynan.io>
2022-05-19 16:45:18 +10:00
Michael Himing a1abf51a9d esp32/boards/UM_FEATHERS3: Use correct sdkconfig.board. 2022-05-19 16:43:59 +10:00
Christian Zietz e92c22a839 esp8266/etshal.h: Remove unneeded function declaration. 2022-05-19 16:40:39 +10:00
Christian Zietz ea1c0557e5 esp8266/machine_wdt: Remove deinit method for watchdog.
Reasons for removal:
- It did not work properly because it stopped the hardware watchdog
  timer while keeping the software watchdog running (issue #8597).
- There isn't a deinit method for the WDT in any other port.
- "The watchdog is not intended to be stopped. That is a feature."
  (See #8600.)
2022-05-19 16:40:39 +10:00
Jim Mussared c2d889fc1e renesas-ra: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared 1d33ceb0d0 cc3200: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared 9e4da2320a javascript: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared ec2fe5d6ca zephyr: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared 63431a5536 unix: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared d0307e79bb teensy: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared c3f7424a57 samd: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared 62f00a43d5 rp2: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared 60c5968f99 pic16bit: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared f67ac90fa9 nrf: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared 7d79fd7e8b mimxrt: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:56:30 +10:00
Jim Mussared 4274b34d6b esp8266: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:56:30 +10:00
Jim Mussared 24127a4ac4 esp32: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:56:30 +10:00
Jim Mussared 0a92469c10 stm32: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:56:30 +10:00
Jim Mussared bb794f05b7 extmod: Make port-included extmod modules use MP_REGISTER_MODULES.
_onewire, socket, and network were previously added by the port rather
than objmodule.c.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:49:12 +10:00
Jim Mussared 4eab44a1ec extmod: Make extmod modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:49:12 +10:00
Damien George 5b700b0af9 all: Reformat remaining C code that doesn't have a space after a comma.
Signed-off-by: Damien George <damien@micropython.org>
2022-05-05 13:30:40 +10:00
Damien George b0a1b60a9b extmod: Move font_petme128_8x8.h from ports/stm32 to extmod.
And add spaces after commas so it is consistently formatted.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-05 13:30:40 +10:00
Damien George da31ad7aad mimxrt/mbedtls: Use core-provided tracked alloc instead of custom funcs.
Signed-off-by: Damien George <damien@micropython.org>
2022-05-05 10:31:50 +10:00
Damien George 39c96b543f stm32/mbedtls: Use core-provided tracked alloc instead of custom funcs.
Signed-off-by: Damien George <damien@micropython.org>
2022-05-05 10:31:50 +10:00
Damien George fca5701f74 py/malloc: Introduce m_tracked_calloc, m_tracked_free functions.
Enabled by MICROPY_TRACKED_ALLOC.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-05 10:31:50 +10:00
Takeo Takahashi 965747bd97 renesas-ra: Rename pyb_rtc_ to machine_rtc_.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-05-04 19:45:16 +09:00
Takeo Takahashi 5f57ec464a renesas-ra: Rename pyb_uart_ to machine_uart_.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-05-04 19:45:16 +09:00
stijn 20028c7c80 windows: Avoid busy loop when using scheduler. 2022-05-04 10:22:29 +10:00
stijn 8aa79c95bd windows: Consolidate all sleep-related functions into windows_mphal.c.
Replace the timer-based sleep with the standard win32 call since the former
has no benefits: even though it allows specifying the time in 100uSec
chunks, the actual resolution is still limited by the OS and is never
better than 1mSec.

For clarity move all of this next to the mp_hal_delay_ms definition so all
related functions are in one place.
2022-05-04 10:22:09 +10:00
Jim Mussared 0e7bfc88c6 all: Use mp_obj_malloc everywhere it's applicable.
This replaces occurences of

    foo_t *foo = m_new_obj(foo_t);
    foo->base.type = &foo_type;

with

    foo_t *foo = mp_obj_malloc(foo_t, &foo_type);

Excludes any places where base is a sub-field or when new0/memset is used.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-03 22:28:14 +10:00
Takeo Takahashi a204365df1 renesas-ra/boards: Change device name information to show properly.
* Change device name table to list style to show properly.
* Change the link of cable connection information to the latest.

Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-05-02 12:02:32 +09:00
Takeo Takahashi 0f57ccf7f2 renesas-ra: Add new port to Renesas RA.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-04-29 12:29:06 +09:00
Damien George 44186ef59b qemu-arm/mpconfigport: Define MICROPY_PY_SYS_PLATFORM.
Signed-off-by: Damien George <damien@micropython.org>
2022-04-28 17:23:03 +10:00
Damien George 402df833fe py/modsys: Introduce sys.implementation._machine constant.
This contains a string useful for identifying the underlying machine.  This
string is kept consistent with the second part of the REPL banner via the
new config option MICROPY_BANNER_MACHINE.

This makes os.uname() more or less redundant, as all the information in
os.uname() is now available in the sys module.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-28 17:23:03 +10:00
Damien George 40047823bc py/modsys: Append MicroPython git version and build date to sys.version.
This commit adds the git hash and build date to sys.version.  This is
allowed according to CPython docs, and is what PyPy does.  The docs state:

    A string containing the version number of the Python interpreter plus
    additional information on the build number and compiler used.

Eg on CPython:

    Python 3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.version
    '3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0]'

and PyPy:

    Python 2.7.12 (5.6.0+dfsg-4, Nov 20 2016, 10:43:30)
    [PyPy 5.6.0 with GCC 6.2.0 20161109] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>> import sys
    >>>> sys.version
    '2.7.12 (5.6.0+dfsg-4, Nov 20 2016, 10:43:30)\n[PyPy 5.6.0 with GCC ...

With this commit on MicroPython we now have:

    MicroPython v1.18-371-g9d08eb024 on 2022-04-28; linux [GCC 11.2.0] v...
    Use Ctrl-D to exit, Ctrl-E for paste mode
    >>> import sys
    >>> sys.version
    '3.4.0; MicroPython v1.18-371-g9d08eb024 on 2022-04-28'

Note that the start of the banner is the same as the end of sys.version.
This helps to keep code size under control because the string can be reused
by the compiler.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-28 15:23:17 +10:00
Asensio Lorenzo Sempere 9d08eb0247 stm32/boards/NUCLEO_G0B1RE: Add NUCLEO_G0B1RE board definition.
This commit adds a board definition for NUCLEO_G0B1RE. This board has the
REPL on UART2 which is connected to the on-board ST-link USB-UART.

Signed-off-by: Asensio Lorenzo Sempere <asensio.aerospace@gmail.com>
2022-04-28 11:56:15 +10:00
Asensio Lorenzo Sempere 010012c7c3 stm32: Add support for G0 MCUs.
This commit adds support for the STM32G0 series of MCUs.

Signed-off-by: Asensio Lorenzo Sempere <asensio.aerospace@gmail.com>
2022-04-28 11:56:15 +10:00
Asensio Lorenzo Sempere 3587d8e808 stm32/storage: Add support for internal storage on Cortex-M0 MCUs.
This implements self-triggering of the Flash NVIC interrupt on Cortex-M0
devices, which allows enabling internal storage on those MCUs.

Signed-off-by: Asensio Lorenzo Sempere <asensio.aerospace@gmail.com>
2022-04-28 11:56:15 +10:00
iabdalkader 96ad86ed2b stm32/boards/ARDUINO_PORTENTA_H7: Add support for Arduino Portenta H7. 2022-04-28 10:42:47 +10:00
iabdalkader 1f33ec140a stm32/ulpi: Include missing py/mperrno.h header. 2022-04-28 10:34:56 +10:00
iabdalkader 014912daae stm32/ulpi: Add USB3320 ULPI low-power functions.
This driver allows switching USB3320 ULPI to low-power mode.  It is ported/
adapted from ST code, stm32f7xx_lp_modes.c, which is BSD-3 licensed code.
2022-04-26 23:11:50 +10:00
iabdalkader 32914c53ef stm32/qspi: Workaround for SR set immediately after setting AR.
See issue #5441.  This issue is now reproducible on the Arduino Portenta
H747, QSPI flash PN MX25L12833F.
2022-04-26 22:33:05 +10:00
iabdalkader 5974ac256b stm32/qspi: Wait for a free FIFO location before writing to DR.
Must always check the FIFO before writing to DR.  Without this, this
function hangs on the H747.
2022-04-26 22:32:48 +10:00
iabdalkader b28839420d stm32/qspi: Support common flash sizes in MPU configuration.
Add MPU configuration for common flash sizes up to 256MiB.
2022-04-26 22:32:29 +10:00
Damien George 0e6873840b rp2/mpconfigport: Enable execfile, NotImplemented and REPL EMACS keys.
To bring this port in line with other ports that use
MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-26 22:15:07 +10:00
Damien George eb9674822b esp32/modnetwork: Fix build when MICROPY_PY_NETWORK_WLAN is disabled.
Fixes issue #8541.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-22 21:56:31 +10:00
wemos ff28d2e3b3 esp32/network_wlan: Support setting/getting txpower in WLAN.config(). 2022-04-22 21:52:28 +10:00
Damien George 5c32111fa0 ports: Reformat more C and Python source code.
These files that are reformatted only now fall under the list of files to
apply uncrustify/black formatting to.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-20 16:17:35 +10:00
Damien George 707aaa350a stm32/boards/LEGO_HUB_NO6: Exclude BTstack code from formatting.
Signed-off-by: Damien George <damien@micropython.org>
2022-04-20 15:54:26 +10:00
iabdalkader 03c61916bc stm32/boards/ADAFRUIT_F405_EXPRESS: Use external SPI flash for storage.
Fixes issue #8553.
2022-04-20 15:37:14 +10:00
iabdalkader 71afed1a70 stm32/mphalport: Fix I/O glitches when switching GPIO mode to alt-func.
To avoid any I/O glitches in mp_hal_pin_config, make sure a valid alternate
function is set in AFR first before switching the pin mode.  When switching
from AF to INPUT or OUTPUT, the AF in AFR will remain valid up until the
pin mode is switched.
2022-04-20 15:31:14 +10:00
Chris Wilson b50fe9a6da stm32/boards/SPARKFUN_MICROMOD_STM32: Fix incorrect UART and I2C config.
Based on testing with real hardware.
2022-04-19 10:42:37 +10:00
Damien George abdc4ec08d qemu-arm/test-frzmpy: Add test for freezing constant tuples.
Signed-off-by: Damien George <damien@micropython.org>
2022-04-14 23:52:14 +10:00
Damien George 24894f9065 ports: Recompile bytecode tests now that .mpy format changed.
Signed-off-by: Damien George <damien@micropython.org>
2022-04-14 23:52:14 +10:00
Stephane Smith 988827b85a esp32/modesp32: Properly define RTC_VALID_EXT_PINS on S2/S3 variants.
On ESP32 S2/S3 variants, GPIO0 through GPIO21 are valid RTC pins.  This
commit defines the valid RTC_VALID_EXT_PINS for the S2/S3 variants,
otherwise, it keeps functionality the same.
2022-04-14 16:17:52 +10:00
Stephane Smith 7005354099 esp32/machine_pin: Don't expose pins 33-37 when octal SPIRAM is enabled.
For ESP32-S3 configurations, CONFIG_SPIRAM_MODE_OCT requires pins 33-37 for
PSRAM.  So exclude them from the machine_pin_type and machine_pin_irq_type
object tables.
2022-04-14 16:14:13 +10:00
Stephane Smith ae3d5289a5 esp32/boards: Compile GENERIC_SPIRAM and UM_TINYPICO with -Os.
These boards do not build with IDF v4.4 because the section .iram0.text
does not fit in region iram0_0_seg.  Enabling SPIRAM increases the code
size so use -Os instead of -O2 to build these boards.

Fixes issue #8260.
2022-04-14 16:06:41 +10:00
Damien George fe9eaf12f3 esp32: Add MICROPY_HW_ENABLE_UART_REPL and enable on generic S2/S3.
Some S2/S3 modules don't use the native USB interface but instead have an
external USB-UART.  To make the GENERIC_S3/S3 firmware work on these boards
the UART REPL is enabled in addition to the native USB CDC REPL.

Fixes issues #8418 and #8524.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-14 14:39:20 +10:00
Damien George be25e333df esp32/boards: Add test manifest to test freezing during build.
Includes tests for freezing @micropython.native and @micropython.viper
code.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-14 14:06:38 +10:00
Damien George 8045ac07f5 stm32/mpbthciport: Switch scheduling callback to use node scheduler.
Signed-off-by: Damien George <damien@micropython.org>
2022-04-14 12:33:31 +10:00
Peter Hinch d242a9b7f7 rp2/machine_uart: Use read/write mutex to prevent char duplication.
Duplication of characters is caused by re-entrant calls from separate cores
of uart_fill_tx_fifo().  This patch uses a mutex to ensure that a
re-entrant execution of the function returns without affecting the UART
FIFO.

Fixes issues #8344 and #8360.
2022-04-12 11:39:00 +10:00
Dave Hylands 9d7c168bf5 stm32/boards/PYBD_SFx: Allow FROZEN_MANIFEST to be overridden.
Because mpconfigboard.mk used = rather then ?= it doesn't allow
FROZEN_MANIFEST to be overridden using a GNUmakefile or the manifest.
2022-04-11 16:19:45 +10:00
iabdalkader a82fad7d8e stm32/system_stm32: Improve H7 PLL and OSC configuration.
- Allow boards to configure CSI, HSI48 and PLL2.
- Allow peripheral clock source configuration.
- Set H7 SYSCLKSource.
2022-04-11 16:12:53 +10:00
iabdalkader 36cac5e154 stm32/system_stm32: Allow boards to configure PLL VCI, VCO and FRACN.
This removes hard-coded PLL1/3 VCI, VCO and FRACN.
2022-04-11 16:12:53 +10:00
iabdalkader a3e5a68c46 stm32/system_stm32: Set voltage scaling level 0 for H7 Rev-V devices.
This enables voltage scaling level 0 for H7 Rev-V devices, which allows the
CPU to run at the maximum supported operating frequency (480MHz).
2022-04-11 16:12:53 +10:00
iabdalkader bdbc9b395f stm32/system_stm32: Add H7 switched-mode-power-supply support.
- Add board-level configuration option to set the SMPS supply mode.
- Wait for valid voltage levels after configuring the SMPS mode.
- Wait for external supply ready flag if SMPS supplies external circuitry.
2022-04-11 16:12:53 +10:00
iabdalkader 7b3adb5ce5 stm32/Makefile: Add H747 to Makefile's MCU flags. 2022-04-11 16:12:50 +10:00
iabdalkader 2a19c3cfe1 stm32/sdram: Add function to enable SDRAM power-down mode.
Add power-down mode for maximum power saving while in standby mode, to be
used by a board if needed.  Also fix a typo in a comment.
2022-04-11 16:00:40 +10:00
Damien George cb0372b5bf stm32/mboot: Add macros for use in led_state_all().
Signed-off-by: Damien George <damien@micropython.org>
2022-04-11 15:52:41 +10:00
Damien George b2deea6762 stm32/mboot: Consolidate all UI and add general state change hooks.
All user interface (LED, button) code has been moved to ui.c, and the
interface to this code with the rest of the system now goes through calls
to mboot_state_change().  This state-change function can be overridden by a
board to fully customise the user interface behaviour.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-11 15:52:41 +10:00
Damien George aab005c75b extmod/modusocket: Provide config macro for socket.listen backlog deflt.
To make it possible to change this value for any given port or board.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-11 15:28:56 +10:00
Jon Bjarni Bjarnason 919f696ad2 extmod/modusocket: Implement optional socket.listen backlog argument.
This follows the CPython change: https://bugs.python.org/issue21455

Socket listen backlog defaults to 2 if not given, based on most bare metal
targets not having many resources for a large backlog.  On UNIX it defaults
to SOMAXCONN or 128, whichever is less.
2022-04-11 15:26:47 +10:00
Damien George b59989f40e rp2/Makefile: Add mbedtls to GIT_SUBMODULES list and use it in CI func.
Signed-off-by: Damien George <damien@micropython.org>
2022-04-11 13:05:25 +10:00
robert-hh ca41eda281 mimxrt/mphalport: Fix USB CDC RX handling to not block when unprocessed.
Changes in this commit:
- Fix USB CDC RX handling to not block when unprocessed.  The fix follows
  5873390226.
- Fix dupterm rx.
- Remove some obsolete lines.
2022-04-11 12:30:59 +10:00
robert-hh 752fe75910 mimxrt/machine_spi: Improve handling of busy SPI peripheral.
This commit changes the method of waiting for SPI being not busy.  Instead
of the FIFO size, the TransferBusyFlag is probed.

Also, raise an error if the transfer failed.
2022-04-11 12:27:49 +10:00
robert-hh b70b8ce3e4 mimxrt/machine_rtc: Start RTC at boot and set datetime if not set.
Changes in this commit:
- Start the RTC Timer at system boot.  Otherwise time.time() will advance
  only if an RTC() object was created.
- Set the time to a more recent date than Jan 1, 1970, if not set.  That is
  2013/10/14, 19:53:11, MicroPython's first commit.
- Compensate an underflow in in timeutils_seconds_since_2000(), called by
  time.time(), if the time is set to a pre-2000 date.
2022-04-11 12:25:23 +10:00
robert-hh e3030f7436 mimxrt/modules: Append /flash/lib to the default sys.path. 2022-04-11 12:25:15 +10:00
robert-hh 798a29f629 mimxrt/boards: Add board.json file for OLIMEX RT1010Py. 2022-04-11 12:24:43 +10:00
Damien George 66b5c4c770 stm32/machine_bitstream: Include all clobbered regs in Cortex-M0 impl.
These additional registers are used by the assembly code.

Thanks to Jim Mussared for the fix.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-07 21:17:51 +10:00
Damien George 43d50f006d stm32/mpconfigport.h: Let MICROPY_PY_IO_FILEIO take its default value.
This is enabled at MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES, which is the
default for stm32.  Not setting the value in mpconfigboard.h allows boards
to optionally configure it.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-07 13:25:48 +10:00
Martin Fischer 5873390226 rp2/mphalport: Fix USB CDC RX handling to not block when unprocessed.
Prior to this commit, the USB CDC OUT endpoint got NACK'd if a character
was received but not consumed by the application, e.g. via
sys.stdin.read().  This meant that USB CDC was blocked and no additional
characters could be sent from the host.  In particular a ctrl-C could not
interrupt the application if another character was pending.

To fix the issue, the approach in this commit uses a callback tud_cdc_rx_cb
which is called by the TinyUSB stack on reception of new CDC data.  By
consuming the data immediately, the endpoint does not stall anymore.  The
previous handler tud_cdc_rx_wanted_cb was made obsolete and removed.

In addition some cleanup was done along the way: by adding interrupt_char.c
and removing the existing code mp_hal_set_interrupt_char().  Also, there is
now only one (stdin) ringbuffer.

Fixes issue #7996.
2022-04-05 10:47:19 +10:00
iabdalkader 5682595d75 esp32: Allow overriding cmake frozen manifest from the command line.
If MICROPY_FROZEN_MANIFEST is set from the cmake command line, then it will
override the default and any manifest set by the board.
2022-04-04 23:49:10 +10:00
Damien George 86e6744ff5 rp2: Enable ucryptolib, using mbedtls for backend functions.
Signed-off-by: Damien George <damien@micropython.org>
2022-04-04 23:15:01 +10:00
Andrew Leech 8db93dc016 stm32/Makefile: Allow overriding COPT in Makefile.
It can now be set in mpconfigboard.mk (as well as the make command line).
2022-04-04 23:12:15 +10:00
iabdalkader 5562ed3f43 stm32/pyb_can: Replace CAN.initfilterbanks with CAN.init keyword arg.
The CAN.initfilterbanks() class method is removed, and its functionality is
replaced with the "num_filter_banks" keyword argument to the CAN
constructor and CAN.init().  This configures the filter bank split.

This new approach provides more flexibility configuring the resources used
by a given CAN instance, allowing other MCUs like H7 to fit the API.  It
also brings CAN closer to how other machine peripherals are configured,
where everything is done in the constructor/init method.

This is a breaking change to the CAN API.
2022-04-02 22:42:00 +11:00
iabdalkader a79706fb39 stm32/pyb_can: Define the maximum bit timing parameters.
Define the maximum parameters for CAN/FDCAN nominal bit timing, and for
FDCAN data bit timing, for bit timing calculations.
2022-04-02 22:41:37 +11:00
iabdalkader 95104c9f6e stm32/pyb_can: Return the filter ID and type of received messages.
CAN.recv() now returns a 5-tuple, with the new element in the second
position being a boolean, True if the ID is extended.

This is a breaking change of the API for CAN.recv().
2022-04-02 22:40:09 +11:00
iabdalkader e7264e9532 stm32/pyb_can: Add support for bus with mixed Classic/FD nodes.
A CAN bus can have mixed classic/FD nodes.  Prior to this patch the CAN API
could be configured for either standard or extended ID, but not both/mixed
operation.

This patch allows extended IDs to be filtered and enabled on a per-message
basis, in send(), setfilter() and clearfilter().

This is a breaking change to the API: init() no longer accepts the extframe
keyword argument.
2022-04-02 22:37:52 +11:00
iabdalkader 3320ec44ed stm32/pyb_can: Add support for CAN FD extended frame ID. 2022-04-02 22:37:45 +11:00
iabdalkader ff287d085f stm32/pyb_can: Enable CAN FD frame support and BRS.
- Enable CAN FD frame support and BRS.
- Optimize the message RAM usage per FDCAN instance.
- Document the usage and different sections of the Message RAM.
2022-04-02 22:37:27 +11:00
Andrew Leech a41bc5a7ca stm32/modmachine: Add deepsleep support to reset_cause() for WB55. 2022-03-30 15:56:26 +11:00
Meriç SARIIŞIK 6b23f7d301 stm32/sdio: Use runtime calculation for clock divider of sdio on H7.
STM32H7 family has a different calculation compared to the current one for
the SDMMC clock divider configuration.
2022-03-30 15:40:59 +11:00
Andrew Leech 303e222f70 nrf/modules: Include uasyncio in default board manifest. 2022-03-30 15:37:49 +11:00
Andrew Leech f92da1adc4 nrf/drivers/usb: Fix MP_STREAM_POLL_RD support on USB CDC.
This gets ipoll working on USB CDC stdin.
2022-03-30 15:34:25 +11:00
Andrew Leech dc8b43adc7 nrf/drivers/usb: Fix background events/scheduling while at USB REPL. 2022-03-30 15:33:29 +11:00
MikeTeachman 1f6cb8f047 mixmrt/machine_i2s: Add I2S protocol support.
This commit adds support for machine.I2S on the mimxrt port.  The I2S API
is consistent with the existing stm32, esp32, and rp2 implementations.

I2S features:
- controller transmit and controller receive
- 16-bit and 32-bit sample sizes
- mono and stereo formats
- sampling frequencies from 8kHz to 48kHz
- 3 modes of operation:
  - blocking
  - non-blocking with callback
  - uasyncio
- configurable internal buffer
- optional MCK

Tested with the following development boards:
- MIMXRT1010_EVK, MIMXRT1015_EVK, MIMXRT1020_EVK, MIMXRT1050_EVK
- Teensy 4.0, Teensy 4.1
- Olimex RT1010
- Seeed ARCH MIX

Tested with the following I2S hardware peripherals:
- UDA1334
- GY-SPH0645LM4H
- WM8960 codec on board the MIMXRT boards and separate breakout board
- INMP441
- PCM5102
- SGTL5000 on the Teensy audio shield

Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
2022-03-30 14:12:40 +11:00
Damien George 6804a8a891 stm32/machine_i2s: Fix 16-bit stereo i2s_frame_map.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-29 11:44:08 +11:00
Damien George 2a91c8a888 stm32/machine_i2s: Allow I2S.deinit to be called multiple times.
In particular, it is called by the constructor if the instance already
exists.  So if the previous instance was deinit'd then it will be deinit'd
a second time.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-29 11:44:08 +11:00
Damien George c90dfba04c stm32/machine_i2s: Set FullDuplexMode to disabled on F4.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-29 11:44:08 +11:00
iabdalkader df86cef59a rp2: Allow Overriding cmake frozen manifest from the command line.
If MICROPY_FROZEN_MANIFEST is set from the cmake command line, then it will
override the default and any manifest set by the board.
2022-03-24 22:10:01 +11:00
iabdalkader fe8b47e29f ports: Allow boards to define additional network interfaces. 2022-03-24 17:23:28 +11:00
Damien George 66fe3d5cb5 stm32: Support building for STM32F745.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 16:01:09 +11:00
Andrew Leech bb0ca00b77 stm32/mboot: Verify CRC32 of fsload DFU files before writing. 2022-03-22 15:04:41 +11:00
Andrew Leech bc856a1e29 stm32/mboot: Verify signature of fsload packed DFU files before writing.
When verifying the DFU contents, the signature of signed/encrypted files is
also now checked in this initial, dry-run stage.
2022-03-22 15:04:37 +11:00
Damien George 80055c2cdc stm32/mboot/fwupdate.py: Simplify calculation of CRC32.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 14:14:31 +11:00
Damien George bf89e336b9 stm32/boards/PYBD_SF2: Turn on SD card in mboot init if SD enabled.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 13:33:43 +11:00
Damien George e316306546 stm32/mboot: Add support for reading from SD card.
Tested on PYBV10 and PYBD_SF6, with MBOOT_FSLOAD enabled and programming
new firmware from a .dfu.gz file stored on the SD card.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 13:33:43 +11:00
Damien George 9b07d38c7e stm32/mboot: Add support for 64-bit mboot address space for reads.
If enabled via MBOOT_ADDRESS_SPACE_64BIT (it's disabled by default) then
read addresses will be 64-bit.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 13:33:43 +11:00
Damien George a92d45c3df stm32/mboot: Always check the magic number to enter filesystem loading.
Even if MBOOT_FSLOAD is disabled, mboot should still check for 0x70ad0080
so it can immediately return to the application if this feature is not
enabled.  Otherwise mboot will get stuck in DFU mode.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 12:49:00 +11:00
Damien George dc91024a73 stm32/mboot: Add pragma for GCC to ignore array bounds warning.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 12:44:10 +11:00
Damien George f0be0de341 stm32/dma: Add option to disable auto-DMA-turn-off.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 12:43:53 +11:00
Damien George 63c7593df6 stm32/main: Support SD cards without a partition table.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 12:41:15 +11:00
Damien George 75d2bfcccf stm32/sdcard: Add sdcard_select_sd/mmc functions.
So that C code can select which of SD or MMC to use.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 12:38:45 +11:00
Damien George 7a9cf1f0fb stm32/sdcard: Use mp_hal_pin_input instead of HAL function.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 12:15:36 +11:00
Damien George eef7eae6b2 esp8266/modesp: Remove esp.info() function.
The main functionality of this info function is available via the existing
micropython.mem_info() and micropython.qstr_info() functions.  The printing
of the address space layout doesn't add much and removing esp.info() saves
about 600 bytes.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 11:03:29 +11:00
Damien George 65be5e072f esp8266/mpconfigport.h: Remove config values that are the defaults.
This commit is a no-op in terms of functionality.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-22 11:03:15 +11:00
Kattni Rembor 61c02e6500 esp32/machine_pin: Expose pin 20 for ESP32.
This pin is available on some ESP32 packages.

Signed-off-by: Kattni Rembor <kattni@adafruit.com>
2022-03-22 10:40:00 +11:00
Algy Tynan afceb56ee2 esp32/boards: Add support for LilyGO LoRa32 boards.
Boards use ESP32-PICO-D4.

Added pins for hardware versions v1.0, v1.2, v1.6 and v2.0.

Signed-off-by: Algy Tynan <algy@tynan.io>
2022-03-22 00:19:36 +11:00
robert-hh 09b55dc297 esp32/machine_hw_spi: Use automatic DMA channel selection for SPI on C3.
Addresses issue #8204.
2022-03-22 00:13:25 +11:00
wemos 1a0bd352d3 esp32/boards: Add LOLIN C3 MINI ESP32-C3 based board. 2022-03-22 00:11:02 +11:00
Jonathan Hogg 3b9de192be esp32/boards/UM_TINYPICO: Remove use of PULL_HOLD.
Change APA102 power handling to not use the (now removed) PULL_HOLD
constant.
2022-03-21 23:59:48 +11:00
Jonathan Hogg 21d0599bd1 esp32/modesp32: Add new gpio_deep_sleep_hold function.
Add a new function to control whether held pins will retain their function
through deep-sleep.

Also document this function and explain how to use this in quickref to
retain pin configuration during deep-sleep.
2022-03-21 23:59:07 +11:00
Jonathan Hogg 7684c996bc esp32/machine_pin: Add new hold keyword argument and remove PULL_HOLD.
The current pull=Pin.PULL_HOLD argument doesn't make a lot of sense in the
context of what it actually does vs what the ESP32 quickref document says
it does.

This commit removes PULL_HOLD and adds a new hold=True|False keyword
argument to Pin()/Pin.init().  Setting this to True will cause the ESP32 to
lock the configuration of the pin – including direction, output value,
drive strength, pull-up/-down – such that it can't be accidentally changed
and will be retained through a watchdog or internal reset.

Fixes issue #8283, and see also #8284.
2022-03-21 23:55:02 +11:00
Peter Züger 94a9b50668 mimxrt/mbedtls: Add NULL pointer check in m_free_mbedtls.
Signed-off-by: Peter Züger <zueger.peter@icloud.com>
2022-03-17 13:11:39 +11:00
Peter Züger 95ee29f4f4 stm32/mbedtls: Add NULL pointer check in m_free_mbedtls.
According to the C standard the free(void *ptr) function: if ptr is a null
pointer, no action occurs.

Signed-off-by: Peter Züger <zueger.peter@icloud.com>
2022-03-17 13:11:22 +11:00
iabdalkader a16dcc8136 stm32/boards: Convert F4xx and F7xx to new flash FS config.
Following on from 35e70c1698.

Fixes issue #8390.
2022-03-17 13:06:45 +11:00
Damien George eec07332b1 unix/variants: Enable a few optimisations and features on dev, coverage.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 13:34:43 +11:00
Damien George 3c20ddb41a unix/variants: Use rom feature config for standard, dev, coverage.
This change is a no-op in terms of functionality.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 13:32:25 +11:00
Damien George 0ac3191d8c unix/mpconfigport.h: Collect together config options from extra level.
This change is a no-op in terms of functionality.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 13:29:13 +11:00
Damien George ac2293161e py/modsys: Add optional mutable attributes sys.ps1/ps2 and use them.
This allows customising the REPL prompt strings.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 10:58:33 +11:00