aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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>
2023-11-07py/qstr: Special case qstr_find_strn for empty string.Jim Mussared
This handles the case where an empty bytes/bytearray/str could pass in NULL as the str argument (with length zero). This would result in UB in strncmp. Even though our bare-metal implementation of strncmp handles this, best to avoid it for when we're using system strncmp. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-07shared/libc/string0: Don't deref args for n==0 case.Jim Mussared
C99 says that strncmp has UB for either string being NULL, so the current behavior is technically correct, but it's an easy fix to handle this case correctly. 7.1.4: "unless explicitly stated otherwise in the detailed description... if an argument to a function has ...null pointer.. the behavior is undeļ¬ned". 7.21.1: "Unless explicitly stated otherwise in the description of a particular function in this subclause, pointer arguments on such a call shall still have valid values, as described in 7.1.4". Also make the same change for the minimal version in bare-arm/lib.c. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-07tools/tinytest-codegen.py: Externalise tests list.Alessandro Gatti
Remove port-specific test directories and excluded tests from tinytest-codegen, and let it read said information from an external file. This way tinytest-codegen is not limited to always generate tests for the `qemu-arm` target. This allows having port-specific test directory and excluded tests for more than one QEMU bare-metal target. The `qemu-arm` port Makefile was modified to work with the generator changes and a tests profile file was added to said port. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2023-11-06samd/pin_af: Fix a typo in a conditional compile.robert-hh
Thanks to @ricksorensen for finding it. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-06samd/machine_uart: Add machine_uart_set_baudrate() function.robert-hh
Changing the baudrate requires a complete re-configuration of the Sercom device, which is put into a separate rather large function. This new machine_uart_set_baudrate() function will be useful for future drivers such as Bluetooth. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-06samd/mpconfigport: Set MICROPY_USE_INTERNAL_ERRNO to 1.robert-hh
Without this, error codes can be misleading. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-06docs/samd: Fix the pinout for SAMD21 Itsy Bitsy Express M0.robert-hh
And the "Pin", "GPIO" and "Name" key explanations. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-05stm32/boards/make-pins.py: Only support ADC1-3.Jim Mussared
e.g. The STM32G4 includes ADC4 & ADC5 which is not currently supported by the stm32 driver. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-05docs/mimxrt: Change the examples which denote a Pin with a number.robert-hh
This option was removed in PR #12211. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-05mimxrt/modmachine: Fix settings for the MIMXRT1170 board.robert-hh
These were not changed with commit c0b64a3f2 for using tools/boardgen.py. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-04stm32/boards/stm32g474_af.csv: Fix final row ADC column.Jim Mussared
The original file was missing a trailing , on the final row. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-04stm32/boards/stm32f4x9_af.csv: Fix DCMI_VSYNC.Jim Mussared
This incorrectly had a `(1)` on the end. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03stm32/boards/make-pins.py: Fix H7 ADC generation.Jim Mussared
Fixes are: - Only emit ADC table entries for pins that aren't cpu-hidden (i.e. ignore `X,-Y` rows). - Only use the P channels on H7. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03rp2: Remove 1ms timeout to make idle waiting tickless.Angus Gratton
The main motivation for doing this was to reduce the latency when the system is woken by a USB interrupt. The best_effort_wfe_or_timeout() function calls into the pico-sdk dynamic timer framework which sets up a new dynamic timer instance each time, and then has to tear it down before continuing after a WFE. Testing Python interrupt latency, it seems to be improved by about 12us (from average of 46us to 34us running a Pin IRQ). C-based "scheduled nodes" should see even lower latency. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-03rp2/machine_adc: Refactor channel/pin validation code.iabdalkader
This patch ensures that integer channel numbers passed to the ADC constructor (including temperature sensor) are interpreted as raw channel numbers, and not cause any GPIO pins to be initialized. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-11-03rp2/machine_uart: Fix handling of serial break condition.Maarten van der Schrieck
The FIFO reports not only the bytes read, but also 4 error bits. These were not checked, leading to NUL value read in case of break and possible garbage bytes being written on parity/framing error. This patch addresses the issue that NUL bytes are incorrectly read on break, and at least provides the boilerplate code and comments for error handling, that may be implemented in the future. Signed-off-by: Maarten van der Schrieck <maarten@thingsconnected.nl>
2023-11-03stm32: Add STM32H5 support for sleep mode.Rene Straub
Update rtc, machine and powerctrl drivers to support STM32H5 sleep modes. This makes RTC alarm wakeup working from lightsleep() and deepsleep(). Changes: - Determine start reason for machine.reset_cause() in modmachine.c. - Add proper interrupt clear code in rtc.c. - Add wakeup functionality in powerctrl_enter_stop_mode(). Remember and restore voltage scaling level. Restart HSI48 if it was on before entering sleep mode. - Clear DBGMCU_CR in SystemClock_Config() as for other variants. Otherwise debug flags prevent entering sleep mode. Implementation Notes: - rtc.c: EXTI_RTSTR1 bits are not present for H5. Code sequence from G0/G4/L4/WB/WL would be invalid. RTSTR is only defined for external (GPIO) interrupts. Maybe this is also true for other STM32 variants. - powerctrl_enter_stop_mode() uses complicated, nested conditionals to select STM32 variants. To make code slightly better readable, comment have been added. A non-nested, #if/#elif sequence would make the code more readable. I leave this to the original authors. Signed-off-by: Rene Straub <rene@see5.ch>
2023-11-03stm32: Add configuration options for analog switches.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-11-03py/misc: Change sizeof to offsetof for variable-length alloc.Jim Mussared
This fixes the case where e.g. struct foo_t { mp_obj_t x; uint16_t y; char buf[]; }; will have `sizeof(struct foo_t)==8`, but `offsetof(struct foo_t, buf)==6`. When computing the size to allocate for `m_new_obj_var` we need to use offsetof to avoid over-allocating. This is important especially when it might cause it to spill over into another GC block. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03py/lexer: Change token position for new lines.Mathieu Serandour
Set the position of new line tokens as the end of the preceding line instead of the beginning of the next line. This is done by first moving the pointer to the end of the current line to skip any whitespace, record the position for the token, then finaly skip any other line and whitespace. The previous behavior was to skip every new line and whitespace, including the indent of the next line, before recording the token position. (Note that both lex->emit_dent and lex->nested_bracket_level equal 0 if had_physical_newline == true, which allows simplifying the if-logic for MP_TOKEN_NEWLINE.) And update the cmd_parsetree.py test expected output, because the position of the new-line token has changed. Fixes issue #12792. Signed-off-by: Mathieu Serandour <mathieu.serandour@numworks.fr>
2023-11-03py/runtime: Remove declaration of function from inside function.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-11-03{cc3200,nrf}/boards/make-pins.py: Add a note about tools/boardgen.py.Jim Mussared
It's not worth the effort to update these ports to use boardgen.py, but put a note just in case anyone uses this as a reference for a new port. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03renesas-ra/boards/make-pins.py: Update to use tools/boardgen.py.Jim Mussared
This removes previously unused functionality to generate pins_ad_const.h, as well as the unused handling of pin AF in machine_pin.c. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03mimxrt/boards/make-pins.py: Update to use tools/boardgen.py.Jim Mussared
Minor change to remove support for using numeric IDs for machine.Pin. This was previously based on the index of the pin in the board csv, but this is different (and incompatible) with other ports. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03samd/boards/make-pins.py: Update to use tools/boardgen.py.Jim Mussared
This replaces the previous make-pin-table.py with an implementation based on boardgen.py. - MICROPY_PY_MACHINE_PIN_BOARD_CPU macro is removed. This isn't optional on other ports, so no need for it to be optional on SAMD. - pin_af_table is removed, and lookups just search the cpu dict instead (this saves N*wordsize bytes of firmware size to have this extra table). - pins.csv is now BOARD,CPU to match other ports. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03stm32/boards/make-pins.py: Add initial support for H7 dual-pad pins.Jim Mussared
This fixes the H7 af.csv files to include the dual-pad information, by listing the ADCs supported on the _C pad with a C_ADC prefix. Minimal change to make-pins.py to ignore these entries. This will be implemented later to emit constants (similar to ADC.CORE_TEMP) to access these channels. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03stm32/boards/make-pins.py: Update to use tools/boardgen.py.Jim Mussared
Requires additions to tools/boardgen.py for stm32 pin generation. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03stm32: Rename pin_obj_t to machine_pin_obj_t.Jim Mussared
This is now consistent with other ports. Also renamed `pin_{board/cpu}_pins_locals_dict` to `machine_pin_{board/cpu}_pins_locals_dict`. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03stm32/boards: Format stm32 alternate function csv files.Jim Mussared
Changes are: - Pad all cells to make them easier to read. - Ensure all files have exactly 19 columns (Port,Pin,AF0-15,ADC) This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03stm32/boards: Fix errors in pins.csv and af.csv.Jim Mussared
Fixes are: - Comment out lines in pins.csv that do not have valid CPU pins. It's useful to keep these in the file as "documentation" but in order to make make-pins.py stricter they need to be commented out. - Fix some typos (missing P prefix) in pins.csv. This resulted in some missing board pins. - Fix some typos in af.csv files. Some typos of "ADC" and some other that were previously ignored. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03tools/boardgen.py: Add initial implementation of a common make-pins.py.Jim Mussared
For now, this implements the functionality required for esp32 and rp2, including support for numeric pins, rp2 alternate functions, and rp2 extended pins. This also updates the rp2 port to use the same structure for pins.h and pins.csv as for esp32, and moves the pin definitions directly into the table (rather than having a table of pointers), which is a small code size improvement. Support for "hidden" pins in pins.csv is added (matching the stm32 implementation). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03esp32/machine_pin: Make irq object a sub-field of pin object.Jim Mussared
This simplifies pin generation. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03ports: Standardise arguments and output for make-pins.py script.Jim Mussared
All ports now use `--board-csv`, `--prefix`, `--output-souce`, `--output-header` and no longer write to stdout. This matches the esp32 implementation. Ports that have an AF input use `--af-csv` (to match `--board-csv`). Any additional output files are now prefixed with `output-` (e.g. `--output-af-const`). Default arguments are removed (all makefiles should always specify all arguments, using default values is likely an error). Replaced the `af-defs-cmp-strings` and `hdr-obj-decls` args for stm32 with just `mboot-mode`. Previously they were set on the regular build, now the logic is reversed so mboot sets it. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03ports: Remove SRC_QSTR_AUTO_DEPS from all ports' Makefiles.Jim Mussared
It's unused. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03examples/pins.py: Remove this pins printing example.Jim Mussared
It's not supported on all ports, adds complexity to the build to generate pins_af.py, and can mostly be replicated just by printing the pin objects. Remove support for generating pins_af.py from all ports (nrf, stm32, renesas-ra, mimxrt, rp2). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03cc3200/boards/make-pins.py: Don't generate qstrs.Jim Mussared
The output pins.c can be processed for qstrs like any other C file. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03renesas-ra/boards/make-pins.py: Don't generate qstrs.Jim Mussared
The output pins.c can be processed for qstrs like any other C file. Also remove af_const from Makefile (unimplemented in make-pins.py) and fix target dependency on ad_const. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03nrf/boards/make-pins.py: Don't generate qstrs.Jim Mussared
The output pins.c can be processed for qstrs like any other C file. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03stm32/boards/make-pins.py: Don't generate qstrs.Jim Mussared
Qstrs are picked up from the generated pin source files in the usual qstr processing stage. Similarly for the stm constant qstrs. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03rp2/boards/make-pins.py: Don't generate qstrs.Jim Mussared
Also remove af-const header, as this is left over from the STM32 version and unused. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03py/mkrules.mk: Add rule for compiling auto-generated source files.Jim Mussared
This prevents each port Makefile from having to add an explicit rule for `build-BOARD/pins_BOARD.c`. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>