Skip to content

Commit 77e885b

Browse files
authored
Merge branch 'micropython:master' into esp32_bitstream
2 parents 2b119c8 + e3ef682 commit 77e885b

File tree

89 files changed

+1066
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1066
-388
lines changed

.github/workflows/ports_esp32.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
- 'lib/**'
1313
- 'drivers/**'
1414
- 'ports/esp32/**'
15+
schedule:
16+
# Scheduled run exists to keep master branch ESP-IDF cache entry hot
17+
# and prevent creating many redundant per-branch cache entries instead.
18+
- cron: "20 0 * * *"
1519

1620
concurrency:
1721
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/ports_unix.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,20 @@ jobs:
217217
if: failure()
218218
run: tests/run-tests.py --print-failures
219219

220+
repr_b:
221+
runs-on: ubuntu-22.04 # use 22.04 to get libffi-dev:i386
222+
steps:
223+
- uses: actions/checkout@v5
224+
- name: Install packages
225+
run: source tools/ci.sh && ci_unix_32bit_setup
226+
- name: Build
227+
run: source tools/ci.sh && ci_unix_repr_b_build
228+
- name: Run main test suite
229+
run: source tools/ci.sh && ci_unix_repr_b_run_tests
230+
- name: Print failures
231+
if: failure()
232+
run: tests/run-tests.py --print-failures
233+
220234
macos:
221235
runs-on: macos-latest
222236
steps:

.github/workflows/ports_windows.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ jobs:
2929
include:
3030
- visualstudio: '2017'
3131
vs_version: '[15, 16)'
32+
custom_vs_install: true
3233
- visualstudio: '2019'
3334
vs_version: '[16, 17)'
35+
custom_vs_install: true
3436
- visualstudio: '2022'
3537
vs_version: '[17, 18)'
3638
# trim down the number of jobs in the matrix
@@ -43,18 +45,17 @@ jobs:
4345
env:
4446
CI_BUILD_CONFIGURATION: ${{ matrix.configuration }}
4547
steps:
46-
- name: Install Visual Studio 2017
47-
if: matrix.visualstudio == '2017'
48+
- name: Install Visual Studio ${{ matrix.visualstudio }}
49+
if: matrix.custom_vs_install
50+
shell: bash
51+
# Shell functions in this block are to retry intermittent corrupt
52+
# downloads (with a clean download dir) before failing the job outright
4853
run: |
49-
choco install visualstudio2017buildtools
50-
choco install visualstudio2017-workload-vctools
51-
choco install windows-sdk-8.1
52-
- name: Install Visual Studio 2019
53-
if: matrix.visualstudio == '2019'
54-
run: |
55-
choco install visualstudio2019buildtools
56-
choco install visualstudio2019-workload-vctools
57-
choco install windows-sdk-8.1
54+
try () { ($@) || ($@) || ($@) || ($@) }
55+
clean_install () ( rm -rf $TEMP/chocolatey; choco install $1 )
56+
try clean_install visualstudio${{ matrix.visualstudio }}buildtools
57+
try clean_install visualstudio${{ matrix.visualstudio }}-workload-vctools
58+
try clean_install windows-sdk-8.1
5859
- uses: microsoft/setup-msbuild@v2
5960
with:
6061
vs-version: ${{ matrix.vs_version }}

.github/workflows/ports_zephyr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
- 'lib/**'
1313
- 'ports/zephyr/**'
1414
- 'tests/**'
15+
schedule:
16+
# Scheduled run exists to keep master branch Zephyr cache entry hot
17+
# and prevent creating many redundant per-branch cache entries instead.
18+
- cron: "40 4 * * *"
1519

1620
concurrency:
1721
group: ${{ github.workflow }}-${{ github.ref }}

docs/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ Building the documentation locally
1313
If you're making changes to the documentation, you may want to build the
1414
documentation locally so that you can preview your changes.
1515

16-
Install Sphinx, and optionally (for the RTD-styling), sphinx_rtd_theme,
17-
preferably in a virtualenv:
16+
Install Sphinx and sphinx_rtd_theme, preferably in a virtualenv:
1817

1918
pip install sphinx
2019
pip install sphinx_rtd_theme
@@ -25,6 +24,21 @@ In `micropython/docs`, build the docs:
2524

2625
You'll find the index page at `micropython/docs/build/html/index.html`.
2726

27+
Documentation autobuild
28+
-----------------------
29+
30+
For a more convenient development experience, you can use `sphinx-autobuild`
31+
to automatically rebuild and serve the documentation when you make changes:
32+
33+
pip install sphinx-autobuild
34+
35+
Then run from the `micropython/docs` directory:
36+
37+
sphinx-autobuild . build/html
38+
39+
This will start a local web server (typically at `http://127.0.0.1:8000`)
40+
and automatically rebuild the documentation whenever you save changes to the source files.
41+
2842
Having readthedocs.org build the documentation
2943
----------------------------------------------
3044

docs/develop/gettingstarted.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,34 @@ To run a selection of tests on a board/device connected over USB use:
282282
283283
See also :ref:`writingtests`.
284284

285+
Additional make targets for developers
286+
--------------------------------------
287+
288+
In all ``make``-based ports, there is a target to print the size of a specific object file.
289+
When a change is confined to a single file, this is useful when testing variations to find smaller alternatives.
290+
291+
For instance, to print the size of ``objstr.o`` in the ``py/`` directory when making a unix standard build:
292+
293+
.. code-block:: bash
294+
295+
$ make build-standard/py/objstr.sz
296+
297+
Similarly, there is a target to save the preprocessed version of a file:
298+
299+
.. code-block:: bash
300+
301+
$ make build-standard/py/objstr.pp
302+
303+
In ``ports/unix`` there are additional targets related to running tests:
304+
305+
.. code-block:: bash
306+
307+
$ make test//int # Run all tests matching the pattern "int"
308+
$ make test/ports/unix # Run all tests in ports/unix
309+
$ make test-failures # Re-run only the failed tests
310+
$ make print-failures # print the differences for failed tests
311+
$ make clean-failures # delete the .exp and .out files from failed tests
312+
285313
Using ci.sh locally
286314
-------------------
287315

@@ -306,6 +334,22 @@ As an example, you can build and test the unix minimal port with:
306334
307335
$ tools/ci.sh unix_minimal_build unix_minimal_run_tests
308336
337+
If you use the bash shell, you can add a ``ci`` command with tab completion:
338+
339+
.. code-block:: bash
340+
341+
$ eval `tools/ci.sh --bash-completion`
342+
$ ci unix_cov<tab>
343+
344+
This will complete the ci step name to ``unix_coverage_``.
345+
Pressing tab a second time will show the list of matching steps:
346+
347+
.. code-block:: bash
348+
349+
$ ci unix_coverage_<tab>
350+
unix_coverage_32bit_build
351+
unix_coverage_32bit_run_native_mpy_tests…
352+
309353
Folder structure
310354
----------------
311355

docs/esp32/quickref.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ with a timer ID of 0, 0 and 1, or from 0 to 3 (inclusive)::
287287
The period is in milliseconds. When using UART.IRQ_RXIDLE, timer 0 is needed for
288288
the IRQ_RXIDLE mechanism and must not be used otherwise.
289289

290+
Timer callbacks are scheduled as soft interrupts on this port; hard
291+
callbacks are not implemented. Specifying ``hard=True`` will raise
292+
a ValueError.
293+
290294
Virtual timers are not currently supported on this port.
291295

292296
.. _Pins_and_GPIO:

docs/esp8266/quickref.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ with timer ID of -1::
108108

109109
The period is in milliseconds.
110110

111+
By default, timer callbacks are scheduled as soft interrupts on this port.
112+
Specify ``hard=True`` to run them in hard interrupt context instead.
113+
111114
Pins and GPIO
112115
-------------
113116

docs/library/machine.Timer.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ Timer callbacks.
1818

1919
Memory can't be allocated inside irq handlers (an interrupt) and so
2020
exceptions raised within a handler don't give much information. See
21-
:func:`micropython.alloc_emergency_exception_buf` for how to get around this
22-
limitation.
21+
:func:`micropython.alloc_emergency_exception_buf` for how to get around
22+
this limitation, which applies to all callbacks of Timers created with
23+
``hard=True``.
2324

2425
If you are using a WiPy board please refer to :ref:`machine.TimerWiPy <machine.TimerWiPy>`
2526
instead of this class.
@@ -38,7 +39,7 @@ Constructors
3839
Methods
3940
-------
4041

41-
.. method:: Timer.init(*, mode=Timer.PERIODIC, freq=-1, period=-1, callback=None)
42+
.. method:: Timer.init(*, mode=Timer.PERIODIC, freq=-1, period=-1, callback=None, hard=True)
4243

4344
Initialise the timer. Example::
4445

@@ -76,6 +77,19 @@ Methods
7677
will occur upon timer expiration:
7778
``TypeError: 'NoneType' object isn't callable``
7879

80+
- ``hard`` can be one of:
81+
82+
- ``True`` - The callback will be executed in hard interrupt
83+
context, which minimises delay and jitter but is subject to the
84+
limitations described in :ref:`isr_rules` including being unable
85+
to allocate on the heap.
86+
- ``False`` - The callback will be scheduled as a soft interrupt,
87+
allowing it to allocate but possibly also introducing
88+
garbage-collection delays and jitter.
89+
90+
The default value of this option is port-specific for historical
91+
reasons.
92+
7993
.. method:: Timer.deinit()
8094

8195
Deinitialises the timer. Stops the timer, and disables the timer peripheral.

docs/library/os.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,37 @@ Terminal redirection and duplication
133133

134134
The function returns the previous stream-like object in the given slot.
135135

136+
.. function:: dupterm_notify(obj_in, /)
137+
138+
Notify the MicroPython REPL that input is available on a stream-like object
139+
previously registered via `os.dupterm()`.
140+
141+
This function should be called by custom stream implementations (e.g., UART,
142+
Bluetooth, or other non-USB REPL streams) to inform the REPL that input is
143+
ready to be read. Proper use ensures that special characters such as
144+
Ctrl+C (used to trigger KeyboardInterrupt) are processed promptly by the
145+
REPL, enabling expected interruption behavior for user code.
146+
147+
The *obj_in* parameter is ignored by `os.dupterm_notify()`, but is required to allow calling
148+
dupterm_notify from an interrupt handler such as `UART.irq()`.
149+
150+
Example:
151+
152+
.. code-block:: python
153+
154+
from machine import UART
155+
import os
156+
uart = UART(0)
157+
os.dupterm(uart, 0)
158+
uart.irq(os.dupterm_notify, machine.UART.IRQ_RX)
159+
160+
.. note::
161+
If the ``dupterm_notify()`` function is not called, input from the custom stream
162+
may not be detected or processed until the next REPL poll, potentially delaying
163+
KeyboardInterrupts or other control signals.
164+
This is especially important for UART, Bluetooth and other
165+
non-standard REPL connections, where automatic notification is not guaranteed.
166+
136167
Filesystem mounting
137168
-------------------
138169

0 commit comments

Comments
 (0)