Age | Commit message (Collapse) | Author |
|
And expand the test for `readinto()` to test the difference between trying
to read the requested amount by doing multiple underlying IO calls, and
only doing one call.
Signed-off-by: Damien George <damien@micropython.org>
|
|
On the zephyr port, hard IRQ handlers run with a separate stack on a
different thread, so each call to mp_irq_dispatch() and mp_irq_handler()
has to be wrapped with adjustments to the stack-limit checker.
Move these adjustments into the shared mp_irq_dispatch(), introducing
MICROPY_STACK_SIZE_HARD_IRQ which a port can define to non-zero if it
uses a separate stack for hard IRQ handlers. We only need wrap the hard
dispatch case. This should reduce binary size on zephyr without affecting
other ports.
Signed-off-by: Chris Webb <chris@arachsys.com>
|
|
machine.Timer() has inconsistent behaviour between ports: some run
callbacks in hard IRQ context whereas others schedule them like soft IRQs.
Most ports now support a hard= argument to the machine.Timer constructor
or initialiser to explicitly choose between these behaviours. However,
esp32 does not support hardware interrupts because they are not delivered
to the main thread, so the interrupt handler would need to acquire the GIL.
Raise a ValueError if hard=True is requested for esp32 machine.Timer.
Signed-off-by: Chris Webb <chris@arachsys.com>
|
|
machine.Timer() has inconsistent behaviour between ports: some run
callbacks in hard IRQ context whereas others schedule them like soft IRQs.
As on the rp2 port, add support to the esp8266 port for a hard= argument
to explicitly choose between these, setting the default to False to match
the existing behaviour. Open-code this as we don't link against mpirq.c
so can't use mp_irq_dispatch().
Signed-off-by: Chris Webb <chris@arachsys.com>
|
|
machine.Timer() has inconsistent behaviour between ports: some run
callbacks in hard IRQ context whereas others schedule them like soft IRQs.
As on the rp2 port, add support to the zephyr port for a hard= argument
to explicitly choose between these, setting the default to False to match
the existing behaviour.
Adjust the stack-limit check to use the ISR stack while the callback is
dispatched so that hard IRQ callbacks work, as with machine_pin.c and
machine_i2c_target.c IRQ callbacks.
Signed-off-by: Chris Webb <chris@arachsys.com>
|
|
machine.Timer() has inconsistent behaviour between ports: some run
callbacks in hard IRQ context whereas others schedule them like soft IRQs.
As on the rp2 port, add support to the stm32 port for a hard= argument
to explicitly choose between these, setting the default to True to match
the existing behaviour.
Signed-off-by: Chris Webb <chris@arachsys.com>
|
|
machine.Timer() has inconsistent behaviour between ports: some run
callbacks in hard IRQ context whereas others schedule them like soft IRQs.
As on the rp2 port, add support to the renesas-ra port for a hard= argument
to explicitly choose between these, setting the default to True to match
the existing behaviour.
Signed-off-by: Chris Webb <chris@arachsys.com>
|
|
Now that mp_irq_dispatch() is available to dispatch arbitary hard/soft
callbacks, take advantage of this for rp2 machine.Timer. This should
slightly reduce binary size.
Signed-off-by: Chris Webb <chris@arachsys.com>
|
|
Changes made here for N6 are:
- set RIF security attributes for ADC12
- clock ADC12 at 50MHz (maximum) so it runs at spec (max 5Msamp/sec)
- increase sampling time for standard channels to 46.5 cycles
- calibrate ADC in `adc.c`
- correctly clear ADC_CFGR1_RES bits in `machine_adc.c`
- set preselection register in `machine_adc.c`
Signed-off-by: Damien George <damien@micropython.org>
|
|
Otherwise an error message will pop up at the first instatiation
of the UART object.
Addresses #18122 / #18123.
Signed-off-by: robert-hh <robert@hammelrath.com>
|
|
To clear wakeup interrupt flag, set CWUTF on RTC_SCR instead of RTC_MISR.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
To get worked pyb.RTC and machine.RTC on STM32G0.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
The definition of TIM_ENTRY of TIM4 is incorrect.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
Fixes are:
- Enable VREG before initializing ADC.
- The channel value of internal sensor should convert with
__LL_ADC_CHANNEL_TO_DECIMAL_NB().
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
Fixes are:
- The internal sensors of STM32G0 are connected channel 12, 13, 14.
- Update adc_refcor before reading vbat and tempsensor because reference
values are at VDDA=3.0V.
- The method of initialize of sampling time is different with other MCUs:
STM32G0 should initialize SamplingTimeCommon1/2 first. When reading
value from ADC, ADC_ChannelConfTypeDef.SamplingTime should be specified
SamplingTimeCommon1 or SamplingTimeCommon2. In this patch,
SamplingTimeCommon2 is used for internal sensors and SamplingTimeCommon1
is used for external ADC channels.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
Clock parameter definitions should be in `mpconfigboard.h` and use them at
clock initialization.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
Lines like the following were not handled by `make-stmconst.py`:
#define APBPERIPH_BASE (PERIPH_BASE)
This leads to missing definitions on stm module. For example, `stm.RTC` is
not defined if `RTC_BASE` is defined as
#define RTC_BASE (APBPERIPH_BASE + 0x00002800UL)
because `APBPERIPH_BASE` is not handled as a valid id.
This patch modifies the RegExp so it can handle the above.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
Previously, when running `micropython -m <module>` and the module called
sys.exit(), the registered atexit function was not executed. This was due
to sys.exit() raising a SystemExit exception, which bypassed the atexit
handler. This change fixes the issue so that the atexit function is
properly invoked when exiting via sys.exit().
Additionally, following the pattern in execute_from_lexer(),
mp_hal_set_interrupt_char() and mp_handle_pending() handling were added to
ensure that the atexit function is also executed when the user exits via
Ctrl-C.
Signed-off-by: Mike Wang <mikewang000000@gmail.com>
|
|
After s.close(), s.fileno() now returns -1, matching CPython behavior.
Some code relies on this compatibility, as it allows checking whether
a socket is closed by testing its fileno() value. This change ensures
better interoperability with existing Python code and libraries.
Signed-off-by: Mike Wang <mikewang000000@gmail.com>
|
|
This commit enables generation of Zba opcodes by the native emitter
for the Pico2, as its RISC-V implementation supports both of those
extensions (see section 3.8 of the RP2350 datasheet).
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
This commit enables the usage of the Zba address generation opcodes in
the QEMU port when targeting the "VIRT_RV32" board, which emulates a
generic RV32 target.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
This adds a QEMU-based bare metal RISC-V 64 bits port. For the time being
only QEMU's "virt" 64 bits board is supported, using the lp64 ABI and the
RV64IMC architecture.
The port's README is also updated to keep track of these changes.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
Use constants from the HAL instead of literal numbers to select which
peripheral clocks are enabled during low power mode.
Signed-off-by: Damien George <damien@micropython.org>
|
|
For NUCLEO boards that does not have HSE crystal, HSEState should set
RCC_HSE_BYPASS to use HSE clock from ST-LINK 8MHz.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
UART prescaler value should set up correctly to initialize LPUART with low
baudrate for STM32G0/G4/H5. This can be implemented similarly to
STM32H7/N6/WB.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
|
|
For STM32G4, hardware I2C can implement same as STM32L4 for machine.I2C.
This commit makes to be able to use of hardware I2C in machine.I2C.
Tested on NUCLEO-G474RE.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
For NUCLEO-G474RE, FLASH_LATENCY_4 can be specified instead of
FLASH_LATENCY_8 because it runs at 170MHz.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
For NUCLEO-F401RE, FLASH_LATENCY_2 can be specified for flash latency
because it runs at 84MHz.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
|
|
These are convenience targets for running specific tests as a developer.
They are more useful that invoking run-tests directly as they take account
of the VARIANT= specified on the make command-line.
For instance, you can run all tests matching the regular expression "int"
with `make VARIANT=... test//int`.
The new targets are all documented in README.md.
Signed-off-by: Jeff Epler <jepler@gmail.com>
|
|
MP_OBJ_SMALL_INT_VALUE would give erroneous results, such as assertion
failures in the coverage build and other oddities like:
>>> s = socket.socket()
>>> s.recv(3.14)
MemoryError: memory allocation failed, allocating 4235896656 bytes
Signed-off-by: Jeff Epler <jepler@gmail.com>
|
|
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
|
|
Python 2.7 has been EOL since January 2020.
Ubuntu oldoldlts (Focal Fossa, 20.04) has Python 3.8. Debian oldoldstable
(Buster, from 2019) has Python 3.7. RHEL 8 (from 2019) has Python 3.6.
It's easier than ever to install a modern Python using uv.
Given this, it seems like a fine idea to drop Python 2.7 support.
Even though the build is not tested on Python as old as 3.3, I left
comments stating that "3.3+" is the baseline Python version. However, it
might make sense to bump this to e.g., 3.10, the oldest Python 3 version
used during CI. Or, using uv or another method actually test on the oldest
Python interpreter that is desirable to support (uv goes back to Python 3.7
easily; in October 2025, the oldest supported Python interpreter version
will be 3.10)
Signed-off-by: Jeff Epler <jepler@gmail.com>
|
|
The margin of 64 bytes is needed to get `micropython/extreme_exc.py` to
pass when run via-mpy.
Signed-off-by: Damien George <damien@micropython.org>
|
|
Avoiding the double timeout when used with the UART class.
`stream.readinto1()` returns after the first timeout.
Fixes issue #17611.
Signed-off-by: robert-hh <robert@hammelrath.com>
|
|
Before, it was ignored. Tested with ESP32, ESP32S3, ESP32C6.
Signed-off-by: robert-hh <robert@hammelrath.com>
|
|
Do not try to read/write again after timeout happened once.
Fixes issue #17611.
Signed-off-by: robert-hh <robert@hammelrath.com>
|
|
The calls signature for gc_malloc was changed in
5ed578e5b48730606536ded9a711223ae9a70262, without cleaning up existing
code on the rationale that the previous bool is automatically converted
to an int with the same meaning.
This commit goes back and cleans up existing invocations to make their
behavior more readable in a modern context.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
|
|
Makes machine.UART objects static instances (similar to other ports), adds
machine_uart_deinit_all() function for cleanup on soft reset.
- Fixes the case where the OS-level uart_event_task is leaked
(along with 2KB of heap) when a UART object is garbage collected
(including after a soft reset).
- Fixes hard fault if a previous UART irq() fires after the UART object is
garbage collected (including after a soft reset), but before any new UART
object is instantiated for the same UART number.
- Constructing multiple UART objects for the same UART now returns the
same instance multiple times, not different instances.
- Was also able to streamline deinit/init to only install the driver once,
rather than install-with-defaults/uninstall/reinstall.
Alternative would be to add a finaliser, but this is more consistent
with how most other UART objects are implemented.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
This is recommended by Espressif, and it's the only way to ensure
everyone builds the same set of component versions.
The awkward part is that updating the ESP-IDF version will churn a line
in each of these files (and possibly other changes).
Adds a build-time check for lock file changes, which is either a warning or
a hard error depending on the value of MICROPY_MAINTAINER_BUILD
flag (introduced in previous commit).
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
Reported to fix issues reported with serial corruption when interacting
with MicroPython from macOS hosts.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
This commit fixes the build issues in the ESP32 port that arise when
explicitly disabling USB CDC support.
The USB support code gated the USB serial number retrieval behind the
USB CDC support definition, even though all USB devices must be able to
be queried for their serial number.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
This commit fixes the build issues in the SAMD port that arise when
explicitly disabling USB CDC support.
The console code assumed CDC support is always enabled even if it was
disabled in mpconfigport.h. These changes make accessing CDC
conditional to that support configuration being enabled.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
This commit fixes the build issues in the MIMXRT port that arise when
explicitly disabling USB CDC support.
The console code assumed CDC support is always enabled even if it was
disabled in mpconfigport.h. These changes make accessing CDC
conditional to that support configuration being enabled.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
This commit fixes the linking issues in the RP2 port that arise when
explicitly disabling USB CDC support.
The console input ringbuffer needs to be made available if dupterm
support is enabled, and the console character input function would
always attempt to read from the input ringbuffer even if CDC support is
disabled and the console isn't bound to any UART.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
A fast host (eg Mac M4) may request the status for the SET_ADDRESS before
TinyUSB gets to process it. This is because TinyUSB does not handle events
inside the USB ISR, rather it waits for the top-level thread to process
them. Fix that by setting the USB device address as soon as
TUSB_REQ_SET_ADDRESS comes in.
This patch follows the corresponding upstream fix:
https://github.com/alifsemi/tinyusb/commit/fc40ea7fc6e6bd49baad6b504c88bb6a37c7a191
Signed-off-by: Damien George <damien@micropython.org>
|
|
This is, eg, `ZEPHYR_NUCLEO_WB55RG`.
Signed-off-by: Damien George <damien@micropython.org>
|
|
As required by the datasheet.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
|
|
STM32L4 uses the same I2C controller as STM32WB. Change `defined(STM32WB)`
to `defined(STM32L4) || defined(STM32WB) ` in relevant files.
Also remove the dummy definition of I2C2_BASE for STM32L432xx. It's now
provided by the dummy definition in `i2cslave.h`.
Signed-off-by: Chris Mason <c.mason@inchipdesign.com.au>
Signed-off-by: Damien George <damien@micropython.org>
|
|
This is intended to be equivalent to the unlock in
shared/runtime/pyexec.c.
Signed-off-by: Jeff Epler <jepler@gmail.com>
|