Skip to content

Commit 14c1815

Browse files
committed
wip
1 parent 89a726e commit 14c1815

File tree

660 files changed

+14475
-5156
lines changed

Some content is hidden

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

660 files changed

+14475
-5156
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
# These should also not be modified by git.
2828
tests/basics/string_cr_conversion.py -text
2929
tests/basics/string_crlf_conversion.py -text
30+
tests/micropython/test_normalize_newlines.py.exp -text
3031
# CIRCUITPY-CHANGE: remove non-CircuitPython tests

LICENSE_MicroPython

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2024 Damien P. George
3+
Copyright (c) 2013-2025 Damien P. George
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docs/library/collections.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,19 @@ Classes
109109
a 2
110110
w 5
111111
b 3
112+
113+
.. method:: OrderedDict.popitem()
114+
115+
Remove and return a (key, value) pair from the dictionary.
116+
Pairs are returned in LIFO order.
117+
118+
.. admonition:: Difference to CPython
119+
:class: attention
120+
121+
``OrderedDict.popitem()`` does not support the ``last=False`` argument and
122+
will always remove and return the last item if present.
123+
124+
A workaround for this is to use ``pop(<first_key>)`` to remove the first item::
125+
126+
first_key = next(iter(d))
127+
d.pop(first_key)

docs/library/platform.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ Functions
3636
Returns a tuple of strings *(lib, version)*, where *lib* is the name of the
3737
libc that MicroPython is linked to, and *version* the corresponding version
3838
of this libc.
39+
40+
.. function:: processor()
41+
42+
Returns a string with a detailed name of the processor, if one is available.
43+
If no name for the processor is known, it will return an empty string
44+
instead.
45+
46+
This is currently available only on RISC-V targets (both 32 and 64 bits).

docs/library/re.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,25 @@ Regex objects
154154
Compiled regular expression. Instances of this class are created using
155155
`re.compile()`.
156156

157-
.. method:: regex.match(string)
158-
regex.search(string)
157+
.. method:: regex.match(string, [pos, [endpos]])
158+
regex.search(string, [pos, [endpos]])
159159
regex.sub(replace, string, count=0, flags=0, /)
160160

161161
Similar to the module-level functions :meth:`match`, :meth:`search`
162162
and :meth:`sub`.
163163
Using methods is (much) more efficient if the same regex is applied to
164164
multiple strings.
165165

166+
The optional second parameter *pos* gives an index in the string where the
167+
search is to start; it defaults to ``0``. This is not completely equivalent
168+
to slicing the string; the ``'^'`` pattern character matches at the real
169+
beginning of the string and at positions just after a newline, but not
170+
necessarily at the index where the search is to start.
171+
172+
The optional parameter *endpos* limits how far the string will be searched;
173+
it will be as if the string is *endpos* characters long, so only the
174+
characters from *pos* to ``endpos - 1`` will be searched for a match.
175+
166176
.. method:: regex.split(string, max_split=-1, /)
167177

168178
Split a *string* using regex. If *max_split* is given, it specifies

docs/library/sys.rst

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,9 @@ Functions
1212
.. function:: exit(retval=0, /)
1313

1414
Terminate current program with a given exit code. Underlyingly, this
15-
function raise as `SystemExit` exception. If an argument is given, its
15+
function raises a `SystemExit` exception. If an argument is given, its
1616
value given as an argument to `SystemExit`.
1717

18-
.. function:: print_exception(exc, file=sys.stdout, /)
19-
20-
This function is deprecated and will be removed starting in
21-
CircuitPython 10.x, `traceback.print_exception()` should be used instead.
22-
23-
Print exception with a traceback to a file-like object *file* (or
24-
`sys.stdout` by default).
25-
2618
.. admonition:: Difference to CPython
2719
:class: attention
2820

@@ -52,6 +44,8 @@ Constants
5244
* *version* - tuple (major, minor, micro), e.g. (1, 7, 0)
5345
* *_machine* - string describing the underlying machine
5446
* *_mpy* - supported mpy file-format version (optional attribute)
47+
* *_build* - string that can help identify the configuration that
48+
MicroPython was built with
5549

5650
This object is the recommended way to distinguish CircuitPython from other
5751
Python implementations (note that it still may not exist in the very
@@ -116,15 +110,15 @@ Constants
116110

117111
.. data:: stderr
118112

119-
Standard error ``stream``.
113+
Standard error `stream`.
120114

121115
.. data:: stdin
122116

123-
Standard input ``stream``.
117+
Standard input `stream`.
124118

125119
.. data:: stdout
126120

127-
Standard output ``stream``.
121+
Standard output `stream`.
128122

129123
.. data:: version
130124

docs/reference/glossary.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ Glossary
186186
Most MicroPython boards make a REPL available over a UART, and this is
187187
typically accessible on a host PC via USB.
188188

189+
small integer
190+
MicroPython optimises the internal representation of integers such that
191+
"small" values do not take up space on the heap, and calculations with
192+
them do not require heap allocation. On most 32-bit ports, this
193+
corresponds to values in the interval ``-2**30 <= x < 2**30``, but this
194+
should be considered an implementation detail and not relied upon.
195+
189196
stream
190197
Also known as a "file-like object". A Python object which provides
191198
sequential read-write access to the underlying data. A stream object

extmod/cyw43_config_common.h

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2025 Damien P. George, Angus Gratton
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
#ifndef MICROPY_INCLUDED_EXTMOD_CYW43_CONFIG_COMMON_H
27+
#define MICROPY_INCLUDED_EXTMOD_CYW43_CONFIG_COMMON_H
28+
29+
// The board-level config will be included here, so it can set some CYW43 values.
30+
#include "py/mpconfig.h"
31+
#include "py/mperrno.h"
32+
#include "py/mphal.h"
33+
#include "py/runtime.h"
34+
#include "extmod/modnetwork.h"
35+
#include "lwip/apps/mdns.h"
36+
#include "pendsv.h"
37+
38+
// This file is included at the top of port-specific cyw43_configport.h files,
39+
// and holds the MicroPython-specific but non-port-specific parts.
40+
//
41+
// It's included into both MicroPython sources and the lib/cyw43-driver sources.
42+
43+
#define CYW43_IOCTL_TIMEOUT_US (1000000)
44+
#define CYW43_NETUTILS (1)
45+
#define CYW43_PRINTF(...) mp_printf(MP_PYTHON_PRINTER, __VA_ARGS__)
46+
47+
#define CYW43_EPERM MP_EPERM // Operation not permitted
48+
#define CYW43_EIO MP_EIO // I/O error
49+
#define CYW43_EINVAL MP_EINVAL // Invalid argument
50+
#define CYW43_ETIMEDOUT MP_ETIMEDOUT // Connection timed out
51+
52+
#define CYW43_THREAD_ENTER MICROPY_PY_LWIP_ENTER
53+
#define CYW43_THREAD_EXIT MICROPY_PY_LWIP_EXIT
54+
#define CYW43_THREAD_LOCK_CHECK
55+
56+
#define CYW43_HOST_NAME mod_network_hostname_data
57+
58+
#define CYW43_ARRAY_SIZE(a) MP_ARRAY_SIZE(a)
59+
60+
#define CYW43_HAL_PIN_MODE_INPUT MP_HAL_PIN_MODE_INPUT
61+
#define CYW43_HAL_PIN_MODE_OUTPUT MP_HAL_PIN_MODE_OUTPUT
62+
#define CYW43_HAL_PIN_PULL_NONE MP_HAL_PIN_PULL_NONE
63+
#define CYW43_HAL_PIN_PULL_UP MP_HAL_PIN_PULL_UP
64+
#define CYW43_HAL_PIN_PULL_DOWN MP_HAL_PIN_PULL_DOWN
65+
66+
#define CYW43_HAL_MAC_WLAN0 MP_HAL_MAC_WLAN0
67+
#define CYW43_HAL_MAC_BDADDR MP_HAL_MAC_BDADDR
68+
69+
#define cyw43_hal_ticks_us mp_hal_ticks_us
70+
#define cyw43_hal_ticks_ms mp_hal_ticks_ms
71+
72+
#define cyw43_hal_pin_obj_t mp_hal_pin_obj_t
73+
#define cyw43_hal_pin_config mp_hal_pin_config
74+
#define cyw43_hal_pin_read mp_hal_pin_read
75+
#define cyw43_hal_pin_low mp_hal_pin_low
76+
#define cyw43_hal_pin_high mp_hal_pin_high
77+
78+
#define cyw43_hal_get_mac mp_hal_get_mac
79+
#define cyw43_hal_get_mac_ascii mp_hal_get_mac_ascii
80+
#define cyw43_hal_generate_laa_mac mp_hal_generate_laa_mac
81+
82+
#define cyw43_schedule_internal_poll_dispatch(func) pendsv_schedule_dispatch(PENDSV_DISPATCH_CYW43, func)
83+
84+
// Note: this function is only called if CYW43_POST_POLL_HOOK is defined in cyw43_configport.h
85+
void cyw43_post_poll_hook(void);
86+
87+
#ifdef MICROPY_EVENT_POLL_HOOK
88+
// Older style hook macros on some ports
89+
#define CYW43_EVENT_POLL_HOOK MICROPY_EVENT_POLL_HOOK
90+
#else
91+
// Newer style hooks on other ports
92+
#define CYW43_EVENT_POLL_HOOK mp_event_handle_nowait()
93+
#endif
94+
95+
static inline void cyw43_delay_us(uint32_t us) {
96+
uint32_t start = mp_hal_ticks_us();
97+
while (mp_hal_ticks_us() - start < us) {
98+
}
99+
}
100+
101+
static inline void cyw43_delay_ms(uint32_t ms) {
102+
// PendSV may be disabled via CYW43_THREAD_ENTER, so this delay is a busy loop.
103+
uint32_t us = ms * 1000;
104+
uint32_t start = mp_hal_ticks_us();
105+
while (mp_hal_ticks_us() - start < us) {
106+
CYW43_EVENT_POLL_HOOK;
107+
}
108+
}
109+
110+
#if LWIP_MDNS_RESPONDER == 1
111+
112+
// Hook for any additional TCP/IP initialization than needs to be done.
113+
// Called after the netif specified by `itf` has been set up.
114+
#ifndef CYW43_CB_TCPIP_INIT_EXTRA
115+
#define CYW43_CB_TCPIP_INIT_EXTRA(self, itf) mdns_resp_add_netif(&self->netif[itf], mod_network_hostname_data)
116+
#endif
117+
118+
// Hook for any additional TCP/IP deinitialization than needs to be done.
119+
// Called before the netif specified by `itf` is removed.
120+
#ifndef CYW43_CB_TCPIP_DEINIT_EXTRA
121+
#define CYW43_CB_TCPIP_DEINIT_EXTRA(self, itf) mdns_resp_remove_netif(&self->netif[itf])
122+
#endif
123+
124+
#endif
125+
126+
#endif // MICROPY_INCLUDED_EXTMOD_CYW43_CONFIG_COMMON_H

extmod/extmod.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ endif
162162

163163
ifeq ($(MICROPY_VFS_LFS2),1)
164164
CFLAGS_EXTMOD += -DMICROPY_VFS_LFS2=1
165-
CFLAGS_THIRDPARTY += -DLFS2_NO_MALLOC -DLFS2_NO_DEBUG -DLFS2_NO_WARN -DLFS2_NO_ERROR -DLFS2_NO_ASSERT
165+
CFLAGS_THIRDPARTY += -DLFS2_NO_MALLOC -DLFS2_NO_DEBUG -DLFS2_NO_WARN -DLFS2_NO_ERROR -DLFS2_NO_ASSERT -DLFS2_DEFINES=extmod/littlefs-include/lfs2_defines.h
166166
SRC_THIRDPARTY_C += $(addprefix $(LITTLEFS_DIR)/,\
167167
lfs2.c \
168168
lfs2_util.c \
@@ -461,7 +461,7 @@ ESP_HOSTED_SRC_C = $(addprefix $(ESP_HOSTED_DIR)/,\
461461
)
462462

463463
ifeq ($(MICROPY_PY_BLUETOOTH),1)
464-
ESP_HOSTED_SRC_C += $(ESP_HOSTED_DIR)/esp_hosted_bthci.c
464+
ESP_HOSTED_SRC_C += $(ESP_HOSTED_DIR)/esp_hosted_bthci_uart.c
465465
endif
466466

467467
# Include the protobuf-c support functions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef LFS2_DEFINES_H
2+
#define LFS2_DEFINES_H
3+
4+
#include "py/mpconfig.h"
5+
6+
#if MICROPY_PY_DEFLATE
7+
// We reuse the CRC32 implementation from uzlib to save a few bytes
8+
#include "lib/uzlib/uzlib.h"
9+
#define LFS2_CRC(crc, buffer, size) uzlib_crc32(buffer, size, crc)
10+
#endif
11+
12+
#endif

0 commit comments

Comments
 (0)