10000 Merge pull request #12 from micropython/master · shazz/micropython@718bd3d · GitHub
[go: up one dir, main page]

Skip to content

Commit 718bd3d

Browse files
authored
Merge pull request #12 from micropython/master
Upgrade fork
2 parents 169bb9f + 62f004b commit 718bd3d

File tree

18 files changed

+462
-124
lines changed

18 files changed

+462
-124
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
[submodule "lib/nrfx"]
1919
path = lib/nrfx
2020
url = https://github.com/NordicSemiconductor/nrfx.git
21+
[submodule "lib/mbedtls"]
22+
path = lib/mbedtls
23+
url = https://github.com/ARMmbed/mbedtls.git

extmod/extmod.mk

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

extmod/modussl_mbedtls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_
334334
{ MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
335335
{ MP_QSTR_cert, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
336336
{ MP_QSTR_server_side, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
337-
{ MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
337+
{ MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
338338
{ MP_QSTR_do_handshake, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
339339
};
340340

lib/mbedtls

Submodule mbedtls added at 3f8d784

ports/stm32/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ SRC_MOD += $(addprefix $(CC3000_DIR)/src/,\
399399
)
400400
endif
401401

402+
ifeq ($(MICROPY_SSL_MBEDTLS),1)
403+
CFLAGS_MOD += -DMBEDTLS_CONFIG_FILE='"mbedtls/mbedtls_config.h"'
404+
SRC_MOD += mbedtls/mbedtls_port.c
405+
endif
406+
402407
OBJ =
403408
OBJ += $(PY_O)
404409
OBJ += $(addprefix $(BUILD)/, $(SRC_LIB:.c=.o))

ports/stm32/boards/PYBD_SF2/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ TEXT1_SECTIONS = .text_ext
1212
# MicroPython settings
1313
MICROPY_PY_LWIP = 1
1414
MICROPY_PY_NETWORK_CYW43 = 1
15+
MICROPY_PY_USSL = 1
16+
MICROPY_SSL_MBEDTLS = 1

ports/stm32/boards/PYBD_SF3/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ TEXT1_SECTIONS = .text_ext
1212
# MicroPython settings
1313
MICROPY_PY_LWIP = 1
1414
MICROPY_PY_NETWORK_CYW43 = 1
15+
MICROPY_PY_USSL = 1
16+
MICROPY_SSL_MBEDTLS = 1

ports/stm32/boards/PYBD_SF6/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ TEXT0_ADDR = 0x08008000
99
# MicroPython settings
1010
MICROPY_PY_LWIP = 1
1111
MICROPY_PY_NETWORK_CYW43 = 1
12+
MICROPY_PY_USSL = 1
13+
MICROPY_SSL_MBEDTLS = 1

ports/stm32/lwip_inc/lwipopts.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
#include <stdint.h>
55

6+
// This protection is not needed, instead we execute all lwIP code at PendSV priority
7+
#define SYS_ARCH_DECL_PROTECT(lev) do { } while (0)
8+
#define SYS_ARCH_PROTECT(lev) do { } while (0)
9+
#define SYS_ARCH_UNPROTECT(lev) do { } while (0)
10+
611
#define NO_SYS 1
712
#define SYS_LIGHTWEIGHT_PROT 1
813
#define MEM_ALIGNMENT 4
@@ -20,10 +25,17 @@
2025
#define LWIP_IPV6 0
2126
#define LWIP_DHCP 1
2227
#define LWIP_DHCP_CHECK_LINK_UP 1
28+
#define DHCP_DOES_ARP_CHECK 0 // to speed DHCP up
2329
#define LWIP_DNS 1
30+
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1
31+
#define LWIP_MDNS_RESPONDER 1
2432
#define LWIP_IGMP 1
2533

34+
#define LWIP_NUM_NETIF_CLIENT_DATA 1 // mDNS responder requires 1
35+
#define MEMP_NUM_UDP_PCB 5 // mDNS responder requires 1
36+
2637
#define SO_REUSE 1
38+
#define TCP_LISTEN_BACKLOG 1
2739

2840
extern uint32_t rng_get(void);
2941
#define LWIP_RAND() rng_get()

ports/stm32/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#if MICROPY_PY_LWIP
4141
#include "lwip/init.h"
42+
#include "lwip/apps/mdns.h"
4243
#include "drivers/cyw43/cyw43.h"
4344
#endif
4445

@@ -479,6 +480,9 @@ void stm32_main(uint32_t reset_mode) {
479480
// because the system timeout list (next_timeout) is only ever reset by BSS clearing.
480481
// So for now we only init the lwIP stack once on power-up.
481482
lwip_init();
483+
#if LWIP_MDNS_RESPONDER
484+
mdns_resp_init();
485+
#endif
482486
systick_enable_dispatch(SYSTICK_DISPATCH_LWIP, mod_network_lwip_poll_wrapper);
483487
#endif
484488

0 commit comments

Comments
 (0)
0