Skip to content

merge upstream master #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
Jul 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9626662
qemu-arm: Enable gcc LTO option for nlrthumb.c
tralamazza Jul 8, 2016
e9f3fb7
mpy-cross: Fix Makefile to handle gc-sections linker flags on OS X.
iSevenDays Jul 8, 2016
3593d8e
py/nlrx64.S: Prefix mp_thread_get_state with an underscore on Mac.
dpgeorge Jul 11, 2016
26d5e91
lib/axtls: Update, fixes esp8266 build.
pfalcon Jul 11, 2016
ee622cc
unix/mpthreadport: Adjust minimum thread stack, and stack limit check.
dpgeorge Jul 11, 2016
dfe056d
drivers/wiznet5k: Fix indentation so it's not misleading.
dpgeorge Jul 11, 2016
e32d1e1
extmod/modussl: Rename to modussl_axtls.c, to allow impl using other …
pfalcon Jul 12, 2016
20283ae
extmod/modussl_axtls: Further changes to allow alternative SSL modules.
pfalcon Jul 12, 2016
be313ea
esp8266: Select axTLS for SSL implementation, following recent refactor.
pfalcon Jul 12, 2016
ad9b9c7
py/stream: Implement 2- and 3-arg write() method as an extension to C…
pfalcon Jul 13, 2016
0b52228
tests: Add test for extended arguments to stream .write() method.
pfalcon Jul 14, 2016
780114e
extmod/modussl_axtls: Add dummy setblocking() method.
pfalcon Jul 14, 2016
0a6f599
extmod/vfs_fat: Implement rmdir() method.
pfalcon Jul 16, 2016
bcd0e9a
esp8266/moduos: Add rmdir() function.
pfalcon Jul 16, 2016
6aa7c80
esp8266: Cache Xtensa-built libaxtls.a in local build dir.
pfalcon Jul 16, 2016
bd6622a
unix: Cache libaxtls.a in local build dir.
pfalcon Jul 16, 2016
c3f519a
tests/extmod/machine_pinbase: Skip if machine.PinBase is not available.
pfalcon Jul 17, 2016
04c27e5
lib/utils/pyexec: Use full path to readline.h header, per latest conv…
pfalcon Jul 20, 2016
93e353e
py/gc: Implement GC running by allocation threshold.
pfalcon Jul 20, 2016
6881590
unix: Disable MICROPY_GC_ALLOC_THRESHOLD for minimal build.
pfalcon Jul 20, 2016
43963a8
minimal: Disable MICROPY_GC_ALLOC_THRESHOLD.
pfalcon Jul 20, 2016
26b7d8a
py: Fix nlrthumb.c when DEBUG=1 is defined
dhylands Jul 13, 2016
707cae7
py/obj: Issue a warning when str and bytes objects are compared.
pfalcon Jul 21, 2016
a1b442b
py/mpconfig.h: Fix description for MICROPY_PY_STR_BYTES_CMP_WARN.
pfalcon Jul 21, 2016
918851e
unix: Enable MICROPY_PY_STR_BYTES_CMP_WARN.
pfalcon Jul 21, 2016
40214b9
esp8266: Enable MICROPY_PY_STR_BYTES_CMP_WARN.
pfalcon Jul 21, 2016
b652ee7
tests/bytes_compare: Rework test for bytes <-> str comparison.
pfalcon Jul 22, 2016
4347337
lib/utils/stdout_helpers: Move from minimal/uart_extra.c for reuse.
pfalcon Jul 22, 2016
9bdb82e
mpy-cross: Use binary file translation mode for creating mpy files on…
stinos Jul 22, 2016
e47c2ec
wundows/README: Typo fix.
pfalcon Jul 22, 2016
1e77e25
examples/embedding: Example for embedding MicroPython in an app.
pfalcon Jun 15, 2016
4d4cfc2
examples/embedding: Add README.
pfalcon Jun 15, 2016
77f0cd8
esp8266: dupterm_task_init() should be called before running _boot.py…
pfalcon Jul 22, 2016
c141584
esp8266/_boot.py: Set GC alloc threshold to half of heap size.
pfalcon Jul 22, 2016
a53e0e5
extmod/modussl_axtls: Use mp_stream_close() method.
pfalcon Jul 22, 2016
614deb8
examples/http_client*: Be sure to close socket.
pfalcon Jul 22, 2016
2dd21d9
extmod/modwebrepl: Use mp_stream_close() method.
pfalcon Jul 22, 2016
0d22177
esp8266/_boot.py: Decrease GC alloc threshold to quarter of heap size.
pfalcon Jul 23, 2016
25df419
extmod/modbtree: Check __bt_open() return value for error.
pfalcon Jul 23, 2016
5a38694
tests/extmod/btree1: Close database at the end of test.
pfalcon Jul 23, 2016
1a7e28d
py/stream.h: Move mp_stream_write_adaptor() inside ifdef block.
pfalcon Jul 24, 2016
16f3246
py/stream.h: Remove dated comment of POSIX-specificity of EAGAIN.
pfalcon Jul 24, 2016
6af90b2
py/objstrunicode: str_index_to_ptr: Should handle bytes too.
pfalcon Jul 25, 2016
ed1c194
py/objstrunicode: str_index_to_ptr: Implement positive indexing prope…
pfalcon Jul 25, 2016
d1771bb
tests/unicode_subscr.py: Detailed test for subscripting unicode strings.
pfalcon Jul 25, 2016
243f898
unix/mpconfigport.h: Include stdio.h by default.
pfalcon Jul 25, 2016
f2f761c
py/stream: Stream module works with errno's, so should include mperrn…
pfalcon Jul 26, 2016
6ead9f6
tests/run-tests: Make "regex'ed .exp" facility available to device te…
pfalcon Jul 26, 2016
8fac939
unix/file: Implement MP_STREAM_FLUSH ioctl.
pfalcon Jul 26, 2016
ade3680
unix/file: ioctl(): Check that file is open before operations.
pfalcon Jul 26, 2016
a60b026
py/stream: Implement generic flush() method, in terms of C-level ioctl.
pfalcon Jul 26, 2016
0181606
unix/file: fdfile_ioctl(): Fix argument to check_fd_is_open().
pfalcon Jul 26, 2016
aa4ada9
esp8266/modpybuart: Fix UART parity setting.
daniel-k Jul 26, 2016
64da62e
unix/file: Use generic stream flush() method.
pfalcon Jul 27, 2016
f039ac5
py/objstringio: Add MP_STREAM_FLUSH ioctl and flush() method.
pfalcon Jul 27, 2016
3990b17
py/objstringio: Implement MP_STREAM_SEEK ioctl and add seek() method.
pfalcon Jul 27, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/wiznet5k/ethernet/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int8_t WIZCHIP_EXPORT(socket)(uint8_t sn, uint8_t protocol, uint16_t port, uint8
setSn_PORT(sn,port);
setSn_CR(sn,Sn_CR_OPEN);
while(getSn_CR(sn));
sock_io_mode |= ((flag & SF_IO_NONBLOCK) << sn);
sock_io_mode |= ((flag & SF_IO_NONBLOCK) << sn);
sock_is_sending &= ~(1<<sn);
sock_remained_size[sn] = 0;
sock_pack_info[sn] = 0;
Expand Down
8 changes: 6 additions & 2 deletions esp8266/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include ../py/mkenv.mk
QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h

MICROPY_PY_USSL = 1
MICROPY_SSL_AXTLS = 1

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

all: $(BUILD)/firmware-combined.bin
all: $(BUILD)/libaxtls.a $(BUILD)/firmware-combined.bin

CONFVARS_FILE = $(BUILD)/confvars

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

include ../py/mkrules.mk

axtls:
axtls: $(BUILD)/libaxtls.a

$(BUILD)/libaxtls.a:
cd ../lib/axtls; cp config/upyconfig config/.config
cd ../lib/axtls; make oldconfig -B
cd ../lib/axtls; make clean
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"
cp ../lib/axtls/_stage/libaxtls.a $@
2 changes: 1 addition & 1 deletion esp8266/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ STATIC void mp_reset(void) {
MP_STATE_PORT(dupterm_arr_obj) = MP_OBJ_NULL;
pin_init0();
readline_init0();
dupterm_task_init();
#if MICROPY_MODULE_FROZEN
pyexec_frozen_module("_boot.py");
pyexec_file("boot.py");
Expand All @@ -85,7 +86,6 @@ void init_done(void) {
#if MICROPY_REPL_EVENT_DRIVEN
pyexec_event_repl_init();
#endif
dupterm_task_init();

#if !MICROPY_REPL_EVENT_DRIVEN
soft_reset:
Expand Down
2 changes: 2 additions & 0 deletions esp8266/modpybuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ STATIC void pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const mp_o
if (args[ARG_parity].u_obj != MP_OBJ_NULL) {
if (args[ARG_parity].u_obj == mp_const_none) {
UartDev.parity = UART_NONE_BITS;
UartDev.exist_parity = UART_STICK_PARITY_DIS;
self->parity = 0;
} else {
mp_int_t parity = mp_obj_get_int(args[ARG_parity].u_obj);
UartDev.exist_parity = UART_STICK_PARITY_EN;
if (parity & 1) {
UartDev.parity = UART_ODD_BITS;
self->parity = 1;
Expand Down
1 change: 1 addition & 0 deletions esp8266/modules/_boot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gc
gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
import uos
from flashbdev import bdev

Expand Down
6 changes: 6 additions & 0 deletions esp8266/moduos.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ STATIC mp_obj_t os_mkdir(mp_obj_t path_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_mkdir_obj, os_mkdir);

STATIC mp_obj_t os_rmdir(mp_obj_t path_in) {
return vfs_proxy_call(MP_QSTR_rmdir, 1, &path_in);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir);

STATIC mp_obj_t os_chdir(mp_obj_t path_in) {
return vfs_proxy_call(MP_QSTR_chdir, 1, &path_in);
}
Expand Down Expand Up @@ -155,6 +160,7 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&os_listdir_obj) },
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&os_mkdir_obj) },
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&os_rmdir_obj) },
{ MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&os_chdir_obj) },
{ MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&os_getcwd_obj) },
{ MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&os_remove_obj) },
Expand Down
2 changes: 2 additions & 0 deletions esp8266/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
#define MICROPY_WARNINGS (1)
#define MICROPY_PY_STR_BYTES_CMP_WARN (1)
#define MICROPY_STREAMS_NON_BLOCK (1)
#define MICROPY_MODULE_FROZEN_STR (1)
#define MICROPY_MODULE_FROZEN_MPY (1)
Expand Down
10 changes: 6 additions & 4 deletions esp8266/uart.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef _INCLUDED_UART_H_
#define _INCLUDED_UART_H_

#include <eagle_soc.h>

#define UART0 (0)
#define UART1 (1)

Expand All @@ -18,14 +20,14 @@ typedef enum {
} UartStopBitsNum;

typedef enum {
UART_NONE_BITS = 0,
UART_ODD_BITS = 0,
UART_EVEN_BITS = BIT4
UART_NONE_BITS = 0,
UART_ODD_BITS = BIT0,
UART_EVEN_BITS = 0
} UartParityMode;

typedef enum {
UART_STICK_PARITY_DIS = 0,
UART_STICK_PARITY_EN = BIT3 | BIT5
UART_STICK_PARITY_EN = BIT1
} UartExistParity;

typedef enum {
Expand Down
8 changes: 8 additions & 0 deletions examples/embedding/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MPTOP = ../..
CFLAGS = -std=c99 -I. -I$(MPTOP) -DNO_QSTR
LDFLAGS = -L.

hello-embed: hello-embed.o -lmicropython

-lmicropython:
$(MAKE) -f $(MPTOP)/examples/embedding/Makefile.upylib MPTOP=$(MPTOP)
200 changes: 200 additions & 0 deletions examples/embedding/Makefile.upylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
MPTOP = ../..
-include mpconfigport.mk
include $(MPTOP)/py/mkenv.mk

all: lib

# OS name, for simple autoconfig
UNAME_S := $(shell uname -s)

# include py core make definitions
include $(MPTOP)/py/py.mk

INC += -I.
INC += -I..
INC += -I$(MPTOP)
INC += -I$(MPTOP)/unix
#INC += -I../lib/timeutils
INC += -I$(BUILD)

# compiler settings
CWARN = -Wall -Werror
CWARN += -Wpointer-arith -Wuninitialized
CFLAGS = $(INC) $(CWARN) -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)

# Debugging/Optimization
ifdef DEBUG
CFLAGS += -g
COPT = -O0
else
COPT = -Os #-DNDEBUG
# _FORTIFY_SOURCE is a feature in gcc/glibc which is intended to provide extra
# security for detecting buffer overflows. Some distros (Ubuntu at the very least)
# have it enabled by default.
#
# gcc already optimizes some printf calls to call puts and/or putchar. When
# _FORTIFY_SOURCE is enabled and compiling with -O1 or greater, then some
# printf calls will also be optimized to call __printf_chk (in glibc). Any
# printfs which get redirected to __printf_chk are then no longer synchronized
# with printfs that go through mp_printf.
#
# In MicroPython, we don't want to use the runtime library's printf but rather
# go through mp_printf, so that stdout is properly tied into streams, etc.
# This means that we either need to turn off _FORTIFY_SOURCE or provide our
# own implementation of __printf_chk. We've chosen to turn off _FORTIFY_SOURCE.
# It should also be noted that the use of printf in MicroPython is typically
# quite limited anyways (primarily for debug and some error reporting, etc
# in the unix version).
#
# Information about _FORTIFY_SOURCE seems to be rather scarce. The best I could
# find was this: https://securityblog.redhat.com/2014/03/26/fortify-and-you/
# Original patchset was introduced by
# https://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html .
#
# Turning off _FORTIFY_SOURCE is only required when compiling with -O1 or greater
CFLAGS += -U _FORTIFY_SOURCE
endif

# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed.
# The unix port of micropython on OSX must be compiled with clang,
# while cross-compile ports require gcc, so we test here for OSX and
# if necessary override the value of 'CC' set in py/mkenv.mk
ifeq ($(UNAME_S),Darwin)
CC = clang
# Use clang syntax for map file
LDFLAGS_ARCH = -Wl,-map,$@.map
else
# Use gcc syntax for map file
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
endif
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)

ifeq ($(MICROPY_FORCE_32BIT),1)
# Note: you may need to install i386 versions of dependency packages,
# starting with linux-libc-dev:i386
ifeq ($(MICROPY_PY_FFI),1)
ifeq ($(UNAME_S),Linux)
CFLAGS_MOD += -I/usr/include/i686-linux-gnu
endif
endif
endif

ifeq ($(MICROPY_USE_READLINE),1)
INC += -I../lib/mp-readline
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
LIB_SRC_C_EXTRA += mp-readline/readline.c
endif
ifeq ($(MICROPY_USE_READLINE),2)
CFLAGS_MOD += -DMICROPY_USE_READLINE=2
LDFLAGS_MOD += -lreadline
# the following is needed for BSD
#LDFLAGS_MOD += -ltermcap
endif
ifeq ($(MICROPY_PY_TIME),1)
CFLAGS_MOD += -DMICROPY_PY_TIME=1
SRC_MOD += modtime.c
endif
ifeq ($(MICROPY_PY_TERMIOS),1)
CFLAGS_MOD += -DMICROPY_PY_TERMIOS=1
SRC_MOD += modtermios.c
endif
ifeq ($(MICROPY_PY_SOCKET),1)
CFLAGS_MOD += -DMICROPY_PY_SOCKET=1
SRC_MOD += modsocket.c
endif

ifeq ($(MICROPY_PY_FFI),1)

ifeq ($(MICROPY_STANDALONE),1)
LIBFFI_CFLAGS_MOD := -I$(shell ls -1d ../lib/libffi/build_dir/out/lib/libffi-*/include)
ifeq ($(MICROPY_FORCE_32BIT),1)
LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib32/libffi.a
else
LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib/libffi.a
endif
else
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
endif

ifeq ($(UNAME_S),Linux)
LIBFFI_LDFLAGS_MOD += -ldl
endif

CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1
LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD)
SRC_MOD += modffi.c
endif

MAIN_C = main.c

# source files
SRC_C = $(addprefix $(MPTOP)/unix/,\
$(MAIN_C) \
gccollect.c \
unix_mphal.c \
input.c \
file.c \
modmachine.c \
modos.c \
moduselect.c \
alloc.c \
coverage.c \
fatfs_port.c \
$(SRC_MOD) \
)

LIB_SRC_C = $(addprefix lib/,\
$(LIB_SRC_C_EXTRA) \
utils/printf.c \
timeutils/timeutils.c \
)

ifeq ($(MICROPY_FATFS),1)
LIB_SRC_C += $(addprefix lib/,\
fatfs/ff.c \
fatfs/option/ccsbcs.c \
)
endif

OBJ = $(PY_O)
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(STMHAL_SRC_C:.c=.o))

# List of sources for qstr extraction
SRC_QSTR += $(SRC_C) $(LIB_SRC_C)
# Append any auto-generated sources that are needed by sources listed in
# SRC_QSTR
SRC_QSTR_AUTO_DEPS +=

include $(MPTOP)/py/mkrules.mk

# Value of configure's --host= option (required for cross-compilation).
# Deduce it from CROSS_COMPILE by default, but can be overriden.
ifneq ($(CROSS_COMPILE),)
CROSS_COMPILE_HOST = --host=$(patsubst %-,%,$(CROSS_COMPILE))
else
CROSS_COMPILE_HOST =
endif

deplibs: libffi axtls

# install-exec-recursive & install-data-am targets are used to avoid building
# docs and depending on makeinfo
libffi:
cd ../lib/libffi; git clean -d -x -f
cd ../lib/libffi; ./autogen.sh
mkdir -p ../lib/libffi/build_dir; cd ../lib/libffi/build_dir; \
../configure $(CROSS_COMPILE_HOST) --prefix=$$PWD/out CC="$(CC)" CXX="$(CXX)" LD="$(LD)"; \
make install-exec-recursive; make -C include install-data-am

axtls: ../lib/axtls/README
cd ../lib/axtls; cp config/upyconfig config/.config
cd ../lib/axtls; make oldconfig -B
cd ../lib/axtls; make clean
cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)"

../lib/axtls/README:
@echo "You cloned without --recursive, fetching submodules for you."
(cd ..; git submodule update --init --recursive)
Loading