Skip to content

Commit 751c766

Browse files
authored
Merge pull request #10437 from dhalbert/merge-micropython-v1.25.0
Merge MicroPython v1.25.0
2 parents 773d72f + 2d9f304 commit 751c766

File tree

220 files changed

+7855
-1144
lines changed

Some content is hidden

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

220 files changed

+7855
-1144
lines changed

.codespell/ignore-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ ftbfs
2626
straightaway
2727
ftbs
2828
ftb
29+
curren

LICENSE

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

Makefile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,20 @@ check-translate:
271271

272272
.PHONY: stubs
273273
stubs:
274-
@rm -rf circuitpython-stubs
275-
@mkdir circuitpython-stubs
276-
@$(PYTHON) tools/extract_pyi.py shared-bindings/ $(STUBDIR)
277-
@$(PYTHON) tools/extract_pyi.py extmod/ulab/code/ $(STUBDIR)/ulab
278-
@for d in ports/*/bindings; do \
274+
rm -rf circuitpython-stubs
275+
mkdir circuitpython-stubs
276+
$(PYTHON) tools/extract_pyi.py shared-bindings/ $(STUBDIR)
277+
$(PYTHON) tools/extract_pyi.py extmod/ulab/code/ $(STUBDIR)/ulab
278+
for d in ports/*/bindings; do \
279279
$(PYTHON) tools/extract_pyi.py "$$d" $(STUBDIR); done
280-
@sed -e "s,__version__,`python -msetuptools_scm`," < setup.py-stubs > circuitpython-stubs/setup.py
281-
@cp README.rst-stubs circuitpython-stubs/README.rst
282-
@cp MANIFEST.in-stubs circuitpython-stubs/MANIFEST.in
283-
@$(PYTHON) tools/board_stubs/build_board_specific_stubs/board_stub_builder.py
284-
@cp -r tools/board_stubs/circuitpython_setboard circuitpython-stubs/circuitpython_setboard
285-
@$(PYTHON) -m build circuitpython-stubs
286-
@touch circuitpython-stubs/board/__init__.py
287-
@touch circuitpython-stubs/board_definitions/__init__.py
280+
sed -e "s,__version__,`python -msetuptools_scm`," < setup.py-stubs > circuitpython-stubs/setup.py
281+
cp README.rst-stubs circuitpython-stubs/README.rst
282+
cp MANIFEST.in-stubs circuitpython-stubs/MANIFEST.in
283+
$(PYTHON) tools/board_stubs/build_board_specific_stubs/board_stub_builder.py
284+
cp -r tools/board_stubs/circuitpython_setboard circuitpython-stubs/circuitpython_setboard
285+
$(PYTHON) -m build circuitpython-stubs
286+
touch circuitpython-stubs/board/__init__.py
287+
touch circuitpython-stubs/board_definitions/__init__.py
288288

289289
.PHONY: check-stubs
290290
check-stubs: stubs

docs/library/array.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Classes
1919
array are given by an `iterable`. If it is not provided, an empty
2020
array is created.
2121

22+
In addition to the methods below, array objects also implement the buffer
23+
protocol. This means the contents of the entire array can be accessed as raw
24+
bytes via a `memoryview` or other interfaces which use this protocol.
25+
2226
.. method:: append(val)
2327

2428
Append new element ``val`` to the end of array, growing it.

docs/library/binascii.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ Functions
3939

4040
.. function:: crc32(data, value=0, /)
4141

42-
Compute CRC-32, the 32-bit checksum of the bytes in *data* starting with an
42+
Compute CRC-32, the 32-bit checksum of the bytes in ``data`` starting with an
4343
initial CRC of *value*. The default initial CRC is 0. The algorithm is
4444
consistent with the ZIP file checksum.

docs/library/builtins.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Functions and types
3131

3232
.. class:: bytearray()
3333

34+
|see_cpython| `python:bytearray`.
35+
3436
.. class:: bytes()
3537

3638
|see_cpython| `python:bytes`.

docs/library/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ These libraries are not currently enabled in any CircuitPython build, but may be
3333
json.rst
3434
platform.rst
3535
re.rst
36-
sys.rst
3736
select.rst
37+
sys.rst
3838

3939
Omitted ``string`` functions
4040
----------------------------

extmod/extmod.mk

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ SRC_EXTMOD_C += \
2424
extmod/vfs_posix.c \
2525
extmod/vfs_posix_file.c \
2626
extmod/vfs_reader.c \
27-
extmod/virtpin.c \
2827
shared/libc/abort_.c \
2928
shared/libc/printf.c \
3029

@@ -253,6 +252,7 @@ SRC_THIRDPARTY_C += $(addprefix $(MBEDTLS_DIR)/library/,\
253252
pkcs12.c \
254253
pkcs5.c \
255254
pkparse.c \
255+
pk_ecc.c \
256256
pk_wrap.c \
257257
pkwrite.c \
258258
platform.c \
@@ -411,15 +411,14 @@ CYW43_DIR = lib/cyw43-driver
411411
GIT_SUBMODULES += $(CYW43_DIR)
412412
CFLAGS_EXTMOD += -DMICROPY_PY_NETWORK_CYW43=1
413413
SRC_THIRDPARTY_C += $(addprefix $(CYW43_DIR)/src/,\
414+
cyw43_bthci_uart.c \
414415
cyw43_ctrl.c \
415416
cyw43_lwip.c \
416417
cyw43_ll.c \
417418
cyw43_sdio.c \
419+
cyw43_spi.c \
418420
cyw43_stats.c \
419421
)
420-
ifeq ($(MICROPY_PY_BLUETOOTH),1)
421-
DRIVERS_SRC_C += drivers/cyw43/cywbt.c
422-
endif
423422

424423
$(BUILD)/$(CYW43_DIR)/src/cyw43_%.o: CFLAGS += -std=c11
425424
endif # MICROPY_PY_NETWORK_CYW43
@@ -577,6 +576,6 @@ $(BUILD)/$(OPENAMP_DIR)/lib/virtio_mmio/virtio_mmio_drv.o: CFLAGS += -Wno-unused
577576
# We need to have generated libmetal before compiling OpenAMP.
578577
$(addprefix $(BUILD)/, $(SRC_OPENAMP_C:.c=.o)): $(BUILD)/openamp/metal/config.h
579578

580-
SRC_THIRDPARTY_C += $(SRC_LIBMETAL_C) $(SRC_OPENAMP_C)
579+
SRC_THIRDPARTY_C += $(SRC_OPENAMP_C) $(SRC_LIBMETAL_C:$(BUILD)/%=%)
581580

582581
endif # MICROPY_PY_OPENAMP

extmod/lwip-include/lwipopts_common.h

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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
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_LWIPOPTS_COMMON_H
27+
#define MICROPY_INCLUDED_LWIPOPTS_COMMON_H
28+
29+
#include "py/mpconfig.h"
30+
31+
// This sys-arch protection is not needed.
32+
// Ports either protect lwIP code with flags, or run it at PendSV priority.
33+
#define SYS_ARCH_DECL_PROTECT(lev) do { } while (0)
34+
#define SYS_ARCH_PROTECT(lev) do { } while (0)
35+
#define SYS_ARCH_UNPROTECT(lev) do { } while (0)
36+
37+
#define NO_SYS 1
38+
#define SYS_LIGHTWEIGHT_PROT 1
39+
#define MEM_ALIGNMENT 4
40+
41+
#define LWIP_CHKSUM_ALGORITHM 3
42+
#define LWIP_CHECKSUM_CTRL_PER_NETIF 1
43+
44+
#define LWIP_ARP 1
45+
#define LWIP_ETHERNET 1
46+
#define LWIP_RAW 1
47+
#define LWIP_NETCONN 0
48+
#define LWIP_SOCKET 0
49+
#define LWIP_STATS 0
50+
#define LWIP_NETIF_HOSTNAME 1
51+
52+
#define LWIP_DHCP 1
53+
#define LWIP_DHCP_CHECK_LINK_UP 1
54+
#define LWIP_DHCP_DOES_ACD_CHECK 0 // to speed DHCP up
55+
#define LWIP_DNS 1
56+
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1
57+
#define LWIP_MDNS_RESPONDER 1
58+
#define LWIP_IGMP 1
59+
60+
#if MICROPY_PY_LWIP_PPP
61+
#define PPP_SUPPORT 1
62+
#define PAP_SUPPORT 1
63+
#define CHAP_SUPPORT 1
64+
#endif
65+
66+
#define LWIP_NUM_NETIF_CLIENT_DATA LWIP_MDNS_RESPONDER
67+
#define MEMP_NUM_UDP_PCB (4 + LWIP_MDNS_RESPONDER)
68+
69+
// The mDNS responder requires 5 timers per IP version plus 2 others. Not having enough silently breaks it.
70+
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + (LWIP_MDNS_RESPONDER * (2 + (5 * (LWIP_IPV4 + LWIP_IPV6)))))
71+
72+
#define SO_REUSE 1
73+
#define TCP_LISTEN_BACKLOG 1
74+
75+
// TCP memory settings.
76+
// Default lwIP settings takes 15800 bytes; TCP d/l: 380k/s local, 7.2k/s remote; TCP u/l is very slow.
77+
#ifndef MEM_SIZE
78+
79+
#if 0
80+
// lwIP takes 19159 bytes; TCP d/l and u/l are around 320k/s on local network.
81+
#define MEM_SIZE (5000)
82+
#define TCP_WND (4 * TCP_MSS)
83+
#define TCP_SND_BUF (4 * TCP_MSS)
84+
#endif
85+
86+
#if 1
87+
// lwIP takes 26700 bytes; TCP dl/ul are around 750/600 k/s on local network.
88+
#define MEM_SIZE (8000)
89+
#define TCP_MSS (800)
90+
#define TCP_WND (8 * TCP_MSS)
91+
#define TCP_SND_BUF (8 * TCP_MSS)
92+
#define MEMP_NUM_TCP_SEG (32)
93+
#endif
94+
95+
#if 0
96+
// lwIP takes 45600 bytes; TCP dl/ul are around 1200/1000 k/s on local network.
97+
#define MEM_SIZE (16000)
98+
#define TCP_MSS (1460)
99+
#define TCP_WND (8 * TCP_MSS)
100+
#define TCP_SND_BUF (8 * TCP_MSS)
101+
#define MEMP_NUM_TCP_SEG (32)
102+
#endif
103+
104+
#endif // MEM_SIZE
105+
106+
// Needed for PPP.
107+
#define sys_jiffies sys_now
108+
109+
typedef uint32_t sys_prot_t;
110+
111+
#endif // MICROPY_INCLUDED_LWIPOPTS_COMMON_H

extmod/moddeflate.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static bool deflateio_init_read(mp_obj_deflateio_t *self) {
142142
}
143143
}
144144

145-
size_t window_len = 1 << wbits;
145+
size_t window_len = (size_t)1 << wbits;
146146
self->read->window = m_new(uint8_t, window_len);
147147

148148
uzlib_uncompress_init(&self->read->decomp, self->read->window, window_len);
@@ -168,16 +168,20 @@ static bool deflateio_init_write(mp_obj_deflateio_t *self) {
168168

169169
const mp_stream_p_t *stream = mp_get_stream_raise(self->stream, MP_STREAM_OP_WRITE);
170170

171-
self->write = m_new_obj(mp_obj_deflateio_write_t);
172-
self->write->input_len = 0;
173-
174171
int wbits = self->window_bits;
175172
if (wbits == 0) {
176173
// Same default wbits for all formats.
177174
wbits = DEFLATEIO_DEFAULT_WBITS;
178175
}
176+
177+
// Allocate the large window before allocating the mp_obj_deflateio_write_t, in case the
178+
// window allocation fails the mp_obj_deflateio_t object will remain in a consistent state.
179179
size_t window_len = 1 << wbits;
180-
self->write->window = m_new(uint8_t, window_len);
180+
uint8_t *window = m_new(uint8_t, window_len);
181+
182+
self->write = m_new_obj(mp_obj_deflateio_write_t);
183+
self->write->window = window;
184+
self->write->input_len = 0;
181185

182186
uzlib_lz77_init(&self->write->lz77, self->write->window, window_len);
183187
self->write->lz77.dest_write_data = self;

extmod/modos.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,15 @@ static const mp_rom_map_elem_t os_module_globals_table[] = {
171171
{ MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&mp_vfs_chdir_obj) },
172172
{ MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&mp_vfs_getcwd_obj) },
173173
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&mp_vfs_listdir_obj) },
174+
#if MICROPY_VFS_WRITABLE
174175
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&mp_vfs_mkdir_obj) },
175176
{ MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&mp_vfs_remove_obj) },
176177
{ MP_ROM_QSTR(MP_QSTR_rename), MP_ROM_PTR(&mp_vfs_rename_obj) },
177178
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&mp_vfs_rmdir_obj) },
179+
{ MP_ROM_QSTR(MP_QSTR_unlink), MP_ROM_PTR(&mp_vfs_remove_obj) }, // unlink aliases to remove
180+
#endif
178181
{ MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&mp_vfs_stat_obj) },
179182
{ MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&mp_vfs_statvfs_obj) },
180-
{ MP_ROM_QSTR(MP_QSTR_unlink), MP_ROM_PTR(&mp_vfs_remove_obj) }, // unlink aliases to remove
181183
#endif
182184

183185
// The following are MicroPython extensions.

extmod/modplatform.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,34 @@
3636
// See: https://sourceforge.net/p/predef/wiki/Home/
3737

3838
#if defined(__ARM_ARCH)
39+
#if defined(__ARM_ARCH_ISA_A64)
40+
#define MICROPY_PLATFORM_ARCH "aarch64"
41+
#else
3942
#define MICROPY_PLATFORM_ARCH "arm"
43+
#endif
4044
#elif defined(__x86_64__) || defined(_M_X64)
4145
#define MICROPY_PLATFORM_ARCH "x86_64"
4246
#elif defined(__i386__) || defined(_M_IX86)
4347
#define MICROPY_PLATFORM_ARCH "x86"
4448
#elif defined(__xtensa__)
4549
#define MICROPY_PLATFORM_ARCH "xtensa"
4650
#elif defined(__riscv)
51+
#if __riscv_xlen == 64
52+
#define MICROPY_PLATFORM_ARCH "riscv64"
53+
#else
4754
#define MICROPY_PLATFORM_ARCH "riscv"
55+
#endif
4856
#else
4957
#define MICROPY_PLATFORM_ARCH ""
5058
#endif
5159

52-
#if defined(__GNUC__)
60+
#if defined(__clang__)
61+
#define MICROPY_PLATFORM_COMPILER \
62+
"Clang " \
63+
MP_STRINGIFY(__clang_major__) "." \
64+
MP_STRINGIFY(__clang_minor__) "." \
65+
MP_STRINGIFY(__clang_patchlevel__)
66+
#elif defined(__GNUC__)
5367
#define MICROPY_PLATFORM_COMPILER \
5468
"GCC " \
5569
MP_STRINGIFY(__GNUC__) "." \
@@ -86,12 +100,17 @@
86100
#elif defined(_PICOLIBC__)
87101
#define MICROPY_PLATFORM_LIBC_LIB "picolibc"
88102
#define MICROPY_PLATFORM_LIBC_VER _PICOLIBC_VERSION
103+
#elif defined(__ANDROID__)
104+
#define MICROPY_PLATFORM_LIBC_LIB "bionic"
105+
#define MICROPY_PLATFORM_LIBC_VER MP_STRINGIFY(__ANDROID_API__)
89106
#else
90107
#define MICROPY_PLATFORM_LIBC_LIB ""
91108
#define MICROPY_PLATFORM_LIBC_VER ""
92109
#endif
93110

94-
#if defined(__linux)
111+
#if defined(__ANDROID__)
112+
#define MICROPY_PLATFORM_SYSTEM "Android"
113+
#elif defined(__linux)
95114
#define MICROPY_PLATFORM_SYSTEM "Linux"
96115
#elif defined(__unix__)
97116
#define MICROPY_PLATFORM_SYSTEM "Unix"

0 commit comments

Comments
 (0)