Skip to content

Commit b35fa44

Browse files
committed
Merge MicroPython 1.12 into CircuitPython
1 parent 25ccd5d commit b35fa44

File tree

409 files changed

+46797
-5223
lines changed

Some content is hidden

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

409 files changed

+46797
-5223
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*.bat text eol=crlf
1212

1313
# These are binary so should never be modified by git.
14+
*.a binary
1415
*.png binary
1516
*.jpg binary
1617
*.dxf binary

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ dist/
2828
######################
2929
*.swp
3030

31-
# Build directory
31+
# Build directories
3232
######################
3333
build/
3434
bin/
3535
circuitpython-stubs/
36+
build-*/
3637

3738
# Test failure outputs
3839
######################

ACKNOWLEDGEMENTS

-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,6 @@ today. The names appear in order of pledging.
762762
1642 Udine
763763
1643 Simon Critchley
764764
1644 Sven Haiges, Germany
765-
1645 Yi Qing Sim
766765
1646 "silicium" ("silicium_one", if "silicium" is busy)
767766
1648 Andy O'Malia, @andyomalia
768767
1650 RedCamelApps.com

docs/library/array.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
:mod:`array` -- arrays of numeric data
2-
======================================
2+
=======================================
33

44
.. module:: array
55
:synopsis: efficient arrays of numeric data
@@ -13,7 +13,7 @@ floating-point support).
1313
Classes
1414
-------
1515

16-
.. class:: array.array(typecode, [iterable])
16+
.. class:: array(typecode, [iterable])
1717

1818
Create array with elements of given type. Initial contents of the
1919
array are given by an `iterable`. If it is not provided, an empty

docs/library/framebuf.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ For example::
2121
import framebuf
2222

2323
# FrameBuffer needs 2 bytes for every RGB565 pixel
24-
fbuf = FrameBuffer(bytearray(10 * 100 * 2), 10, 100, framebuf.RGB565)
24+
fbuf = framebuf.FrameBuffer(bytearray(10 * 100 * 2), 10, 100, framebuf.RGB565)
2525

2626
fbuf.fill(0)
2727
fbuf.text('MicroPython!', 0, 0, 0xffff)

docs/library/micropython.rst

+33
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,36 @@ Functions
9494
This function can be used to prevent the capturing of Ctrl-C on the
9595
incoming stream of characters that is usually used for the REPL, in case
9696
that stream is used for other purposes.
97+
98+
.. function:: schedule(func, arg)
99+
100+
Schedule the function *func* to be executed "very soon". The function
101+
is passed the value *arg* as its single argument. "Very soon" means that
102+
the MicroPython runtime will do its best to execute the function at the
103+
earliest possible time, given that it is also trying to be efficient, and
104+
that the following conditions hold:
105+
106+
- A scheduled function will never preempt another scheduled function.
107+
- Scheduled functions are always executed "between opcodes" which means
108+
that all fundamental Python operations (such as appending to a list)
109+
are guaranteed to be atomic.
110+
- A given port may define "critical regions" within which scheduled
111+
functions will never be executed. Functions may be scheduled within
112+
a critical region but they will not be executed until that region
113+
is exited. An example of a critical region is a preempting interrupt
114+
handler (an IRQ).
115+
116+
A use for this function is to schedule a callback from a preempting IRQ.
117+
Such an IRQ puts restrictions on the code that runs in the IRQ (for example
118+
the heap may be locked) and scheduling a function to call later will lift
119+
those restrictions.
120+
121+
Note: If `schedule()` is called from a preempting IRQ, when memory
122+
allocation is not allowed and the callback to be passed to `schedule()` is
123+
a bound method, passing this directly will fail. This is because creating a
124+
reference to a bound method causes memory allocation. A solution is to
125+
create a reference to the method in the class constructor and to pass that
126+
reference to `schedule()`.
127+
128+
There is a finite queue to hold the scheduled functions and `schedule()`
129+
will raise a `RuntimeError` if the queue is full.

docs/library/sys.rst

+6-14
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,6 @@ Functions
1717
function raise as `SystemExit` exception. If an argument is given, its
1818
value given as an argument to `SystemExit`.
1919

20-
.. function:: print_exception(exc, file=sys.stdout)
21-
22-
Print exception with a traceback to a file-like object *file* (or
23-
`sys.stdout` by default).
24-
25-
.. admonition:: Difference to CPython
26-
:class: attention
27-
28-
This is simplified version of a function which appears in the
29-
``traceback`` module in CPython. Unlike ``traceback.print_exception()``,
30-
this function takes just exception value instead of exception type,
31-
exception value, and traceback object; *file* argument should be
32-
positional; further arguments are not supported.
33-
3420
Constants
3521
---------
3622

@@ -122,3 +108,9 @@ Constants
122108
.. data:: version_info
123109

124110
Python language version that this implementation conforms to, as a tuple of ints.
111+
112+
.. admonition:: Difference to CPython
113+
:class: attention
114+
115+
Only the first three version numbers (major, minor, micro) are supported and
116+
they can be referenced only by index, not by name.

extmod/crypto-algorithms/sha256.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*********************************************************************
2+
* Source: https://github.com/B-Con/crypto-algorithms
23
* Filename: sha256.c
34
* Author: Brad Conte (brad AT bradconte.com)
4-
* Copyright:
5+
* Copyright: This code is released into the public domain.
56
* Disclaimer: This code is presented "as is" without any guarantees.
67
* Details: Implementation of the SHA-256 hashing algorithm.
78
SHA-256 is one of the three algorithms in the SHA2

extmod/crypto-algorithms/sha256.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*********************************************************************
2+
* Source: https://github.com/B-Con/crypto-algorithms
23
* Filename: sha256.h
34
* Author: Brad Conte (brad AT bradconte.com)
4-
* Copyright:
5+
* Copyright: This code is released into the public domain.
56
* Disclaimer: This code is presented "as is" without any guarantees.
67
* Details: Defines the API for the corresponding SHA1 implementation.
78
*********************************************************************/

extmod/extmod.mk

+232
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# This makefile fragment provides rules to build 3rd-party components for extmod modules
2+
3+
################################################################################
4+
# VFS FAT FS
5+
6+
OOFATFS_DIR = lib/oofatfs
7+
8+
# this sets the config file for FatFs
9+
CFLAGS_MOD += -DFFCONF_H=\"$(OOFATFS_DIR)/ffconf.h\"
10+
11+
ifeq ($(MICROPY_VFS_FAT),1)
12+
CFLAGS_MOD += -DMICROPY_VFS_FAT=1
13+
SRC_MOD += $(addprefix $(OOFATFS_DIR)/,\
14+
ff.c \
15+
ffunicode.c \
16+
)
17+
endif
18+
19+
################################################################################
20+
# VFS littlefs
21+
22+
LITTLEFS_DIR = lib/littlefs
23+
24+
ifeq ($(MICROPY_VFS_LFS1),1)
25+
CFLAGS_MOD += -DMICROPY_VFS_LFS1=1
26+
CFLAGS_MOD += -DLFS1_NO_MALLOC -DLFS1_NO_DEBUG -DLFS1_NO_WARN -DLFS1_NO_ERROR -DLFS1_NO_ASSERT
27+
SRC_MOD += $(addprefix $(LITTLEFS_DIR)/,\
28+
lfs1.c \
29+
lfs1_util.c \
30+
)
31+
else
32+
CFLAGS_MOD += -DMICROPY_VFS_LFS1=0
33+
endif
34+
35+
ifeq ($(MICROPY_VFS_LFS2),1)
36+
CFLAGS_MOD += -DMICROPY_VFS_LFS2=1
37+
CFLAGS_MOD += -DLFS2_NO_MALLOC -DLFS2_NO_DEBUG -DLFS2_NO_WARN -DLFS2_NO_ERROR -DLFS2_NO_ASSERT
38+
SRC_MOD += $(addprefix $(LITTLEFS_DIR)/,\
39+
lfs2.c \
40+
lfs2_util.c \
41+
)
42+
else
43+
CFLAGS_MOD += -DMICROPY_VFS_LFS2=0
44+
endif
45+
46+
################################################################################
47+
# ussl
48+
49+
ifeq ($(MICROPY_PY_USSL),1)
50+
CFLAGS_MOD += -DMICROPY_PY_USSL=1
51+
ifeq ($(MICROPY_SSL_AXTLS),1)
52+
CFLAGS_MOD += -DMICROPY_SSL_AXTLS=1 -I$(TOP)/lib/axtls/ssl -I$(TOP)/lib/axtls/crypto -I$(TOP)/extmod/axtls-include
53+
AXTLS_DIR = lib/axtls
54+
$(BUILD)/$(AXTLS_DIR)/%.o: CFLAGS += -Wno-all -Wno-unused-parameter -Wno-uninitialized -Wno-sign-compare -Wno-old-style-definition $(AXTLS_DEFS_EXTRA)
55+
SRC_MOD += $(addprefix $(AXTLS_DIR)/,\
56+
ssl/asn1.c \
57+
ssl/loader.c \
58+
ssl/tls1.c \
59+
ssl/tls1_svr.c \
60+
ssl/tls1_clnt.c \
61+
ssl/x509.c \
62+
crypto/aes.c \
63+
crypto/bigint.c \
64+
crypto/crypto_misc.c \
65+
crypto/hmac.c \
66+
crypto/md5.c \
67+
crypto/rsa.c \
68+
crypto/sha1.c \
69+
)
70+
else ifeq ($(MICROPY_SSL_MBEDTLS),1)
71+
MBEDTLS_DIR = lib/mbedtls
72+
CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(TOP)/$(MBEDTLS_DIR)/include
73+
SRC_MOD += $(addprefix $(MBEDTLS_DIR)/library/,\
74+
aes.c \
75+
aesni.c \
76+
arc4.c \
77+
asn1parse.c \
78+
asn1write.c \
79+
base64.c \
80+
bignum.c \
81+
blowfish.c \
82+
camellia.c \
83+
ccm.c \
84+
certs.c \
85+
chacha20.c \
86+
chachapoly.c \
87+
cipher.c \
88+
cipher_wrap.c \
89+
cmac.c \
90+
ctr_drbg.c \
91+
debug.c \
92+
des.c \
93+
dhm.c \
94+
ecdh.c \
95+
ecdsa.c \
96+
ecjpake.c \
97+
ecp.c \
98+
ecp_curves.c \
99+
entropy.c \
100+
entropy_poll.c \
101+
error.c \
102+
gcm.c \
103+
havege.c \
104+
hmac_drbg.c \
105+
md2.c \
106+
md4.c \
107+
md5.c \
108+
md.c \
109+
md_wrap.c \
110+
oid.c \
111+
padlock.c \
112+
pem.c \
113+
pk.c \
114+
pkcs11.c \
115+
pkcs12.c \
116+
pkcs5.c \
117+
pkparse.c \
118+
pk_wrap.c \
119+
pkwrite.c \
120+
platform.c \
121+
platform_util.c \
122+
poly1305.c \
123+
ripemd160.c \
124+
rsa.c \
125+
rsa_internal.c \
126+
sha1.c \
127+
sha256.c \
128+
sha512.c \
129+
ssl_cache.c \
130+
ssl_ciphersuites.c \
131+
ssl_cli.c \
132+
ssl_cookie.c \
133+
ssl_srv.c \
134+
ssl_ticket.c \
135+
ssl_tls.c \
136+
timing.c \
137+
x509.c \
138+
x509_create.c \
139+
x509_crl.c \
140+
x509_crt.c \
141+
x509_csr.c \
142+
x509write_crt.c \
143+
x509write_csr.c \
144+
xtea.c \
145+
)
146+
endif
147+
endif
148+
149+
################################################################################
150+
# lwip
151+
152+
ifeq ($(MICROPY_PY_LWIP),1)
153+
# A port should add an include path where lwipopts.h can be found (eg extmod/lwip-include)
154+
LWIP_DIR = lib/lwip/src
155+
INC += -I$(TOP)/$(LWIP_DIR)/include
156+
CFLAGS_MOD += -DMICROPY_PY_LWIP=1
157+
$(BUILD)/$(LWIP_DIR)/core/ipv4/dhcp.o: CFLAGS_MOD += -Wno-address
158+
SRC_MOD += extmod/modlwip.c lib/netutils/netutils.c
159+
SRC_MOD += $(addprefix $(LWIP_DIR)/,\
160+
apps/mdns/mdns.c \
161+
core/def.c \
162+
core/dns.c \
163+
core/inet_chksum.c \
164+
core/init.c \
165+
core/ip.c \
166+
core/mem.c \
167+
core/memp.c \
168+
core/netif.c \
169+
core/pbuf.c \
170+
core/raw.c \
171+
core/stats.c \
172+
core/sys.c \
173+
core/tcp.c \
174+
core/tcp_in.c \
175+
core/tcp_out.c \
176+
core/timeouts.c \
177+
core/udp.c \
178+
core/ipv4/autoip.c \
179+
core/ipv4/dhcp.c \
180+
core/ipv4/etharp.c \
181+
core/ipv4/icmp.c \
182+
core/ipv4/igmp.c \
183+
core/ipv4/ip4_addr.c \
184+
core/ipv4/ip4.c \
185+
core/ipv4/ip4_frag.c \
186+
core/ipv6/dhcp6.c \
187+
core/ipv6/ethip6.c \
188+
core/ipv6/icmp6.c \
189+
core/ipv6/inet6.c \
190+
core/ipv6/ip6_addr.c \
191+
core/ipv6/ip6.c \
192+
core/ipv6/ip6_frag.c \
193+
core/ipv6/mld6.c \
194+
core/ipv6/nd6.c \
195+
netif/ethernet.c \
196+
)
197+
ifeq ($(MICROPY_PY_LWIP_SLIP),1)
198+
CFLAGS_MOD += -DMICROPY_PY_LWIP_SLIP=1
199+
SRC_MOD += $(LWIP_DIR)/netif/slipif.c
200+
endif
201+
endif
202+
203+
################################################################################
204+
# btree
205+
206+
ifeq ($(MICROPY_PY_BTREE),1)
207+
BTREE_DIR = lib/berkeley-db-1.xx
208+
BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ "-Dvirt_fd_t=void*" $(BTREE_DEFS_EXTRA)
209+
INC += -I$(TOP)/$(BTREE_DIR)/PORT/include
210+
SRC_MOD += extmod/modbtree.c
211+
SRC_MOD += $(addprefix $(BTREE_DIR)/,\
212+
btree/bt_close.c \
213+
btree/bt_conv.c \
214+
btree/bt_debug.c \
215+
btree/bt_delete.c \
216+
btree/bt_get.c \
217+
btree/bt_open.c \
218+
btree/bt_overflow.c \
219+
btree/bt_page.c \
220+
btree/bt_put.c \
221+
btree/bt_search.c \
222+
btree/bt_seq.c \
223+
btree/bt_split.c \
224+
btree/bt_utils.c \
225+
mpool/mpool.c \
226+
)
227+
CFLAGS_MOD += -DMICROPY_PY_BTREE=1
228+
# we need to suppress certain warnings to get berkeley-db to compile cleanly
229+
# and we have separate BTREE_DEFS so the definitions don't interfere with other source code
230+
$(BUILD)/$(BTREE_DIR)/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter $(BTREE_DEFS)
231+
$(BUILD)/extmod/modbtree.o: CFLAGS += $(BTREE_DEFS)
232+
endif

0 commit comments

Comments
 (0)