Skip to content

Commit d4f16ed

Browse files
authored
Merge pull request #14 from ganshun666/master
merge upstream master
2 parents 2eefdf0 + 3990b17 commit d4f16ed

Some content is hidden

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

59 files changed

+998
-143
lines changed

drivers/wiznet5k/ethernet/socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ int8_t WIZCHIP_EXPORT(socket)(uint8_t sn, uint8_t protocol, uint16_t port, uint8
157157
setSn_PORT(sn,port);
158158
setSn_CR(sn,Sn_CR_OPEN);
159159
while(getSn_CR(sn));
160-
sock_io_mode |= ((flag & SF_IO_NONBLOCK) << sn);
160+
sock_io_mode |= ((flag & SF_IO_NONBLOCK) << sn);
161161
sock_is_sending &= ~(1<<sn);
162162
sock_remained_size[sn] = 0;
163163
sock_pack_info[sn] = 0;

esp8266/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include ../py/mkenv.mk
44
QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h
55

66
MICROPY_PY_USSL = 1
7+
MICROPY_SSL_AXTLS = 1
78

89
# include py core make definitions
910
include ../py/py.mk
@@ -153,7 +154,7 @@ SRC_QSTR += $(SRC_C) $(STM_SRC_C) $(EXTMOD_SRC_C) $(DRIVERS_SRC_C)
153154
# Append any auto-generated sources that are needed by sources listed in SRC_QSTR
154155
SRC_QSTR_AUTO_DEPS +=
155156

156-
all: $(BUILD)/firmware-combined.bin
157+
all: $(BUILD)/libaxtls.a $(BUILD)/firmware-combined.bin
157158

158159
CONFVARS_FILE = $(BUILD)/confvars
159160

@@ -229,8 +230,11 @@ $(BUILD)/firmware.elf: $(OBJ)
229230

230231
include ../py/mkrules.mk
231232

232-
axtls:
233+
axtls: $(BUILD)/libaxtls.a
234+
235+
$(BUILD)/libaxtls.a:
233236
cd ../lib/axtls; cp config/upyconfig config/.config
234237
cd ../lib/axtls; make oldconfig -B
235238
cd ../lib/axtls; make clean
236239
cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)" AR="$(AR)" CFLAGS_EXTRA="$(CFLAGS_XTENSA) -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=3072"
240+
cp ../lib/axtls/_stage/libaxtls.a $@

esp8266/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ STATIC void mp_reset(void) {
6060
MP_STATE_PORT(dupterm_arr_obj) = MP_OBJ_NULL;
6161
pin_init0();
6262
readline_init0();
63+
dupterm_task_init();
6364
#if MICROPY_MODULE_FROZEN
6465
pyexec_frozen_module("_boot.py");
6566
pyexec_file("boot.py");
@@ -85,7 +86,6 @@ void init_done(void) {
8586
#if MICROPY_REPL_EVENT_DRIVEN
8687
pyexec_event_repl_init();
8788
#endif
88-
dupterm_task_init();
8989

9090
#if !MICROPY_REPL_EVENT_DRIVEN
9191
soft_reset:

esp8266/modpybuart.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,11 @@ STATIC void pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const mp_o
112112
if (args[ARG_parity].u_obj != MP_OBJ_NULL) {
113113
if (args[ARG_parity].u_obj == mp_const_none) {
114114
UartDev.parity = UART_NONE_BITS;
115+
UartDev.exist_parity = UART_STICK_PARITY_DIS;
115116
self->parity = 0;
116117
} else {
117118
mp_int_t parity = mp_obj_get_int(args[ARG_parity].u_obj);
119+
UartDev.exist_parity = UART_STICK_PARITY_EN;
118120
if (parity & 1) {
119121
UartDev.parity = UART_ODD_BITS;
120122
self->parity = 1;

esp8266/modules/_boot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import gc
2+
gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
23
import uos
34
from flashbdev import bdev
45

esp8266/moduos.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ STATIC mp_obj_t os_mkdir(mp_obj_t path_in) {
9595
}
9696
STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_mkdir_obj, os_mkdir);
9797

98+
STATIC mp_obj_t os_rmdir(mp_obj_t path_in) {
99+
return vfs_proxy_call(MP_QSTR_rmdir, 1, &path_in);
100+
}
101+
STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir);
102+
98103
STATIC mp_obj_t os_chdir(mp_obj_t path_in) {
99104
return vfs_proxy_call(MP_QSTR_chdir, 1, &path_in);
100105
}
@@ -155,6 +160,7 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
155160
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
156161
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&os_listdir_obj) },
157162
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&os_mkdir_obj) },
163+
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&os_rmdir_obj) },
158164
{ MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&os_chdir_obj) },
159165
{ MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&os_getcwd_obj) },
160166
{ MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&os_remove_obj) },

esp8266/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
7373
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
7474
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
75+
#define MICROPY_WARNINGS (1)
76+
#define MICROPY_PY_STR_BYTES_CMP_WARN (1)
7577
#define MICROPY_STREAMS_NON_BLOCK (1)
7678
#define MICROPY_MODULE_FROZEN_STR (1)
7779
#define MICROPY_MODULE_FROZEN_MPY (1)

esp8266/uart.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef _INCLUDED_UART_H_
22
#define _INCLUDED_UART_H_
33

4+
#include <eagle_soc.h>
5+
46
#define UART0 (0)
57
#define UART1 (1)
68

@@ -18,14 +20,14 @@ typedef enum {
1820
} UartStopBitsNum;
1921

2022
typedef enum {
21-
UART_NONE_BITS = 0,
22-
UART_ODD_BITS = 0,
23-
UART_EVEN_BITS = BIT4
23+
UART_NONE_BITS = 0,
24+
UART_ODD_BITS = BIT0,
25+
UART_EVEN_BITS = 0
2426
} UartParityMode;
2527

2628
typedef enum {
2729
UART_STICK_PARITY_DIS = 0,
28-
UART_STICK_PARITY_EN = BIT3 | BIT5
30+
UART_STICK_PARITY_EN = BIT1
2931
} UartExistParity;
3032

3133
typedef enum {

examples/embedding/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
MPTOP = ../..
2+
CFLAGS = -std=c99 -I. -I$(MPTOP) -DNO_QSTR
3+
LDFLAGS = -L.
4+
5+
hello-embed: hello-embed.o -lmicropython
6+
7+
-lmicropython:
8+
$(MAKE) -f $(MPTOP)/examples/embedding/Makefile.upylib MPTOP=$(MPTOP)

examples/embedding/Makefile.upylib

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
MPTOP = ../..
2+
-include mpconfigport.mk
3+
include $(MPTOP)/py/mkenv.mk
4+
5+
all: lib
6+
7+
# OS name, for simple autoconfig
8+
UNAME_S := $(shell uname -s)
9+
10+
# include py core make definitions
11+
include $(MPTOP)/py/py.mk
12+
13+
INC += -I.
14+
INC += -I..
15+
INC += -I$(MPTOP)
16+
INC += -I$(MPTOP)/unix
17+
#INC += -I../lib/timeutils
18+
INC += -I$(BUILD)
19+
20+
# compiler settings
21+
CWARN = -Wall -Werror
22+
CWARN += -Wpointer-arith -Wuninitialized
23+
CFLAGS = $(INC) $(CWARN) -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
24+
25+
# Debugging/Optimization
26+
ifdef DEBUG
27+
CFLAGS += -g
28+
COPT = -O0
29+
else
30+
COPT = -Os #-DNDEBUG
31+
# _FORTIFY_SOURCE is a feature in gcc/glibc which is intended to provide extra
32+
# security for detecting buffer overflows. Some distros (Ubuntu at the very least)
33+
# have it enabled by default.
34+
#
35+
# gcc already optimizes some printf calls to call puts and/or putchar. When
36+
# _FORTIFY_SOURCE is enabled and compiling with -O1 or greater, then some
37+
# printf calls will also be optimized to call __printf_chk (in glibc). Any
38+
# printfs which get redirected to __printf_chk are then no longer synchronized
39+
# with printfs that go through mp_printf.
40+
#
41+
# In MicroPython, we don't want to use the runtime library's printf but rather
42+
# go through mp_printf, so that stdout is properly tied into streams, etc.
43+
# This means that we either need to turn off _FORTIFY_SOURCE or provide our
44+
# own implementation of __printf_chk. We've chosen to turn off _FORTIFY_SOURCE.
45+
# It should also be noted that the use of printf in MicroPython is typically
46+
# quite limited anyways (primarily for debug and some error reporting, etc
47+
# in the unix version).
48+
#
49+
# Information about _FORTIFY_SOURCE seems to be rather scarce. The best I could
50+
# find was this: https://securityblog.redhat.com/2014/03/26/fortify-and-you/
51+
# Original patchset was introduced by
52+
# https://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html .
53+
#
54+
# Turning off _FORTIFY_SOURCE is only required when compiling with -O1 or greater
55+
CFLAGS += -U _FORTIFY_SOURCE
56+
endif
57+
58+
# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed.
59+
# The unix port of micropython on OSX must be compiled with clang,
60+
# while cross-compile ports require gcc, so we test here for OSX and
61+
# if necessary override the value of 'CC' set in py/mkenv.mk
62+
ifeq ($(UNAME_S),Darwin)
63+
CC = clang
64+
# Use clang syntax for map file
65+
LDFLAGS_ARCH = -Wl,-map,$@.map
66+
else
67+
# Use gcc syntax for map file
68+
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
69+
endif
70+
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
71+
72+
ifeq ($(MICROPY_FORCE_32BIT),1)
73+
# Note: you may need to install i386 versions of dependency packages,
74+
# starting with linux-libc-dev:i386
75+
ifeq ($(MICROPY_PY_FFI),1)
76+
ifeq ($(UNAME_S),Linux)
77+
CFLAGS_MOD += -I/usr/include/i686-linux-gnu
78+
endif
79+
endif
80+
endif
81+
82+
ifeq ($(MICROPY_USE_READLINE),1)
83+
INC += -I../lib/mp-readline
84+
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
85+
LIB_SRC_C_EXTRA += mp-readline/readline.c
86+
endif
87+
ifeq ($(MICROPY_USE_READLINE),2)
88+
CFLAGS_MOD += -DMICROPY_USE_READLINE=2
89+
LDFLAGS_MOD += -lreadline
90+
# the following is needed for BSD
91+
#LDFLAGS_MOD += -ltermcap
92+
endif
93+
ifeq ($(MICROPY_PY_TIME),1)
94+
CFLAGS_MOD += -DMICROPY_PY_TIME=1
95+
SRC_MOD += modtime.c
96+
endif
97+
ifeq ($(MICROPY_PY_TERMIOS),1)
98+
CFLAGS_MOD += -DMICROPY_PY_TERMIOS=1
99+
SRC_MOD += modtermios.c
100+
endif
101+
ifeq ($(MICROPY_PY_SOCKET),1)
102+
CFLAGS_MOD += -DMICROPY_PY_SOCKET=1
103+
SRC_MOD += modsocket.c
104+
endif
105+
106+
ifeq ($(MICROPY_PY_FFI),1)
107+
108+
ifeq ($(MICROPY_STANDALONE),1)
109+
LIBFFI_CFLAGS_MOD := -I$(shell ls -1d ../lib/libffi/build_dir/out/lib/libffi-*/include)
110+
ifeq ($(MICROPY_FORCE_32BIT),1)
111+
LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib32/libffi.a
112+
else
113+
LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib/libffi.a
114+
endif
115+
else
116+
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
117+
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
118+
endif
119+
120+
ifeq ($(UNAME_S),Linux)
121+
LIBFFI_LDFLAGS_MOD += -ldl
122+
endif
123+
124+
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1
125+
LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD)
126+
SRC_MOD += modffi.c
127+
endif
128+
129+
MAIN_C = main.c
130+
131+
# source files
132+
SRC_C = $(addprefix $(MPTOP)/unix/,\
133+
$(MAIN_C) \
134+
gccollect.c \
135+
unix_mphal.c \
136+
input.c \
137+
file.c \
138+
modmachine.c \
139+
modos.c \
140+
moduselect.c \
141+
alloc.c \
142+
coverage.c \
143+
fatfs_port.c \
144+
$(SRC_MOD) \
145+
)
146+
147+
LIB_SRC_C = $(addprefix lib/,\
148+
$(LIB_SRC_C_EXTRA) \
149+
utils/printf.c \
150+
timeutils/timeutils.c \
151+
)
152+
153+
ifeq ($(MICROPY_FATFS),1)
154+
LIB_SRC_C += $(addprefix lib/,\
155+
fatfs/ff.c \
156+
fatfs/option/ccsbcs.c \
157+
)
158+
endif
159+
160+
OBJ = $(PY_O)
161+
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
162+
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
163+
OBJ += $(addprefix $(BUILD)/, $(STMHAL_SRC_C:.c=.o))
164+
165+
# List of sources for qstr extraction
166+
SRC_QSTR += $(SRC_C) $(LIB_SRC_C)
167+
# Append any auto-generated sources that are needed by sources listed in
168+
# SRC_QSTR
169+
SRC_QSTR_AUTO_DEPS +=
170+
171+
include $(MPTOP)/py/mkrules.mk
172+
173+
# Value of configure's --host= option (required for cross-compilation).
174+
# Deduce it from CROSS_COMPILE by default, but can be overriden.
175+
ifneq ($(CROSS_COMPILE),)
176+
CROSS_COMPILE_HOST = --host=$(patsubst %-,%,$(CROSS_COMPILE))
177+
else
178+
CROSS_COMPILE_HOST =
179+
endif
180+
181+
deplibs: libffi axtls
182+
183+
# install-exec-recursive & install-data-am targets are used to avoid building
184+
# docs and depending on makeinfo
185+
libffi:
186+
cd ../lib/libffi; git clean -d -x -f
187+
cd ../lib/libffi; ./autogen.sh
188+
mkdir -p ../lib/libffi/build_dir; cd ../lib/libffi/build_dir; \
189+
../configure $(CROSS_COMPILE_HOST) --prefix=$$PWD/out CC="$(CC)" CXX="$(CXX)" LD="$(LD)"; \
190+
make install-exec-recursive; make -C include install-data-am
191+
192+
axtls: ../lib/axtls/README
193+
cd ../lib/axtls; cp config/upyconfig config/.config
194+
cd ../lib/axtls; make oldconfig -B
195+
cd ../lib/axtls; make clean
196+
cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)"
197+
198+
../lib/axtls/README:
199+
@echo "You cloned without --recursive, fetching submodules for you."
200+
(cd ..; git submodule update --init --recursive)

0 commit comments

Comments
 (0)