summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-11-29rp2/mpnetworkport: Rework lwIP polling to use soft_timer.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-11-29rp2/mpbthciport: Rework HCI polling timer to use soft_timer.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-11-29rp2: Integrate soft_timer using the alarm pool.Damien George
The alarm pool is used to schedule the callback to soft_timer_handler(). Signed-off-by: Damien George <damien@micropython.org>
2023-11-29shared/runtime/softtimer: Generalise soft_timer to work without SysTick.Damien George
If a port defines MICROPY_SOFT_TIMER_TICKS_MS then soft_timer assumes a SysTick back end, and provides a soft_timer_next variable that sets when the next call to soft_timer_handler() should occur. Otherwise, a port should provide soft_timer_get_ms() and soft_timer_schedule_at_ms() with appropriate semantics (see comments). Existing users of soft_timer should continue to work as they did. Signed-off-by: Damien George <damien@micropython.org>
2023-11-28py/modbuiltins: Share vstr_add_char's implementation of utf8 encoding.Jeff Epler
This saves ~84 bytes on trinket m0, and saves 112 bytes on PYBV10. Signed-off-by: Jeff Epler <jepler@gmail.com>
2023-11-28stm32: Add missing header include for debug builds.iabdalkader
Debug build fails if string.h header is not included. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-11-28py/mkrules: Add support for custom manifest variables.Jim Mussared
This allows e.g. a board (or make command line) to set MICROPY_MANIFEST_MY_VARIABLE = path/to/somewhere set(MICROPY_MANIFEST_MY_VARIABLE path/to/somewhere) and then in the manifest.py they can query this, e.g. via include("$(MY_VARIABLE)/path/manifest.py") Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-23esp32/esp32_rmt: Fix RMT looping.Mark Blakeney
Commit 7ea06a3e2638e0fb82240c0b88c9cd1ecaf942f5 moved the `rmt_write_items()` call to fix RMT looping for ESP32-S3, but broke it for the other ESP32s. This commit conditionally compiles the location of that call. Signed-off-by: Mark Blakeney <mark.blakeney@bullet-systems.net>
2023-11-23esp32/network_wlan: Fix network.WLAN.status() to return better info.Ihor Nehrutsa
Prior to this change, after calling connect() the status() method for the STA interface would either return STAT_GOT_IP or STAT_CONNECTION. The latter would be returned because wifi_sta_connect_requested==true and conf_wifi_sta_reconnects==0 by default. As such there was no way to know anything about errors when attempting to connect, such as a bad password. Now, status() can return STAT_NO_AP_FOUND and STAT_WRONG_PASSWORD when those conditions are met. Fixes issue #12930. Signed-off-by: IhorNehrutsa <Ihor.Nehrutsa@gmail.com>
2023-11-23esp32/network_wlan: Reduce RAM usage if SPIRAM fails to initialise.Angus Gratton
In ESP-IDF, enabling SPIRAM in menuconfig sets some Kconfig options: - "Wi-Fi Cache TX Buffers" enabled. By default this tries to allocate 32 of these when Wi-Fi is initialised, which requires 54,400 bytes of free heap. - Switches "Type of WiFi TX buffers" from Dynamic to Static. This pre-allocates all of the Wi-Fi transmit buffers. Not a problem if PSRAM is initialised, but it's quite a lot of RAM if PSRAM failed to initialise! As we use the same config for PSRAM & no-PSRAM builds now, this either causes Wi-Fi to fail to initialise (seen on S2) or will eat quite a lot of RAM. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-23esp32/uart: Make compatible with sclk type change in ESP-IDF 5.3.Trent Piepho
This type changes when they add LP-UART support for the ESP32-C6 in the dev version of ESP-IDF 5.3. Signed-off-by: Trent Piepho <tpiepho@gmail.com>
2023-11-23esp32/uart: Preserve console UART clock, fix UART console with DFS.Trent Piepho
In commit 7c929d44 the console UART was changed to use the UART HAL. Starting the UART HAL will change the UART clock from whatever it was already configured at to UART_SCLK_DEFAULT. There is no "initialize at existing settings" option. This clock doesn't work with DFS. The ESP-IDF code already takes this into account, and when DFS is enabled it will configure the console UART to use the correct platform-specific clock that will work with DFS. The UART HAL init undoes this and sets it back to default. This change will query the clock before the HAL init, then use the HAL function to restore it back. Thus keeping the clock at the "correct" value, which depends on platform, DFS status, and so on. The clock frequency will be found using the UART driver function ESP-IDF code uses for this. The existing code hard-coded a path that worked if the clock was the APB clock and would fail otherwise. The UART_NUM_0 define is removed because driver/uart.h already provides this same macro. Signed-off-by: Trent Piepho <tpiepho@gmail.com>
2023-11-23esp32/boards/ESP32_GENERIC: Reduce size of D2WD variant to fit in flash.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-11-22docs/library/esp: Correct the description of esp.osdebug().Angus Gratton
The behaviour described in the docs was not correct for either port. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-22esp32/boards/sdkconfig.base: Fix increasing log level via esp.osdebug().Angus Gratton
At some point the config changed such that no messages above Error level were compiled into the final binary. Fixes issue #12815. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-21py/objslice: Validate that the argument to indices() is an integer.Damien George
Otherwise passing in a non-integer can lead to an invalid memory access. Thanks to Junwha Hong and Wonil Jang @S2Lab, UNIST for finding the issue. Fixes issue #13007. Signed-off-by: Damien George <damien@micropython.org>
2023-11-20esp32/modsocket: Try garbage collection if the socket limit is reached.Angus Gratton
If the hard socket limit (default 16) is reached then it's possible that socket allocation fails but garbage collection would allow it to succeed. Perform a GC pass and try again before giving up, similar to the logic elsewhere in MicroPython that tries a GC pass before raising MemoryError. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-20esp32/modsocket: Implement socket connect timeout.Angus Gratton
LWIP doesn't implement a timeout for blocking connect(), and such a timeout is not required by POSIX. However, CPython will use the socket timeout for blocking connect on most platforms. The "principle of least surprise" suggests we should support it on ESP32 as well (not to mention it's useful!). This provides the additional improvement that external exceptions (like KeyboardInterrupt) are now handled immediately if they happen during connect(). Previously Ctrl-C would not terminate a blocking connect until connect() returned, but now it will. Fixes issue #8326. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-17renesas-ra/boards/ARDUINO_PORTENTA_C33: Fix incorrect I2C pins.Sebastian Romero
Also change the number of the interface to 0 as it's connected to IIC0. Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
2023-11-17ports: Fix incorrect identifiers on Arduino boards.Sebastian Romero
This commit changes the Arduino board identifiers to correspond to their official names. This helps to identify boards at runtime. At the moment the Arduino Portenta H7 is reported as PORTENTA which is unfortunate as now there is another Portenta board (Portenta C33) supported in MicroPython. Also made the other identifiers for flash and network name consistent, removed the incorrectly used MICROPY_PY_SYS_PLATFORM identifiers, and added missing MICROPY_PY_NETWORK_HOSTNAME_DEFAULT identifiers. Boards affected: - stm32: ARDUINO_PORTENTA_H7, ARDUINO_GIGA, ARDUINO_NICLA_VISION - renesas-ra: ARDUINO_PORTENTA_C33 - esp32: ARDUINO_NANO_ESP32 - rp2: ARDUINO_NANO_RP2040_CONNECT Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
2023-11-17py/obj: Fix mp_obj_is_type compilation with C++.stijn
Fixes issue #12951. Signed-off-by: stijn <stijn@ignitron.net>
2023-11-17stm32/boards/STM32H573I_DK: Enable the SD card.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-11-17stm32/sdcard: Add SD card support for H5 MCUs.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-11-17stm32/boards/NUCLEO_H563ZI: Add new NUCLEO-H563ZI board definition.Rene Straub
Configuration: - Clock is HSE, CPU runs at 250MHz. - REPL on USB and UART connected to the ST-Link interface. - Storage is configured for internal flash memory. - Three LEDs and one user button. - Ethernet is enabled. Signed-off-by: Rene Straub <rene@see5.ch>
2023-11-17stm32/boards/NUCLEO_F446RE: Add UARTs 1, 3 and 4.ThomHPL
Signed-off-by: ThomHPL <thomas.herpoel@gmail.com>
2023-11-17tests/net_hosted/asyncio_loopback.py: Add loopback test.Peter Züger
Signed-off-by: Peter Züger <zueger.peter@icloud.com>
2023-11-17stm32: Add optional lwip loopback support.Peter Züger
MICROPY_PY_LWIP_LOOPBACK must be set at the make level to enable this. Signed-off-by: Peter Züger <zueger.peter@icloud.com>
2023-11-17extmod/extmod.mk: Allow enabling lwip loopback support.Peter Züger
Enabling MICROPY_PY_LWIP_LOOPBACK via make will turn on loopback support. Signed-off-by: Peter Züger <zueger.peter@icloud.com>
2023-11-17stm32/mpu: Enable STM32WB mpu use to support qspi flash.Andrew Leech
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2023-11-16samd: Use unique id for USB serial number.Angus Gratton
Replaces the previous all-zeroes "TODO" serial number. Requires refactoring the low-level unique_id routine out from modmachine.c. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-16shared/tinyusb: Add a helper for hex string conversion.Angus Gratton
Change the rp2 and renesas-ra ports to use the helper function. Saves copy-pasta, at the small cost of one more function call in the firmware (if not using LTO). This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-16samd: Switch to shared TinyUSB implementation.Angus Gratton
Functionality and code size don't really change, but removes port-specific code in favour of shared code. (The MSC implemented in shared/tinyusb depends on some functions in the pico-sdk, so this change doesn't make this available for samd.) This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-10samd/mphalport: Run TinyUSB stack while waiting for CDC input/output.Angus Gratton
See the commit a00c9d56db for a detailed description of the problem, a regression introduced in 26d503298. Same approach here as the linked fix for rp2 (applied unconditionally here as this port only supports USB-CDC for stdin/stdout). Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-09rp2/mphalport: Run TinyUSB stack while waiting for CDC input/output.Damien George
The recent change in bcbdee235719d459a4cd60d51021454fba54cd0f means that TinyUSB can no longer be run from within a soft (or hard) IRQ handler, ie when the scheduler is locked. That means that Python code that calls `print(...)` from within a scheduled function may block indefinitely if the USB CDC buffers are full. This commit fixes that problem by explicitly running the TinyUSB stack when waiting within stdio tx/rx functions. Signed-off-by: Damien George <damien@micropython.org>
2023-11-09shared/tinyusb: Expose mp_usbd_task as a public function.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-11-09extmod/vfs_posix_file: Make standard file objects non-const.stijn
Fixes undefined behavior when calling vfs_posix_file_ioctl with MP_STREAM_CLOSE as request because that casts away the constness and assigns -1 to the object's fd member. Fixes issue #12670. Signed-off-by: stijn <stijn@ignitron.net>
2023-11-09extmod/modbluetooth: Initialise nlr_jump_callback_top for IRQ handlers.Daniël van de Giessen
Similar to 3883f29485fad21105f6f965d56bfec842b8cfbb where this change was implemented for threads: when the Bluetooth IRQ handler is called the thread state is not not zero-initialized and thus we need to manually set this to NULL. Fixes issue #12239. Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2023-11-09stm32/boards/NUCLEO_WL55: Freeze LoRa driver.Jim Mussared
This adds the sync version of the LoRa driver (and the base WL55 driver). Adds +13.6kiB (212.6 -> 226.2). Limit for this board is 232kiB. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-09esp32/esp32_rmt: Add RMT.PULSE_MAX constant.Mark Blakeney
If you have a variable frequency and pulse width, and you want to optimize pulse resolution, then you must do a calculation beforehand to ensure you normalize the array to keep all list values within bound. That calculation requires RMT.source_freq(), RMT.clock_div(), and this 32767 constant. Signed-off-by: Mark Blakeney <mark.blakeney@bullet-systems.net>
2023-11-09esp32/esp32_rmt: Change RMT.source_freq() to class method.Mark Blakeney
To create an esp32.RMT() instance with an optimum (i.e. highest resolution) clock_div is currently awkward because you need to know the source clock frequency to calculate the best clock_div, but unfortunately that is only currently available as an source_freq() method on the instance after you have already created it. So RMT.source_freq() should really be a class method, not an instance method. This change is backwards compatible for existing code because you can still reference that function from an instance, or now also, from the class. Signed-off-by: Mark Blakeney <mark.blakeney@bullet-systems.net>
2023-11-09mimxrt/boards/OLIMEX_RT1010: Adjust the UART pin assignment.robert-hh
Olimex asked for that, getting a UART at the UEXT1 connector as well. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-09CODECONVENTIONS: Update for change from black to ruff format.Andrew Leech
Also add notes on running pre-commit manually. Signed-off-by: Andrew Leech <andrew@alelec.net>
2023-11-09samd: Switch TinyUSB to run via a scheduled task.Angus Gratton
Previously the TinyUSB task was run in the ISR immediately after the interrupt handler. This approach gives very similar performance (no change in CDC throughput tests) but reduces the amount of time spent in the ISR, and allows TinyUSB callbacks to run in thread mode. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-09rp2: Change to use TinyUSB dcd_event_handler hook.Angus Gratton
This change: - Has a small code size reduction. - Should slightly improve overall performance. The old hook code seemed to use between 0.1% and 1.6% of the total CPU time doing no-op calls even when no USB work was required. - USB performance is mostly the same, there is a small increase in latency for some workloads that seems to because sometimes the hook usbd_task() is called at the right time to line up with the next USB host request. This only happened semi-randomly due to the timing of the hook. Improving the wakeup latency by switching rp2 to tickless WFE allows the usbd_task() to run in time for the next USB host request almost always, improving performance and more than offsetting this impact. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-09shared/tinyusb: Schedule TinyUSB task function from dcd_event_handler.Angus Gratton
dcd_event_handler() is called from the IRQ when a new DCD event is queued for processing by the TinyUSB thread mode task. This lets us queue the handler to run immediately when MicroPython resumes. Currently this relies on a linker --wrap hack to work, but a PR has been submitted to TinyUSB to allow the function to be called inline from dcd_event_handler() itself. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-09tools/mpremote: Add ioctl to specify large read buffer size.Andrew Leech
Speeds up importing files from mounted filesystem. Also fix the return code for invalid / unsupported ioctl requests. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2023-11-09extmod/vfs_reader: Add file ioctl to set read buffer size.Andrew Leech
Can be used to speed up importing a file from a vfs based filesystem. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2023-11-08extmod/machine_i2c: Do a fast poll during I2C.scan().Damien George
Fixes issue #12912. Signed-off-by: Damien George <damien@micropython.org>
2023-11-07windows: Use the MicroPython logo as application icon.stijn
Add a .ico file with common icon image size, created from vector-logo-2.png, and embed it into the resulting executable. Signed-off-by: stijn <stijn@ignitron.net>
2023-11-07extmod/machine_adc_block: Factor esp32 ADCBlock bindings to common code.Damien George
This is a code factoring to have the Python bindings in one location, and all the ports use those same bindings. At this stage only esp32 implements this class, so the code for the bindings comes from that port. The documentation is also updated to reflect the esp32's behaviour of ADCBlock.connect(). Signed-off-by: Damien George <damien@micropython.org>