Wykres commitów

14442 Commity (4f3780a156e1ba3f6981ab3a90be655a718f88f5)

Autor SHA1 Wiadomość Data
Damien George b151422cb2 lib/cyw43-driver: Update driver to latest version.
Changes since the previous version:
- remove mDNS
- implement lwIP IGMP MAC filter callback
- implement IPv6 support
- allow building with IGMP disabled
- fix handshake meggase WAIT_G1 event value
- increase EAPOL timeout from 2500ms to 500ms
- add function to get RSSI
- fix handling of open security networks
- remove support for automatically setting auth type

Signed-off-by: Damien George <damien@micropython.org>
2022-12-20 16:06:40 +11:00
Felix Dörre 439298be15 rp2: Fix lightsleep to work with interrupts and cyw43 driver.
This commit prevents the device from "hanging" when using lightsleep while
the WiFi chip is active.

Whenever the WiFi chip wants to interrupt the microcontroller to notify it
for a new package, it sets the CYW43_PIN_WL_HOST_WAKE pin to high,
triggering an IRQ.  However, as polling the chip cannot happen in an
interrupt handler, it subsequently notifies the pendsv-service to do a poll
as soon as the interrupt handler ended.  In order to prevent a new
interrupt from happening immediately afterwards, even before the poll has
run, the IRQ handler disables interrupts from the pin.

The first problem occurs, when a WiFi package arrives while the main loop
is in cyw43-code.  In order to prevent concurrent access of the hardware,
the network code blocks pendsv from running again while entering lwIP code.

The same holds for direct cyw43 code (like changing the cyw43-gpios, i.e.
the LED on the Pico W).  While the pendsv is disabled, interrupts can still
occur to schedule a poll (and disable further interrupts), but it will not
run.  This can happen while the microcontroller is anywhere in rp2040 code.

In order to preserve power while waiting for cyw43 responses,
cyw43_configport.h defines CYW43_DO_IOCTL_WAIT and
CYW43_SDPCM_SEND_COMMON_WAIT to __WFI().  While this might work in most
cases, there are 2 edge cases where it fails:
- When an interrupt has already been received by the cyw43 stack, for
  example due to an incoming ethernet packet.
- When the interrupt from the cyw43 response comes before the
  microcontroller entered the __WFI() instruction.

When that happens, wfi will just block forever as no further interrupts are
received.  The only way to safely use wfi to wake up from an interrupt is
inside a critical section, as this delays interrupts until the wfi is
entered, possibly resuming immediately until interrupts are reenabled and
the interrupt handler is run.  Additionally this critical section needs to
check whether the interrupt has already been disabled and pendsv was
triggered, as in such a case, wfi can never be woken up, and needs to be
skipped, because there is already a package from the network chip waiting.
Note that this turns cyw43_yield into a nop (and thereby the cyw43-loops
into busy waits) from the second time onwards, as after the first call, a
pendsv request will definitely be pending.  More logic could be added, to
explicitly enable the interrupt in this case.

Regarding lightsleep, this code has a similar problem.  When an interrupt
occurs during lightsleep, the IRQ and pendsv handler and thereby poll are
run immediately, with the clocks still disabled, causing the SPI transfers
to fail.  If we don't want to add complex logic inside the IRQ handler we
need to protect the whole lightsleep procedure form interrupts with a
critical section, exiting out early if an interrupt is pending for whatever
reason.  Only then we can start to shut down clocks and only enable
interrupts when the system is ready again.  Other interrupt handlers might
also be happy, that they are only run when the system is fully operational.

Tested on a Pico W, calling machine.lightsleep() within an endless loop and
pinging from the outside.
2022-12-20 15:54:51 +11:00
robert-hh 57bb1e0474 tools/autobuild: Create .uf2 file for seeed_xiao_nrf52.
And for all other nrf boards that have or get a uf2 build tag.
2022-12-19 16:16:12 +11:00
David Lechner 3b285326e3 github/workflows: Update existing comments for code_size_comment.
This modifies the automated code size comment to edit an existing comment
if one already exists instead of always creating a new comment.  This
reduces noise on pull requests that are repeatedly updated.

Signed-off-by: David Lechner <david@pybricks.com>
2022-12-19 14:42:07 +11:00
Red_M 1290329415 esp32/boards/GENERIC_S3_SPIRAM_OCT: Add ESP32S3 board with Octal SPIRAM. 2022-12-19 13:29:33 +11:00
Damien George bb77c1d5a3 stm32/powerctrl: Fix build on STM32G0xx and STM32H7Bx MCUs.
STM32G0xx doesn't have DBGMCU, and STM32H7Bx doesn't have EXTI_D2.

Signed-off-by: Damien George <damien@micropython.org>
2022-12-16 16:48:59 +11:00
Damien George 910f579403 py/emitnative: Initialise locals as Python object type for native code.
In @micropython.native code the types of variables and expressions are
always Python objects, so they can be initialised as such.  This prevents
problems with compiling optimised code like while-loops where a local may
be referenced before it is assigned to.

Signed-off-by: Damien George <damien@micropython.org>
2022-12-16 11:44:10 +11:00
Damien Tournoud ed58d6e4ce extmod/modussl_mbedtls: Fix support for ioctl(MP_STREAM_POLL).
During the initial handshake or subsequent renegotiation, the protocol
might need to read in order to write (or conversely to write in order
to read). It might be blocked from doing so by the state of the
underlying socket (i.e. there is no data to read, or there is no space
to write).

The library indicates this condition by returning one of the errors
`MBEDTLS_ERR_SSL_WANT_READ` or `MBEDTLS_ERR_SSL_WANT_WRITE`. When that
happens, we need to enforce that the next poll operation only considers
the direction that the library indicated.

In addition, mbedtls does its own read buffering that we need to take
into account while polling, and we need to save the last error between
read()/write() and ioctl().
2022-12-15 12:06:22 -08:00
robert-hh 988b6e2dae renesas-ra: Add the UART methods uart.txdone() and uart.flush().
This required to add two functions down the stack to uart.c and ra.sci.c.

- One for telling, whther the transmission is busy.
- One for reporting the size of the TX buffer.

Tested with a EK-RA6M2 board.
2022-12-15 12:09:34 +01:00
Jim Mussared 9e91764671 py/obj: Remove unused MP_DEFINE_CONST_OBJ_FULL_TYPE macro.
This was previously used for the definition of NIC types, but they have
been updated to use a protocol instead.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-12-15 17:40:36 +11:00
Jim Mussared 68090cc6cd cc3200: Remove unused NIC type customisation.
See the previous commit, except in this case the customisation didn't
actually do anything so can just be removed.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-12-15 17:40:18 +11:00
Jim Mussared 5f8f32f917 extmod/modnetwork: Use a type protocol to implement NIC functions.
This was previously implemented by adding additional members to the
mp_obj_type_t defined for each NIC, which is difficult to do cleanly with
the new object type slots mechanism. The way this works is also not
supported on GCC 8.x and below.

Instead replace it with the type protocol, which is a much simpler way of
achieving the same thing.

This affects the WizNet (in non-LWIP mode) and Nina NIC drivers.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-12-15 17:40:06 +11:00
brave ulysses 7f71057a89 stm32/boards/NUCLEO_F756ZG: Add board definition for NUCLEO-F756ZG.
Signed-off-by: Damien George <damien@micropython.org>
2022-12-15 14:59:26 +11:00
iabdalkader 5b7f71882b stm32/powerctrl: Improve standby mode entry code for H7 MCUs.
Changes in this commit:
- Clear and mask D2 EXTIs.
- Set correct voltage scaling level for standby mode.
- Disable debug MCU (if debugging is disabled), for all MCU series.
2022-12-15 14:39:28 +11:00
robert-hh 564945a2a0 nrf/boards/seeed_xiao_nrf52: Add defn for Seeed XIAO NRF52840 Sense.
It keeps compatibility with the XIAO bootloader by:
- using Soft Device 7.3.0
- reserving 48k memory for the bootloader.

So on double reset a drive pops for uploading an uf2 image or a nrfutil zip
pkg file.  Instructions to create it from a hex file are included.  The
bootloader can as well be activated with the touch 1200 option of nrfutil.

The script download_ble_stack.sh has been adapted to get the version 7.3.0
soft device files.  It may have to be executed once before building.

The file system is set to 256k and the pin definitions are adapted.
Besides that, it has the common functionality and omissions.  The on-board
sensors and additional flash can be supported by Python scripts.
2022-12-15 14:27:08 +11:00
Jim Mussared 6d460d33dc samd/boards/SEEED_XIAO: Rename to SEEED_XIAO_SAMD21.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-12-15 14:18:44 +11:00
Damien Tournoud fd1e66edb3 esp32/usb: Cleanup connection detection.
This was introduced by 35fb90bd57, but
it is much simpler and essentially the same to just use
`tud_cdc_n_connected()`.

The only difference is that tud_cdc_n_connected() only checks for DTR,
but this is correct anyway: DTR indicates device presence, RTS indicates
that the host wants to receive data.

Signed-off-by: Damien Tournoud <damien@platform.sh>
2022-12-13 20:46:32 -08:00
Jim Mussared 9bec52a2f8 esp32/main: Don't call usocket_events_deinit if unavailable.
usocket_events_deinit will only be available if MICROPY_PY_USOCKET_EVENTS
is enabled (which is only enabled when webrepl is enabled).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-12-14 13:51:20 +11:00
Wind-stormger 3a3739037d esp32/machine_touchpad: Fix TouchPad for ESP32S2, ESP32S3. 2022-12-14 13:46:41 +11:00
David Lechner 5608226cfd github/workflows: Cancel when branch is updated.
This adds a concurrency section to all github workflows to cancel any
in progress workflow when a branch is updated. This should cancel any
ongoing or queued workflows, e.g. when a pull request is updated.

Signed-off-by: David Lechner <david@pybricks.com>
2022-12-14 13:42:50 +11:00
David Lechner 3c2d7563d2 tests/unix/mod_os: Add test for os module.
This adds a test to get coverage of the unix port-specific implementation
of the `os` module.

Signed-off-by: David Lechner <david@pybricks.com>
2022-12-14 13:38:51 +11:00
David Lechner 958f748e53 unix/moduos: Implement 2-arg version of os.getenv().
This adds the `default` argument of `os.getenv(key, default=None)`.

Signed-off-by: David Lechner <david@pybricks.com>
2022-12-14 13:38:39 +11:00
Damien Tournoud 0eba00a92c extmod/uasyncio: Fix syntax of generator functions.
The compiler is not picky right now, but these are actually all syntax
errors:
- await is only valid in an async function
- async functions that use yield are actually async generators (a construct
  not supported by the compiler right now)
2022-12-14 13:25:24 +11:00
robert-hh b75b5c102c mimxrt/sdcard: Remove obsolete code already excluded by preprocessor. 2022-12-14 13:05:27 +11:00
robert-hh aea4174937 mimxrt/sdcard: Fix an error when writing large blocks.
Which happened when a read followed a large write.
2022-12-14 13:04:58 +11:00
robert-hh 913f9ad5ad mimxrt/machine_rtc: Set the microsecond value to 0.
Set the subsecond value reported by rtc.datetime() and rtc.now() to 0.
Synchronizing the roll-over with the second change was not precise.
2022-12-14 13:04:09 +11:00
robert-hh 17ab2f671b samd: Support entering bootloader via USB CDC 1200bps touch. 2022-12-14 12:50:04 +11:00
robert-hh e69313f89c samd: Add a vref=num option to the ADC and DAC constructor.
ADC: The argument of vref=num is an integer. Values for num are:

    SAMD21:
    0  INT1V   1.0V voltage reference
    1  INTVCC0 1/1.48 Analog voltage supply
    2  INTVCC1 1/2 Analog voltage supply (only for VDDANA > 2.0V)
    3  VREFA   External reference
    4  VREFB   External reference

    SAMD51:
    0  INTREF  internal bandgap reference
    1  INTVCC1 Analog voltage supply
    2  INTVCC0 1/2 Analog voltage supply (only for VDDANA > 2.0v)
    3  AREFA   External reference A
    4  AREFB   External reference B
    5  AREFC   External reference C (ADC1 only)

DAC: The argument of vref=num is an integer. Suitable values:

    SAMD21:
    0  INT1V   Internal voltage reference
    1  VDDANA  Analog voltage supply
    2  VREFA   External reference

    SAMD51:
    0  INTREF Internal bandgap reference
    1  VDDANA Analog voltage supply
    2  VREFAU Unbuffered external voltage reference (not buffered in DAC)
    4  VREFAB Buffered external voltage reference (buffered in DAC).
2022-12-14 12:48:24 +11:00
robert-hh a73dcb3d22 samd/machine_uart: Fix uart.deinit() and save some RAM.
Changes in this commit:
- Do not deinit IRQ when uart.deinit() is called with an inactive object.
- Remove using it for the finaliser.  There is another machanism for soft
  reset, and it is not needed otherwise.
- Do not tag the UART buffers with MP_STATE_PORT, it is not required.
2022-12-14 12:46:20 +11:00
robert-hh f78dd25a2c samd/machine_uart: Check the UART TX pin assignment.
Check, if TX is at Pad 0 (SAMD51), or Pad 0 or 2 (SAMD21).
2022-12-14 12:45:51 +11:00
robert-hh 5b1fd8802a samd/machine_uart: Simplify machine_uart_any() and machine_uart_read().
Remove the call to uart_drain_rx_fifo().  It is not required, and may cause
a race condition.
2022-12-14 12:43:34 +11:00
robert-hh 4199f986ad samd/machine_uart: Fix IRQ flag setting and clearing.
Clearing the DRE flag for the transmit interrupt at the end of a
uart.write() also cleared the RXC flag disabling the receive interrupt.

This commit also changes the flag set/clear mechanism in the driver for SPI
as well, even if it did not cause a problem there.  But at least it saves a
few bytes of code.
2022-12-14 12:42:34 +11:00
robert-hh fcd1788937 samd: Avoid under-/overflow in I2C and SPI baudrate calculations.
Applies to both SPI and I2C.  The underflow caused high baudrate settings
resulting in the lowest possible baudrate.  The overflow resulted in
erratic baudrates, not just the lowest possible.
2022-12-14 12:41:42 +11:00
robert-hh 43fc133dbd samd/mpconfigport: Use __WFE() in MICROPY_EVENT_POLL_HOOK.
Like WFI, WFE also responds to a hardware interrupt, and using WFE speeds
up at least spi.read().  Power consumption at an idle REPL is unchanged.
2022-12-14 12:40:22 +11:00
robert-hh 3cc359c204 samd/mpconfigport: Support MICROPY_HW_SOFTSPI_MIN_DELAY.
Bringing the SoftSPI baudrate up to about 500 kHz.
2022-12-14 12:39:54 +11:00
Dale Weber f2de289ef3 stm32/boards/NUCLEO_F429ZI: Enable I2C1 and I2C2 with default pins.
The datasheet on page 55 shows PF0 (SDA) and PF1 (SCL) are the pins for
I2C2, but these pins do not work.  Checking the MBED pinout for the
NUCLEO-F429ZI shows:

    I2C1: PB8 (SCL) and PB9 (SDA).
    I2C2: PB10 (SCL) and PB11 (SDA).

Both of these work and can be scanned and find devices connected to them.

Signed-off-by: Dale Weber <hybotics.sd@gmail.com>.
2022-12-13 17:35:55 +11:00
stijn f6f177807f windows/.gitignore: Simplify by removing build artefacts.
Since all output is now in the build-<variant>/ directory, which is already
excluded by the root .gitignore, we don't need to repeat that.
2022-12-13 17:22:11 +11:00
stijn 9c7ff87643 all: Keep msvc build output in build/ directories.
This follow the change made for Makefile-based projects in b2e82402.
2022-12-13 17:18:53 +11:00
Antonin ENFRUN db19ee7e15 webassembly/library: Extract and send data to print as UInt8Array.
This allows utf-8 data to work.  It's the receiving layer's responsibility
to deal with decoding the data.
2022-12-13 17:16:37 +11:00
David Lechner f3d9fe7b2c docs/differences: Add Python 3.10 page.
This adds a new page for Python 3.10 implementation status similar to
previous releases.

Signed-off-by: David Lechner <david@pybricks.com>
2022-12-13 16:55:55 +11:00
David Lechner 918e0ae164 docs/differences: Update Python 3.9 status.
This marks PEP 584 as complete and notes a few PEPs as not relevant.

Signed-off-by: David Lechner <david@pybricks.com>
2022-12-13 16:31:11 +11:00
TPReal bf49a087b2 extmod/modframebuf: Fix crash in FrameBuffer scrolling beyond extents.
Fixed the crash occurring when scrolling by at least the size of the
framebuffer.
2022-12-09 16:47:23 +11:00
TPReal 002f54ab4e tests/extmod/framebuf_scroll: Add tests for FrameBuffer scrolling.
Includes a currently-failing test of scrolling by at least the size of the
buffer.
2022-12-09 16:47:08 +11:00
Damien George b042fd5120 drivers/bus: Change QSPI read_cmd signature to return an error code.
Signed-off-by: Damien George <damien@micropython.org>
2022-12-09 13:25:18 +11:00
Andrew Leech 7ee5afe8d1 drivers/bus: Detect QSPI transfer errors and pass up to spiflash driver.
This changes the signatures of QSPI write_cmd_data, write_cmd_addr_data and
read_cmd_qaddr_qdata so they return an error code.  The softqspi and stm32
hardware qspi driver are updated to follow this new signature.  Also the
spiflash driver is updated to use these new return values.

Signed-off-by: Damien George <damien@micropython.org>
2022-12-09 13:25:18 +11:00
Damien George ab0258fb1e py/gc: Fix debug printing of GC layout.
Signed-off-by: Damien George <damien@micropython.org>
2022-12-08 14:36:34 +11:00
Jeff Epler d75ff42297 unix/coverage: Add extra GC coverage test for ATB gap byte.
The assertion that is added here (to gc.c) fails when running this new test
if ALLOC_TABLE_GAP_BYTE is set to 0.

Signed-off-by: Jeff Epler <jepler@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2022-12-08 14:35:08 +11:00
Jeff Epler 9f434dd8de py/gc: Ensure a gap of one byte after the ATB.
Prior to this fix the follow crash occurred.  With a GC layout of:

    GC layout:
      alloc table at 0x3fd80428, length 32001 bytes, 128004 blocks
      finaliser table at 0x3fd88129, length 16001 bytes, 128008 blocks
      pool at 0x3fd8bfc0, length 2048064 bytes, 128004 blocks

Block 128003 is an AT_HEAD and eventually is passed to gc_mark_subtree.
This causes gc_mark_subtree to call ATB_GET_KIND(128004).  When block 1 is
created with a finaliser, the first byte of the finaliser table becomes
0x2, but ATB_GET_KIND(128004) reads these bits as AT_TAIL, and then
gc_mark_subtree references past the end of the heap, which happened to be
past the end of PSRAM on the esp32-s2.

The fix in this commit is to ensure there is a one-byte gap after the ATB
filled permanently with AT_FREE.

Fixes issue #7116.

See also https://github.com/adafruit/circuitpython/issues/5021

Signed-off-by: Jeff Epler <jepler@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2022-12-08 14:29:58 +11:00
Jeff Epler 84071590b3 py/gc: Avoid valgrind false positives.
When you want to use the valgrind memory analysis tool on MicroPython, you
can arrange to define MICROPY_DEBUG_VALGRIND to enable use of special
valgrind macros.  For now, this only fixes `gc_get_ptr` so that it never
emits the diagnostic "Conditional jump or move depends on uninitialised
value(s)".

Signed-off-by: Jeff Epler <jepler@gmail.com>
2022-12-08 14:29:22 +11:00
Damien George 2283b6d68f py: Pass in address to compiled module instead of returning it.
This change makes it so the compiler and persistent code loader take a
mp_compiled_module_t* as their last argument, instead of returning this
struct.  This eliminates a duplicate context variable for all callers of
these functions (because the context is now stored in the
mp_compiled_module_t by the caller), and also eliminates any confusion
about which context to use after the mp_compile_to_raw_code or
mp_raw_code_load function returns (because there is now only one context,
that stored in mp_compiled_module_t.context).

Reduces code size by 16 bytes on ARM Cortex-based ports.

Signed-off-by: Damien George <damien@micropython.org>
2022-12-08 12:27:23 +11:00