Skip to content

Commit 168c40e

Browse files
authored
Merge pull request #8508 from dhalbert/v1.21-merge
V1.21 merge
2 parents e3873c1 + ecaf9e6 commit 168c40e

File tree

540 files changed

+8463
-3798
lines changed

Some content is hidden

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

540 files changed

+8463
-3798
lines changed

.git-blame-ignore-revs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# all: Fix various spelling mistakes found by codespell 2.2.6.
2+
cf490a70917a1b2d38ba9b58e763e0837d0f7ca7
3+
4+
# all: Fix spelling mistakes based on codespell check.
5+
b1229efbd1509654dec6053865ab828d769e29db
6+
17
# top: Update Python formatting to black "2023 stable style".
28
8b2748269244304854b3462cb8902952b4dcb892
39

.github/workflows/run-tests.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ jobs:
5757
run: |
5858
make -C examples/natmod/features1
5959
make -C examples/natmod/features2
60-
make -C examples/natmod/uheapq
61-
make -C examples/natmod/urandom
62-
make -C examples/natmod/ure
63-
make -C examples/natmod/uzlib
60+
make -C examples/natmod/heapq
61+
make -C examples/natmod/random
62+
make -C examples/natmod/re
6463
- name: Test native modules
6564
if: matrix.test == 'all'
66-
run: ./run-natmodtests.py extmod/{uheapq*,ure*,uzlib*}.py
65+
run: ./run-natmodtests.py extmod/{heapq*,re*,zlib*}.py
6766
working-directory: tests

docs/library/gc.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Functions
2424

2525
.. function:: mem_alloc()
2626

27-
Return the number of bytes of heap RAM that are allocated.
27+
Return the number of bytes of heap RAM that are allocated by Python code.
2828

2929
.. admonition:: Difference to CPython
3030
:class: attention
@@ -33,8 +33,8 @@ Functions
3333

3434
.. function:: mem_free()
3535

36-
Return the number of bytes of available heap RAM, or -1 if this amount
37-
is not known.
36+
Return the number of bytes of heap RAM that is available for Python
37+
code to allocate, or -1 if this amount is not known.
3838

3939
.. admonition:: Difference to CPython
4040
:class: attention

docs/library/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limited flash memory:
1717
``binascii``, ``errno``, ``json``, ``re``.
1818

1919
These libraries are not currently enabled in any CircuitPython build, but may be in the future:
20-
``ctypes``
20+
``ctypes``, ``platform``
2121

2222
.. toctree::
2323
:maxdepth: 1
@@ -31,6 +31,7 @@ These libraries are not currently enabled in any CircuitPython build, but may be
3131
gc.rst
3232
io.rst
3333
json.rst
34+
platform.rst
3435
re.rst
3536
sys.rst
3637
ctypes.rst

docs/library/platform.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
:mod:`platform` -- access to underlying platform’s identifying data
2+
===================================================================
3+
4+
.. module:: platform
5+
:synopsis: access to underlying platform’s identifying data
6+
7+
|see_cpython_module| :mod:`python:platform`.
8+
9+
This module tries to retrieve as much platform-identifying data as possible. It
10+
makes this information available via function APIs.
11+
12+
Functions
13+
---------
14+
15+
.. function:: platform()
16+
17+
Returns a string identifying the underlying platform. This string is composed
18+
of several substrings in the following order, delimited by dashes (``-``):
19+
20+
- the name of the platform system (e.g. Unix, Windows or MicroPython)
21+
- the MicroPython version
22+
- the architecture of the platform
23+
- the version of the underlying platform
24+
- the concatenation of the name of the libc that MicroPython is linked to
25+
and its corresponding version.
26+
27+
For example, this could be
28+
``"MicroPython-1.20.0-xtensa-IDFv4.2.4-with-newlib3.0.0"``.
29+
30+
.. function:: python_compiler()
31+
32+
Returns a string identifying the compiler used for compiling MicroPython.
33+
34+
.. function:: libc_ver()
35+
36+
Returns a tuple of strings *(lib, version)*, where *lib* is the name of the
37+
libc that MicroPython is linked to, and *version* the corresponding version
38+
of this libc.

docs/library/sys.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Constants
3333

3434
* *name* - string "circuitpython"
3535
* *version* - tuple (major, minor, micro), e.g. (1, 7, 0)
36+
* *_machine* - string describing the underlying machine
3637
* *_mpy* - supported mpy file-format version (optional attribute)
3738

3839
This object is the recommended way to distinguish CircuitPython from other

docs/reference/glossary.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Glossary
3232

3333
callee-owned tuple
3434
This is a MicroPython-specific construct where, for efficiency
35-
reasons, some built-in functions or methods may re-use the same
35+
reasons, some built-in functions or methods may reuse the same
3636
underlying tuple object to return data. This avoids having to allocate
3737
a new tuple for every call, and reduces heap fragmentation. Programs
3838
should not hold references to callee-owned tuples and instead only
@@ -120,7 +120,7 @@ Glossary
120120
<https://github.com/micropython/micropython-lib>`_ which provides
121121
implementations for many modules from CPython's standard library.
122122

123-
Some of the modules are are implemented in pure Python, and are able to
123+
Some of the modules are implemented in pure Python, and are able to
124124
be used on all ports. However, the majority of these modules use
125125
:term:`FFI` to access operating system functionality, and as such can
126126
only be used on the :term:`MicroPython Unix port` (with limited support

docs/shared_bindings_matrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
}
6464

6565
ADDITIONAL_MODULES = {
66-
"_asyncio": "MICROPY_PY_UASYNCIO",
66+
"_asyncio": "MICROPY_PY_ASYNCIO",
6767
"adafruit_bus_device": "CIRCUITPY_BUSDEVICE",
6868
"adafruit_pixelbuf": "CIRCUITPY_PIXELBUF",
6969
"array": "CIRCUITPY_ARRAY",
@@ -79,7 +79,7 @@
7979
"keypad.Keys": "CIRCUITPY_KEYPAD_KEYS",
8080
"keypad.ShiftRegisterKeys": "CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS",
8181
"os.getenv": "CIRCUITPY_OS_GETENV",
82-
"select": "MICROPY_PY_USELECT_SELECT",
82+
"select": "MICROPY_PY_SELECT_SELECT",
8383
"sys": "CIRCUITPY_SYS",
8484
"terminalio": "CIRCUITPY_DISPLAYIO",
8585
"usb": "CIRCUITPY_USB_HOST",

examples/natmod/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Dynamic Native Modules
2+
3+
Dynamic Native Modules are .mpy files that contain native machine code from a
4+
language other than Python. For more info see [the documentation]
5+
(https://docs.micropython.org/en/latest/develop/natmod.html).
6+
7+
This should not be confused with [User C Modules]
8+
(https://docs.micropython.org/en/latest/develop/cmodules.html) which are a
9+
mechanism to add additional out-of-tree modules into the firmware build.
10+
11+
## Examples
12+
13+
This directory contains several examples of writing dynamic native modules, in
14+
two main categories:
15+
16+
1. Feature examples.
17+
18+
* `features0` - A module containing a single "factorial" function which
19+
demonstrates working with integers.
20+
21+
* `features1` - A module that demonstrates some common tasks:
22+
- defining simple functions exposed to Python
23+
- defining local, helper C functions
24+
- defining constant integers and strings exposed to Python
25+
- getting and creating integer objects
26+
- creating Python lists
27+
- raising exceptions
28+
- allocating memory
29+
- BSS and constant data (rodata)
30+
- relocated pointers in rodata
31+
32+
* `features2` - This is a hybrid module containing both Python and C code,
33+
and additionally the C code is spread over multiple files. It also
34+
demonstrates using floating point (only when the target supports
35+
hardware floating point).
36+
37+
* `features3` - A module that shows how to use types, constant objects,
38+
and creating dictionary instances.
39+
40+
* `features4` - A module that demonstrates how to define a class.
41+
42+
2. Dynamic version of existing built-ins.
43+
44+
This provides a way to add missing functionality to firmware that doesn't
45+
include certain built-in modules. See the `heapq`, `random`, `re`,
46+
`deflate`, `btree`, and `framebuf` directories.
47+
48+
So for example, if your firmware was compiled with `MICROPY_PY_FRAMEBUF`
49+
disabled (e.g. to save flash space), then it would not include the
50+
`framebuf` module. The `framebuf` native module provides a way to add the
51+
`framebuf` module dynamically.
52+
53+
The way these work is they define a dynamic native module which
54+
`#include`'s the original module and then does the necessary
55+
initialisation of the module's globals dict.
56+
57+
## Build instructions
58+
59+
To compile an example, you need to have the same toolchain available as
60+
required for your target port. e.g. `arm-none-eabi-gcc` for any ARM Cortex M
61+
target. See the port instructions for details.
62+
63+
You also need to have the `pyelftools` Python package available, either via
64+
your system package manager or installed from PyPI in a virtual environment
65+
with `pip`.
66+
67+
Each example provides a Makefile. You should specify the `ARCH` argument to
68+
make (one of x86, x64, armv6m, armv7m, xtensa, xtensawin):
69+
70+
```
71+
$ cd features0
72+
$ make ARCH=armv7m
73+
$ mpremote cp features0.mpy :
74+
```

examples/natmod/uzlib/Makefile renamed to examples/natmod/deflate/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
MPY_DIR = ../../..
33

44
# Name of module (different to built-in uzlib so it can coexist)
5-
MOD = uzlib_$(ARCH)
5+
MOD = deflate_$(ARCH)
66

77
# Source files (.c or .py)
8-
SRC = uzlib.c
8+
SRC = deflate.c
99

1010
# Architecture to build for (x86, x64, armv7m, xtensa, xtensawin)
1111
ARCH = x64

0 commit comments

Comments
 (0)