diff --git a/MicroPython_BUILD/BUILD.sh b/MicroPython_BUILD/BUILD.sh index 05691012..84e05518 100755 --- a/MicroPython_BUILD/BUILD.sh +++ b/MicroPython_BUILD/BUILD.sh @@ -51,6 +51,7 @@ #======================= TOOLS_VER=ver20180515.id +BUILD_VER=ver20180516.id #======================= # ----------------------------- @@ -94,6 +95,7 @@ if [ $? -ne 0 ]; then exit 1 fi +# Goto base repository directory cd ../ # ----------------------------------- diff --git a/MicroPython_BUILD/build_func.sh b/MicroPython_BUILD/build_func.sh index c74cf805..34dfb6cc 100755 --- a/MicroPython_BUILD/build_func.sh +++ b/MicroPython_BUILD/build_func.sh @@ -319,9 +319,9 @@ check_OS() { # ================================================= #-------------------- check_Environment() { - # ---------------------------------------- - # Remove directories from previous version - # ---------------------------------------- + # -------------------------------------------------- + # Remove directories from early MicroPython versions + # -------------------------------------------------- if [ -d "esp-idf" ]; then rm -rf esp-idf/ > /dev/null 2>&1 rmdir esp-idf > /dev/null 2>&1 @@ -371,6 +371,9 @@ check_Environment() { rm -f *.id > /dev/null 2>&1 touch ${TOOLS_VER} echo "toolchains & esp-idf version" > ${TOOLS_VER} + rm -f ${BUILD_BASE_DIR}/*.id > /dev/null 2>&1 + touch ${BUILD_BASE_DIR}/${BUILD_VER} + echo "Build ID, do not delete this file" > ${BUILD_BASE_DIR}/${BUILD_VER} # remove executables rm -f ${BUILD_BASE_DIR}/components/mpy_cross_build/mpy-cross/mpy-cross > /dev/null 2>&1 rm -f ${BUILD_BASE_DIR}/components/mpy_cross_build/mpy-cross/mpy-cross.exe > /dev/null 2>&1 @@ -388,6 +391,22 @@ check_Environment() { rm -f ${BUILD_BASE_DIR}/sdkconfig.old > /dev/null 2>&1 rm -rf ${BUILD_BASE_DIR}/build/ > /dev/null 2>&1 rmdir ${BUILD_BASE_DIR}/build > /dev/null 2>&1 + else + # ----------------------- + # Check the build version + # ----------------------- + if [ ! -f "${BUILD_BASE_DIR}/${BUILD_VER}" ]; then + echo "Build updated, running menuconfig is needed..." + rm -f ${BUILD_BASE_DIR}/*.id > /dev/null 2>&1 + touch ${BUILD_BASE_DIR}/${BUILD_VER} + echo "Build ID, do not delete this file" > ${BUILD_BASE_DIR}/${BUILD_VER} + # remove build directory and configs + cp -f ${BUILD_BASE_DIR}/sdkconfig ${BUILD_BASE_DIR}/_sdkconfig.saved > /dev/null 2>&1 + rm -f ${BUILD_BASE_DIR}/sdkconfig > /dev/null 2>&1 + rm -f ${BUILD_BASE_DIR}/sdkconfig.old > /dev/null 2>&1 + rm -rf ${BUILD_BASE_DIR}/build/ > /dev/null 2>&1 + rmdir ${BUILD_BASE_DIR}/build > /dev/null 2>&1 + fi fi if [ ! -d "esp-idf" ]; then diff --git a/MicroPython_BUILD/components/micropython/Kconfig.projbuild b/MicroPython_BUILD/components/micropython/Kconfig.projbuild index ce337325..8efbc5dc 100644 --- a/MicroPython_BUILD/components/micropython/Kconfig.projbuild +++ b/MicroPython_BUILD/components/micropython/Kconfig.projbuild @@ -108,6 +108,13 @@ menu "MicroPython" Running without UNICODE support may solve some issues, also the string operations may be faster + config MICROPY_ENABLE_FINALISER + bool "Enable finalizer" + default y + help + Whether to enable finalisers in the garbage collector + If enabled, the __del__ methods of the objects will be called during garbage collect + config MICROPY_GC_COLLECT_RETVAL bool "gc.collect returns value" default n @@ -309,6 +316,20 @@ menu "MicroPython" help Include GSM module and PPPoS support into build + config MICROPY_USE_GPS + bool "Use GPS module" + default y + help + Include GPS module into build + + config MICROPY_GPS_SERVICE_STACK + int "GPS service stack size" + depends on MICROPY_USE_GPS + default 3072 + range 3072 6144 + help + Set the stack size of GPS service task + config MICROPY_USE_ETHERNET bool "Use Ethernet module" default n @@ -337,20 +358,6 @@ menu "MicroPython" Include CURL module into build Using CURL module will add ~230 KB to your flash code size - config MICROPY_USE_GPS - bool "Use GPS module" - default y - help - Include GPS module into build - - config MICROPY_GPS_SERVICE_STACK - int "GPS service stack size" - depends on MICROPY_USE_GPS - default 3072 - range 3072 6144 - help - Set the stack size of GPS service task - config MICROPY_USE_CURL_TLS bool "Enable TLS in Curl module" depends on MICROPY_USE_CURL diff --git a/MicroPython_BUILD/components/micropython/esp32/gccollect.c b/MicroPython_BUILD/components/micropython/esp32/gccollect.c index ba62aaaf..d8f0f333 100644 --- a/MicroPython_BUILD/components/micropython/esp32/gccollect.c +++ b/MicroPython_BUILD/components/micropython/esp32/gccollect.c @@ -38,7 +38,8 @@ #include "soc/cpu.h" #include "xtensa/hal.h" -/* +static int n_marked; + static void gc_collect_inner(int level, int flag) { if (level < XCHAL_NUM_AREGS / 8) { @@ -49,34 +50,23 @@ static void gc_collect_inner(int level, int flag) } if (level == XCHAL_NUM_AREGS / 8) { - #if MICROPY_PY_GC_COLLECT_RETVAL - int n_marked = MP_STATE_MEM(gc_marked); - #endif + n_marked = MP_STATE_MEM(gc_marked); // get the stack pointer volatile uint32_t sp = (uint32_t)get_sp(); gc_collect_root((void**)sp, ((mp_uint_t)MP_STATE_THREAD(stack_top) - sp) / sizeof(uint32_t)); - //volatile uint32_t sp = mp_thread_get_sp(); - //gc_collect_root(sp, ((mp_uint_t)MP_STATE_THREAD(stack_top) - sp) / sizeof(uint32_t)); - #if MICROPY_PY_GC_COLLECT_RETVAL if ((flag) && ((MP_STATE_MEM(gc_marked) - n_marked) > 0)) printf("gc_collect: marked on stack: %d (%p - %p)\n", MP_STATE_MEM(gc_marked) - n_marked, (void *)sp, (void *)MP_STATE_THREAD(stack_top)); - #endif return; } // Trace root pointers from other threads - #if MICROPY_PY_GC_COLLECT_RETVAL int n_marked = MP_STATE_MEM(gc_marked); - #endif mp_thread_gc_others(flag); - #if MICROPY_PY_GC_COLLECT_RETVAL if ((flag) && ((MP_STATE_MEM(gc_marked) - n_marked) > 0)) printf("gc_collect: marked on others: %d\n", MP_STATE_MEM(gc_marked) - n_marked); - #endif } -*/ //----------------------- void gc_collect(int flag) @@ -91,35 +81,10 @@ void gc_collect(int flag) // Trace root pointers. gc_collect_start(); - #if MICROPY_PY_GC_COLLECT_RETVAL if (flag) printf("gc_collect: marked on START: %d (th='%s')\n", MP_STATE_MEM(gc_marked), th_name); - #endif - - // ---- Collect inner ------------------------------------------------------- - //gc_collect_inner(0, flag); - #if MICROPY_PY_GC_COLLECT_RETVAL - int n_marked = MP_STATE_MEM(gc_marked); - #endif - - // get the stack pointer - volatile uint32_t sp = (uint32_t)get_sp(); - gc_collect_root((void**)sp, ((mp_uint_t)MP_STATE_THREAD(stack_top) - sp) / sizeof(uint32_t)); - - #if MICROPY_PY_GC_COLLECT_RETVAL - if ((flag) && ((MP_STATE_MEM(gc_marked) - n_marked) > 0)) printf("gc_collect: marked on stack: %d (%p - %p)\n", MP_STATE_MEM(gc_marked) - n_marked, (void *)sp, (void *)MP_STATE_THREAD(stack_top)); - #endif - // Trace root pointers from other threads - #if MICROPY_PY_GC_COLLECT_RETVAL - n_marked = MP_STATE_MEM(gc_marked); - #endif - - mp_thread_gc_others(flag); - - #if MICROPY_PY_GC_COLLECT_RETVAL - if ((flag) && ((MP_STATE_MEM(gc_marked) - n_marked) > 0)) printf("gc_collect: marked on others: %d\n", MP_STATE_MEM(gc_marked) - n_marked); - #endif // ---- Collect inner ------------------------------------------------------- + gc_collect_inner(0, flag); if (flag > 1) { mp_thread_mutex_unlock(&(mp_state_ctx.mem.gc_mutex)); @@ -127,17 +92,13 @@ void gc_collect(int flag) mp_thread_mutex_lock(&(mp_state_ctx.mem.gc_mutex), 1); } - #if MICROPY_PY_GC_COLLECT_RETVAL n_marked = MP_STATE_MEM(gc_marked); - #endif gc_collect_end(); - #if MICROPY_PY_GC_COLLECT_RETVAL if (flag) { if ((MP_STATE_MEM(gc_marked) - n_marked) > 0) printf("gc_collect: marked on end: %d\n", MP_STATE_MEM(gc_marked) - n_marked); printf("gc_collect: marked total: %d; collected: %d\n", MP_STATE_MEM(gc_marked), MP_STATE_MEM(gc_collected)); } - #endif if (flag > 1) gc_dump_alloc_table(); } diff --git a/MicroPython_BUILD/components/micropython/esp32/modsocket.c b/MicroPython_BUILD/components/micropython/esp32/modsocket.c index 76ef5b94..71f57c56 100644 --- a/MicroPython_BUILD/components/micropython/esp32/modsocket.c +++ b/MicroPython_BUILD/components/micropython/esp32/modsocket.c @@ -48,6 +48,7 @@ #include "py/mperrno.h" #include "lib/netutils/netutils.h" #include "tcpip_adapter.h" +#include "modnetwork.h" #include "lwip/sockets.h" #include "lwip/netdb.h" @@ -622,29 +623,29 @@ STATIC mp_uint_t socket_stream_ioctl(mp_obj_t self_in, mp_uint_t request, uintpt return MP_STREAM_ERROR; } -STATIC const mp_map_elem_t socket_locals_dict_table[] = { - { MP_OBJ_NEW_QSTR(MP_QSTR___del__), (mp_obj_t)&mp_stream_close_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_close), (mp_obj_t)&mp_stream_close_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_bind), (mp_obj_t)&socket_bind_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_listen), (mp_obj_t)&socket_listen_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_accept), (mp_obj_t)&socket_accept_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_accepted), (mp_obj_t)&socket_accepted_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_connect), (mp_obj_t)&socket_connect_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_send), (mp_obj_t)&socket_send_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_sendall), (mp_obj_t)&socket_sendall_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_sendto), (mp_obj_t)&socket_sendto_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_recv), (mp_obj_t)&socket_recv_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_recvfrom), (mp_obj_t)&socket_recvfrom_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_setsockopt), (mp_obj_t)&socket_setsockopt_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_settimeout), (mp_obj_t)&socket_settimeout_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_setblocking), (mp_obj_t)&socket_setblocking_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_makefile), (mp_obj_t)&socket_makefile_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_fileno), (mp_obj_t)&socket_fileno_obj }, - - { MP_OBJ_NEW_QSTR(MP_QSTR_read), (mp_obj_t)&mp_stream_read_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_readinto), (mp_obj_t)&mp_stream_readinto_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_readline), (mp_obj_t)&mp_stream_unbuffered_readline_obj}, - { MP_OBJ_NEW_QSTR(MP_QSTR_write), (mp_obj_t)&mp_stream_write_obj }, +STATIC const mp_rom_map_elem_t socket_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_stream_close_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) }, + { MP_ROM_QSTR(MP_QSTR_bind), MP_ROM_PTR(&socket_bind_obj) }, + { MP_ROM_QSTR(MP_QSTR_listen), MP_ROM_PTR(&socket_listen_obj) }, + { MP_ROM_QSTR(MP_QSTR_accept), MP_ROM_PTR(&socket_accept_obj) }, + { MP_ROM_QSTR(MP_QSTR_accepted), MP_ROM_PTR(&socket_accepted_obj) }, + { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&socket_connect_obj) }, + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&socket_send_obj) }, + { MP_ROM_QSTR(MP_QSTR_sendall), MP_ROM_PTR(&socket_sendall_obj) }, + { MP_ROM_QSTR(MP_QSTR_sendto), MP_ROM_PTR(&socket_sendto_obj) }, + { MP_ROM_QSTR(MP_QSTR_recv), MP_ROM_PTR(&socket_recv_obj) }, + { MP_ROM_QSTR(MP_QSTR_recvfrom), MP_ROM_PTR(&socket_recvfrom_obj) }, + { MP_ROM_QSTR(MP_QSTR_setsockopt), MP_ROM_PTR(&socket_setsockopt_obj) }, + { MP_ROM_QSTR(MP_QSTR_settimeout), MP_ROM_PTR(&socket_settimeout_obj) }, + { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socket_setblocking_obj) }, + { MP_ROM_QSTR(MP_QSTR_makefile), MP_ROM_PTR(&socket_makefile_obj) }, + { MP_ROM_QSTR(MP_QSTR_fileno), MP_ROM_PTR(&socket_fileno_obj) }, + + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, }; STATIC MP_DEFINE_CONST_DICT(socket_locals_dict, socket_locals_dict_table); @@ -735,23 +736,23 @@ STATIC mp_obj_t esp_socket_initialize() { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_socket_initialize_obj, esp_socket_initialize); -STATIC const mp_map_elem_t mp_module_socket_globals_table[] = { - { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usocket) }, - { MP_OBJ_NEW_QSTR(MP_QSTR___init__), (mp_obj_t)&esp_socket_initialize_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&get_socket_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_getaddrinfo), (mp_obj_t)&esp_socket_getaddrinfo_obj }, - - { MP_OBJ_NEW_QSTR(MP_QSTR_AF_INET), MP_OBJ_NEW_SMALL_INT(AF_INET) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_AF_INET6), MP_OBJ_NEW_SMALL_INT(AF_INET6) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_SOCK_STREAM), MP_OBJ_NEW_SMALL_INT(SOCK_STREAM) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_SOCK_DGRAM), MP_OBJ_NEW_SMALL_INT(SOCK_DGRAM) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_SOCK_RAW), MP_OBJ_NEW_SMALL_INT(SOCK_RAW) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_IPPROTO_TCP), MP_OBJ_NEW_SMALL_INT(IPPROTO_TCP) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_IPPROTO_UDP), MP_OBJ_NEW_SMALL_INT(IPPROTO_UDP) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_IPPROTO_IP), MP_OBJ_NEW_SMALL_INT(IPPROTO_IP) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_SOL_SOCKET), MP_OBJ_NEW_SMALL_INT(SOL_SOCKET) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_SO_REUSEADDR), MP_OBJ_NEW_SMALL_INT(SO_REUSEADDR) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_IP_ADD_MEMBERSHIP), MP_OBJ_NEW_SMALL_INT(IP_ADD_MEMBERSHIP) }, +STATIC const mp_rom_map_elem_t mp_module_socket_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usocket) }, + { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&esp_socket_initialize_obj) }, + { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&get_socket_obj) }, + { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&esp_socket_getaddrinfo_obj) }, + + { MP_ROM_QSTR(MP_QSTR_AF_INET), MP_ROM_INT(AF_INET) }, + { MP_ROM_QSTR(MP_QSTR_AF_INET6), MP_ROM_INT(AF_INET6) }, + { MP_ROM_QSTR(MP_QSTR_SOCK_STREAM), MP_ROM_INT(SOCK_STREAM) }, + { MP_ROM_QSTR(MP_QSTR_SOCK_DGRAM), MP_ROM_INT(SOCK_DGRAM) }, + { MP_ROM_QSTR(MP_QSTR_SOCK_RAW), MP_ROM_INT(SOCK_RAW) }, + { MP_ROM_QSTR(MP_QSTR_IPPROTO_TCP), MP_ROM_INT(IPPROTO_TCP) }, + { MP_ROM_QSTR(MP_QSTR_IPPROTO_UDP), MP_ROM_INT(IPPROTO_UDP) }, + { MP_ROM_QSTR(MP_QSTR_IPPROTO_IP), MP_ROM_INT(IPPROTO_IP) }, + { MP_ROM_QSTR(MP_QSTR_SOL_SOCKET), MP_ROM_INT(SOL_SOCKET) }, + { MP_ROM_QSTR(MP_QSTR_SO_REUSEADDR), MP_ROM_INT(SO_REUSEADDR) }, + { MP_ROM_QSTR(MP_QSTR_IP_ADD_MEMBERSHIP), MP_ROM_INT(IP_ADD_MEMBERSHIP) }, }; STATIC MP_DEFINE_CONST_DICT(mp_module_socket_globals, mp_module_socket_globals_table); diff --git a/MicroPython_BUILD/components/micropython/esp32/modules/logging.py b/MicroPython_BUILD/components/micropython/esp32/modules/logging.py index 1c3ef0d8..cea2de03 100644 --- a/MicroPython_BUILD/components/micropython/esp32/modules/logging.py +++ b/MicroPython_BUILD/components/micropython/esp32/modules/logging.py @@ -19,18 +19,30 @@ class Logger: + level = NOTSET + def __init__(self, name): - self.level = NOTSET self.name = name def _level_str(self, level): - if level in _level_dict: - return _level_dict[level] - return "LVL" + str(level) + l = _level_dict.get(level) + if l is not None: + return l + return "LVL%s" % level + + def setLevel(self, level): + self.level = level + + def isEnabledFor(self, level): + return level >= (self.level or _level) def log(self, level, msg, *args): if level >= (self.level or _level): - print(("%s:%s:" + msg) % ((self._level_str(level), self.name) + args), file=_stream) + _stream.write("%s:%s:" % (self._level_str(level), self.name)) + if not args: + print(msg, file=_stream) + else: + print(msg % args, file=_stream) def debug(self, msg, *args): self.log(DEBUG, msg, *args) @@ -47,6 +59,13 @@ def error(self, msg, *args): def critical(self, msg, *args): self.log(CRITICAL, msg, *args) + def exc(self, e, msg, *args): + self.log(ERROR, msg, *args) + sys.print_exception(e, _stream) + + def exception(self, msg, *args): + self.exc(sys.exc_info()[1], msg, *args) + _level = INFO _loggers = {} diff --git a/MicroPython_BUILD/components/micropython/esp32/modules/upip.py b/MicroPython_BUILD/components/micropython/esp32/modules/upip.py index e9abd909..788df465 100644 --- a/MicroPython_BUILD/components/micropython/esp32/modules/upip.py +++ b/MicroPython_BUILD/components/micropython/esp32/modules/upip.py @@ -1,3 +1,10 @@ +# +# upip - Package manager for MicroPython +# +# Copyright (c) 2015-2018 Paul Sokolovsky +# +# Licensed under the MIT license. +# import sys import gc import uos as os @@ -5,7 +12,6 @@ import ujson as json import uzlib import upip_utarfile as tarfile -gc.collect() debug = False @@ -93,6 +99,11 @@ def install_tar(f, prefix): save_file(outfname, subf) return meta +def expandhome(s): + if "~/" in s: + h = os.getenv("HOME") + s = s.replace("~/", h + "/") + return s import ussl import usocket @@ -105,16 +116,16 @@ def url_open(url): proto, _, host, urlpath = url.split('/', 3) try: - ai = usocket.getaddrinfo(host, 443) + ai = usocket.getaddrinfo(host, 443, 0, usocket.SOCK_STREAM) except OSError as e: fatal("Unable to resolve %s (no Internet?)" % host, e) #print("Address infos:", ai) - addr = ai[0][4] + ai = ai[0] - s = usocket.socket(ai[0][0]) + s = usocket.socket(ai[0], ai[1], ai[2]) try: #print("Connect address:", addr) - s.connect(addr) + s.connect(ai[-1]) if proto == "https:": s = ussl.wrap_socket(s, server_hostname=host) @@ -181,6 +192,7 @@ def install_pkg(pkg_spec, install_path): return meta def install(to_install, install_path=None): + gc.collect() # Calculate gzip dictionary size to use global gzdict_sz sz = gc.mem_free() + gc.mem_alloc() @@ -212,13 +224,17 @@ def install(to_install, install_path=None): deps = deps.decode("utf-8").split("\n") to_install.extend(deps) except Exception as e: - print("Error installing '{}': {}, packages may be partially installed".format(pkg_spec, e)) + print("Error installing '{}': {}, packages may be partially installed".format( + pkg_spec, e), + file=sys.stderr) + gc.collect() def get_install_path(): global install_path if install_path is None: # sys.path[0] is current module's path install_path = sys.path[1] + install_path = expandhome(install_path) return install_path def cleanup(): diff --git a/MicroPython_BUILD/components/micropython/esp32/modules/urequests.py b/MicroPython_BUILD/components/micropython/esp32/modules/urequests.py index cdd5b5ff..acb220e8 100644 --- a/MicroPython_BUILD/components/micropython/esp32/modules/urequests.py +++ b/MicroPython_BUILD/components/micropython/esp32/modules/urequests.py @@ -16,9 +16,11 @@ def close(self): @property def content(self): if self._cached is None: - self._cached = self.raw.read() - self.raw.close() - self.raw = None + try: + self._cached = self.raw.read() + finally: + self.raw.close() + self.raw = None return self._cached @property @@ -48,49 +50,58 @@ def request(method, url, data=None, json=None, headers={}, stream=None): host, port = host.split(":", 1) port = int(port) - ai = usocket.getaddrinfo(host, port) - addr = ai[0][-1] - s = usocket.socket() - s.connect(addr) - if proto == "https:": - s = ussl.wrap_socket(s, server_hostname=host) - s.write(b"%s /%s HTTP/1.0\r\n" % (method, path)) - if not "Host" in headers: - s.write(b"Host: %s\r\n" % host) - # Iterate over keys to avoid tuple alloc - for k in headers: - s.write(k) - s.write(b": ") - s.write(headers[k]) + ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM) + ai = ai[0] + + s = usocket.socket(ai[0], ai[1], ai[2]) + try: + s.connect(ai[-1]) + if proto == "https:": + s = ussl.wrap_socket(s, server_hostname=host) + s.write(b"%s /%s HTTP/1.0\r\n" % (method, path)) + if not "Host" in headers: + s.write(b"Host: %s\r\n" % host) + # Iterate over keys to avoid tuple alloc + for k in headers: + s.write(k) + s.write(b": ") + s.write(headers[k]) + s.write(b"\r\n") + if json is not None: + assert data is None + import ujson + data = ujson.dumps(json) + s.write(b"Content-Type: application/json\r\n") + if data: + s.write(b"Content-Length: %d\r\n" % len(data)) s.write(b"\r\n") - if json is not None: - assert data is None - import ujson - data = ujson.dumps(json) - if data: - s.write(b"Content-Length: %d\r\n" % len(data)) - s.write(b"\r\n") - if data: - s.write(data) - - l = s.readline() - protover, status, msg = l.split(None, 2) - status = int(status) - #print(protover, status, msg) - while True: + if data: + s.write(data) + l = s.readline() - if not l or l == b"\r\n": - break #print(l) - if l.startswith(b"Transfer-Encoding:"): - if b"chunked" in l: - raise ValueError("Unsupported " + l) - elif l.startswith(b"Location:") and not 200 <= status <= 299: - raise NotImplementedError("Redirects not yet supported") + l = l.split(None, 2) + status = int(l[1]) + reason = "" + if len(l) > 2: + reason = l[2].rstrip() + while True: + l = s.readline() + if not l or l == b"\r\n": + break + #print(l) + if l.startswith(b"Transfer-Encoding:"): + if b"chunked" in l: + raise ValueError("Unsupported " + l) + elif l.startswith(b"Location:") and not 200 <= status <= 299: + raise NotImplementedError("Redirects not yet supported") + except OSError: + s.close() + raise resp = Response(s) resp.status_code = status - resp.reason = msg.rstrip() + resp.reason = reason return resp diff --git a/MicroPython_BUILD/components/micropython/esp32/mpconfigport.h b/MicroPython_BUILD/components/micropython/esp32/mpconfigport.h index a9c047a5..c01ecbab 100644 --- a/MicroPython_BUILD/components/micropython/esp32/mpconfigport.h +++ b/MicroPython_BUILD/components/micropython/esp32/mpconfigport.h @@ -84,7 +84,12 @@ // This helps eliminate stray pointers that hold on to memory that's no longer used. // It decreases performance due to unnecessary memory clearing. #define MICROPY_GC_CONSERVATIVE_CLEAR (1) +// Whether to enable finalisers in the garbage collector (ie call __del__) +#ifdef CONFIG_MICROPY_ENABLE_FINALISER #define MICROPY_ENABLE_FINALISER (1) +#else +#define MICROPY_ENABLE_FINALISER (0) +#endif #define MICROPY_STACK_CHECK (1) #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1) #define MICROPY_KBD_EXCEPTION (1) @@ -201,7 +206,7 @@ #define MICROPY_PY_MACHINE_SPI_MAKE_NEW machine_hw_spi_make_new #define MICROPY_PY_USSL (1) #define MICROPY_SSL_MBEDTLS (1) -#define MICROPY_PY_USSL_FINALISER (1) +#define MICROPY_PY_USSL_FINALISER (0) // Crashes on gc if enabled! #define MICROPY_PY_UHASHLIB (0) // We use the ESP32 version #define MICROPY_PY_UHASHLIB_SHA1 (MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS) diff --git a/MicroPython_BUILD/components/micropython/esp32/mpversion.h b/MicroPython_BUILD/components/micropython/esp32/mpversion.h index a98fdf70..32e763dc 100644 --- a/MicroPython_BUILD/components/micropython/esp32/mpversion.h +++ b/MicroPython_BUILD/components/micropython/esp32/mpversion.h @@ -24,14 +24,14 @@ * THE SOFTWARE. */ -#define MICROPY_GIT_TAG "ESP32_LoBo_v3.2.16" +#define MICROPY_GIT_TAG "ESP32_LoBo_v3.2.17" #define MICROPY_ESPIDF_HASH "a2556229aa6f55b16b171e3325ee9ab1943e8552" #define MICROPY_ESPIDF_VERSION "v3.1-dev-961-ga2556229" #define MICROPY_ESPIDF_DATE "2018-05-08" -#define MICROPY_BUILD_DATE "2018-05-15" +#define MICROPY_BUILD_DATE "2018-05-16" #define MICROPY_VERSION_MAJOR (3) #define MICROPY_VERSION_MINOR (2) -#define MICROPY_VERSION_MICRO (16) -#define MICROPY_VERSION_STRING "3.2.16" -#define MICROPY_CORE_VERSION "59dda71" -#define MICROPY_CORE_DATE "2018-04-10" +#define MICROPY_VERSION_MICRO (17) +#define MICROPY_VERSION_STRING "3.2.17" +#define MICROPY_CORE_VERSION "1b7487e" +#define MICROPY_CORE_DATE "2018-05-16" diff --git a/MicroPython_BUILD/components/micropython/extmod/modlwip.c b/MicroPython_BUILD/components/micropython/extmod/modlwip.c index 234dedd9..66410331 100644 --- a/MicroPython_BUILD/components/micropython/extmod/modlwip.c +++ b/MicroPython_BUILD/components/micropython/extmod/modlwip.c @@ -1133,7 +1133,8 @@ STATIC mp_uint_t lwip_socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_ ret |= MP_STREAM_POLL_RD; } - if (flags & MP_STREAM_POLL_WR && tcp_sndbuf(socket->pcb.tcp) > 0) { + // Note: pcb.tcp==NULL if state<0, and in this case we can't call tcp_sndbuf + if (flags & MP_STREAM_POLL_WR && socket->pcb.tcp != NULL && tcp_sndbuf(socket->pcb.tcp) > 0) { ret |= MP_STREAM_POLL_WR; } @@ -1142,6 +1143,13 @@ STATIC mp_uint_t lwip_socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_ // return EOF, write - error. Without this poll will hang on a // socket which was closed by peer. ret |= flags & (MP_STREAM_POLL_RD | MP_STREAM_POLL_WR); + } else if (socket->state == ERR_RST) { + // Socket was reset by peer, a write will return an error + ret |= flags & (MP_STREAM_POLL_WR | MP_STREAM_POLL_HUP); + } else if (socket->state < 0) { + // Socket in some other error state, use catch-all ERR flag + // TODO: may need to set other return flags here + ret |= flags & MP_STREAM_POLL_ERR; } } else if (request == MP_STREAM_CLOSE) { @@ -1176,7 +1184,6 @@ STATIC mp_uint_t lwip_socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_ } ret = 0; - } else { *errcode = MP_EINVAL; ret = MP_STREAM_ERROR; @@ -1294,14 +1301,33 @@ STATIC void lwip_getaddrinfo_cb(const char *name, ip_addr_t *ipaddr, void *arg) // lwip.getaddrinfo STATIC mp_obj_t lwip_getaddrinfo(size_t n_args, const mp_obj_t *args) { - if (n_args > 2) { - mp_warning("getaddrinfo constraints not supported"); - } - mp_obj_t host_in = args[0], port_in = args[1]; const char *host = mp_obj_str_get_str(host_in); mp_int_t port = mp_obj_get_int(port_in); + // If constraints were passed then check they are compatible with the supported params + if (n_args > 2) { + mp_int_t family = mp_obj_get_int(args[2]); + mp_int_t type = 0; + mp_int_t proto = 0; + mp_int_t flags = 0; + if (n_args > 3) { + type = mp_obj_get_int(args[3]); + if (n_args > 4) { + proto = mp_obj_get_int(args[4]); + if (n_args > 5) { + flags = mp_obj_get_int(args[5]); + } + } + } + if (!((family == 0 || family == MOD_NETWORK_AF_INET) + && (type == 0 || type == MOD_NETWORK_SOCK_STREAM) + && proto == 0 + && flags == 0)) { + mp_warning("unsupported getaddrinfo constraints"); + } + } + getaddrinfo_state_t state; state.status = 0; diff --git a/MicroPython_BUILD/components/micropython/extmod/uzlib/tinflate.c b/MicroPython_BUILD/components/micropython/extmod/uzlib/tinflate.c index 58850eb4..21558af5 100644 --- a/MicroPython_BUILD/components/micropython/extmod/uzlib/tinflate.c +++ b/MicroPython_BUILD/components/micropython/extmod/uzlib/tinflate.c @@ -394,9 +394,11 @@ static int tinf_inflate_uncompressed_block(TINF_DATA *d) unsigned int length, invlength; /* get length */ - length = uzlib_get_byte(d) + 256 * uzlib_get_byte(d); + length = uzlib_get_byte(d); + length += 256 * uzlib_get_byte(d); /* get one's complement of length */ - invlength = uzlib_get_byte(d) + 256 * uzlib_get_byte(d); + invlength = uzlib_get_byte(d); + invlength += 256 * uzlib_get_byte(d); /* check length */ if (length != (~invlength & 0x0000ffff)) return TINF_DATA_ERROR; diff --git a/MicroPython_BUILD/components/micropython/extmod/vfs.c b/MicroPython_BUILD/components/micropython/extmod/vfs.c index d2c6c746..5de21f55 100644 --- a/MicroPython_BUILD/components/micropython/extmod/vfs.c +++ b/MicroPython_BUILD/components/micropython/extmod/vfs.c @@ -127,8 +127,26 @@ mp_import_stat_t mp_vfs_import_stat(const char *path) { if (mp_obj_get_type(vfs->obj) == &mp_native_vfs_type) { return native_vfs_import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out); } - // TODO delegate to vfs.stat() method - return MP_IMPORT_STAT_NO_EXIST; + + // delegate to vfs.stat() method + mp_obj_t path_o = mp_obj_new_str(path_out, strlen(path_out)); + mp_obj_t stat; + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + stat = mp_vfs_proxy_call(vfs, MP_QSTR_stat, 1, &path_o); + nlr_pop(); + } else { + // assume an exception means that the path is not found + return MP_IMPORT_STAT_NO_EXIST; + } + mp_obj_t *items; + mp_obj_get_array_fixed_n(stat, 10, &items); + mp_int_t st_mode = mp_obj_get_int(items[0]); + if (st_mode & MP_S_IFDIR) { + return MP_IMPORT_STAT_DIR; + } else { + return MP_IMPORT_STAT_FILE; + } } mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -258,7 +276,7 @@ mp_obj_t mp_vfs_chdir(mp_obj_t path_in) { // subsequent relative paths begin at the root of that VFS. for (vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { if (vfs->len == 1) { - mp_obj_t root = mp_obj_new_str("/", 1); + mp_obj_t root = MP_OBJ_NEW_QSTR(MP_QSTR__slash_); mp_vfs_proxy_call(vfs, MP_QSTR_chdir, 1, &root); break; } @@ -315,7 +333,7 @@ STATIC mp_obj_t mp_vfs_ilistdir_it_iternext(mp_obj_t self_in) { self->cur.vfs = vfs->next; if (vfs->len == 1) { // vfs is mounted at root dir, delegate to it - mp_obj_t root = mp_obj_new_str("/", 1); + mp_obj_t root = MP_OBJ_NEW_QSTR(MP_QSTR__slash_); self->is_iter = true; self->cur.iter = mp_vfs_proxy_call(vfs, MP_QSTR_ilistdir, 1, &root); return mp_iternext(self->cur.iter); diff --git a/MicroPython_BUILD/components/micropython/py/gc.c b/MicroPython_BUILD/components/micropython/py/gc.c index 0f11e70f..b1f6f7ee 100644 --- a/MicroPython_BUILD/components/micropython/py/gc.c +++ b/MicroPython_BUILD/components/micropython/py/gc.c @@ -230,9 +230,7 @@ STATIC void gc_mark_subtree(size_t block) { // an unmarked head, mark it, and push it on gc stack TRACE_MARK(childblock, ptr); ATB_HEAD_TO_MARK(childblock); - #if MICROPY_PY_GC_COLLECT_RETVAL MP_STATE_MEM(gc_marked)++; - #endif if (sp < MICROPY_ALLOC_GC_STACK_SIZE) { MP_STATE_MEM(gc_stack)[sp++] = childblock; } else { @@ -267,9 +265,7 @@ STATIC void gc_deal_with_stack_overflow(void) { } STATIC void gc_sweep(void) { - #if MICROPY_PY_GC_COLLECT_RETVAL MP_STATE_MEM(gc_collected) = 0; - #endif // free unmarked heads and their tails int free_tail = 0; for (size_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) { @@ -299,9 +295,7 @@ STATIC void gc_sweep(void) { #endif free_tail = 1; DEBUG_printf("gc_sweep(%p)\n", (void*)PTR_FROM_BLOCK(block)); - #if MICROPY_PY_GC_COLLECT_RETVAL MP_STATE_MEM(gc_collected)++; - #endif // no break, fall through to free the head case AT_TAIL: @@ -323,9 +317,7 @@ STATIC void gc_sweep(void) { void gc_collect_start(void) { GC_ENTER(); - #if MICROPY_PY_GC_COLLECT_RETVAL MP_STATE_MEM(gc_marked) = 0; - #endif MP_STATE_MEM(gc_lock_depth)++; #if MICROPY_GC_ALLOC_THRESHOLD MP_STATE_MEM(gc_alloc_amount) = 0; @@ -354,9 +346,7 @@ void gc_collect_root(void **ptrs, size_t len) { // An unmarked head: mark it, and mark all its children TRACE_MARK(block, ptr); ATB_HEAD_TO_MARK(block); - #if MICROPY_PY_GC_COLLECT_RETVAL MP_STATE_MEM(gc_marked)++; - #endif gc_mark_subtree(block); } } diff --git a/MicroPython_BUILD/components/micropython/py/makeqstrdata.py b/MicroPython_BUILD/components/micropython/py/makeqstrdata.py index 38fde1a9..3c0a6090 100644 --- a/MicroPython_BUILD/components/micropython/py/makeqstrdata.py +++ b/MicroPython_BUILD/components/micropython/py/makeqstrdata.py @@ -114,6 +114,9 @@ def parse_input_headers(infiles): if ident == "": # Sort empty qstr above all still order = -200000 + elif ident == "__dir__": + # Put __dir__ after empty qstr for builtin dir() to work + order = -190000 elif ident.startswith("__"): order -= 100000 qstrs[ident] = (order, ident, qstr) diff --git a/MicroPython_BUILD/components/micropython/py/modbuiltins.c b/MicroPython_BUILD/components/micropython/py/modbuiltins.c index bf84e678..23c21ca2 100644 --- a/MicroPython_BUILD/components/micropython/py/modbuiltins.c +++ b/MicroPython_BUILD/components/micropython/py/modbuiltins.c @@ -187,10 +187,17 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) { // Make a list of names in the given object // Implemented by probing all possible qstrs with mp_load_method_maybe size_t nqstr = QSTR_TOTAL(); - for (size_t i = 1; i < nqstr; ++i) { + for (size_t i = MP_QSTR_ + 1; i < nqstr; ++i) { mp_obj_t dest[2]; - mp_load_method_maybe(args[0], i, dest); + mp_load_method_protected(args[0], i, dest, false); if (dest[0] != MP_OBJ_NULL) { + #if MICROPY_PY_ALL_SPECIAL_METHODS + // Support for __dir__: see if we can dispatch to this special method + // This relies on MP_QSTR__dir__ being first after MP_QSTR_ + if (i == MP_QSTR___dir__ && dest[1] != MP_OBJ_NULL) { + return mp_call_method_n_kw(0, 0, dest); + } + #endif mp_obj_list_append(dir, MP_OBJ_NEW_QSTR(i)); } } @@ -526,14 +533,8 @@ MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_delattr_obj, mp_builtin_delattr); STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) { qstr attr = mp_obj_str_get_qstr(attr_in); - mp_obj_t dest[2]; - // TODO: https://docs.python.org/3/library/functions.html?highlight=hasattr#hasattr - // explicitly says "This is implemented by calling getattr(object, name) and seeing - // whether it raises an AttributeError or not.", so we should explicitly wrap this - // in nlr_push and handle exception. - mp_load_method_maybe(object_in, attr, dest); - + mp_load_method_protected(object_in, attr, dest, false); return mp_obj_new_bool(dest[0] != MP_OBJ_NULL); } MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr); diff --git a/MicroPython_BUILD/components/micropython/py/mperrno.h b/MicroPython_BUILD/components/micropython/py/mperrno.h index f439f655..0cad75a1 100644 --- a/MicroPython_BUILD/components/micropython/py/mperrno.h +++ b/MicroPython_BUILD/components/micropython/py/mperrno.h @@ -122,7 +122,7 @@ #define MP_EPIPE EPIPE #define MP_EDOM EDOM #define MP_ERANGE ERANGE -#define MP_EWOULDBLOCK EAGAIN +#define MP_EWOULDBLOCK EWOULDBLOCK #define MP_EOPNOTSUPP EOPNOTSUPP #define MP_EAFNOSUPPORT EAFNOSUPPORT #define MP_EADDRINUSE EADDRINUSE diff --git a/MicroPython_BUILD/components/micropython/py/mpprint.c b/MicroPython_BUILD/components/micropython/py/mpprint.c index 0f28d62b..c2e65301 100644 --- a/MicroPython_BUILD/components/micropython/py/mpprint.c +++ b/MicroPython_BUILD/components/micropython/py/mpprint.c @@ -4,7 +4,6 @@ * The MIT License (MIT) * * Copyright (c) 2013-2015 Damien P. George - * Copyright (c) 2018 LoBo (https://github.com/loboris) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -52,7 +51,6 @@ STATIC void plat_print_strn(void *env, const char *str, size_t len) { const mp_print_t mp_plat_print = {NULL, plat_print_strn}; int mp_print_str(const mp_print_t *print, const char *str) { - if (str == NULL) return 0; size_t len = strlen(str); if (len) { print->print_strn(print->data, str, len); @@ -101,7 +99,7 @@ int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flag left_pad -= p; } } - if ((len) && (str)) { + if (len) { print->print_strn(print->data, str, len); total_chars_printed += len; } @@ -121,7 +119,7 @@ int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flag // 32-bits is 10 digits, add 3 for commas, 1 for sign, 1 for terminating null // We can use 16 characters for 32-bit and 32 characters for 64-bit -#define INT_BUF_SIZE (sizeof(mp_int_t) * 8) +#define INT_BUF_SIZE (sizeof(mp_int_t) * 4) // Our mp_vprintf function below does not support the '#' format modifier to // print the prefix of a non-base-10 number, so we don't need code for this. @@ -206,7 +204,7 @@ STATIC int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, int base, int mp_print_mp_int(const mp_print_t *print, mp_obj_t x, int base, int base_char, int flags, char fill, int width, int prec) { // These are the only values for "base" that are required to be supported by this // function, since Python only allows the user to format integers in these bases. - // If needed this function could be generalized to handle other values. + // If needed this function could be generalised to handle other values. assert(base == 2 || base == 8 || base == 10 || base == 16); if (!MP_OBJ_IS_INT(x)) { @@ -257,7 +255,7 @@ int mp_print_mp_int(const mp_print_t *print, mp_obj_t x, int base, int base_char // The size of this buffer is rather arbitrary. If it's not large // enough, a dynamic one will be allocated. - char stack_buf[sizeof(mp_int_t) * 8]; + char stack_buf[sizeof(mp_int_t) * 4]; char *buf = stack_buf; size_t buf_size = sizeof(stack_buf); size_t fmt_size = 0; @@ -500,8 +498,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) { } #endif if (prec < 0) { - if (str) prec = strlen(str); - else prec = 0; + prec = strlen(str); } chrs += mp_print_strn(print, str, prec, flags, fill, width); break; diff --git a/MicroPython_BUILD/components/micropython/py/mpstate.h b/MicroPython_BUILD/components/micropython/py/mpstate.h index 263ce417..5799d589 100644 --- a/MicroPython_BUILD/components/micropython/py/mpstate.h +++ b/MicroPython_BUILD/components/micropython/py/mpstate.h @@ -59,7 +59,7 @@ extern mp_dynamic_compiler_t mp_dynamic_compiler; typedef struct _mp_sched_item_t { mp_obj_t func; mp_obj_t arg; - void *carg; + void *carg; } mp_sched_item_t; // This structure hold information about the memory allocation system. @@ -80,7 +80,6 @@ typedef struct _mp_state_mem_t { int gc_stack_overflow; size_t gc_stack[MICROPY_ALLOC_GC_STACK_SIZE]; - size_t *gc_sp; uint16_t gc_lock_depth; // This variable controls auto garbage collection. If set to 0 then the @@ -96,10 +95,8 @@ typedef struct _mp_state_mem_t { size_t gc_last_free_atb_index; - #if MICROPY_PY_GC_COLLECT_RETVAL size_t gc_collected; size_t gc_marked; - #endif #if MICROPY_PY_THREAD // This is a global mutex used to make the GC thread-safe. @@ -110,10 +107,11 @@ typedef struct _mp_state_mem_t { // This structure hold runtime and VM information. It includes a section // which contains root pointers that must be scanned by the GC. typedef struct _mp_state_vm_t { - //////////////////////////////////////////////////////////// - // START ROOT POINTER SECTION - // everything that needs GC scanning must go here - // this must start at the start of this structure + // + // CONTINUE ROOT POINTER SECTION + // This must start at the start of this structure and follows + // the state in the mp_state_thread_t structure, continuing + // the root pointer section from there. // qstr_pool_t *last_pool; @@ -144,8 +142,6 @@ typedef struct _mp_state_vm_t { volatile mp_obj_t mp_pending_exception; #if MICROPY_ENABLE_SCHEDULER - volatile int16_t sched_state; - uint16_t sched_sp; mp_sched_item_t sched_stack[MICROPY_SCHEDULER_DEPTH]; #endif @@ -213,6 +209,11 @@ typedef struct _mp_state_vm_t { mp_int_t mp_emergency_exception_buf_size; #endif + #if MICROPY_ENABLE_SCHEDULER + volatile int16_t sched_state; + uint16_t sched_sp; + #endif + #if MICROPY_PY_THREAD_GIL // This is a global mutex used to make the VM/runtime thread-safe. mp_thread_mutex_t gil_mutex; @@ -223,11 +224,6 @@ typedef struct _mp_state_vm_t { // This structure holds state that is specific to a given thread. // Everything in this structure is scanned for root pointers. typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - nlr_buf_t *nlr_top; // ROOT POINTER - // Stack top at the start of program char *stack_top; @@ -240,12 +236,21 @@ typedef struct _mp_state_thread_t { uint8_t *pystack_end; uint8_t *pystack_cur; #endif + + //////////////////////////////////////////////////////////// + // START ROOT POINTER SECTION + // Everything that needs GC scanning must start here, and + // is followed by state in the mp_state_vm_t structure. + // + + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + nlr_buf_t *nlr_top; } mp_state_thread_t; // This structure combines the above 3 structures. // The order of the entries are important for root pointer scanning in the GC to work. -// Note: if this structure changes then revisit all nlr asm code since they -// have the offset of nlr_top hard-coded. typedef struct _mp_state_ctx_t { mp_state_thread_t thread; mp_state_vm_t vm; diff --git a/MicroPython_BUILD/components/micropython/py/obj.c b/MicroPython_BUILD/components/micropython/py/obj.c index 190208d1..8208fb2a 100644 --- a/MicroPython_BUILD/components/micropython/py/obj.c +++ b/MicroPython_BUILD/components/micropython/py/obj.c @@ -67,10 +67,6 @@ void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t } #endif mp_obj_type_t *type = mp_obj_get_type(o_in); - if (type == NULL) { - mp_print_str(print, "(nil)"); - return; - } if (type->print != NULL) { type->print((mp_print_t*)print, o_in, kind); } else { diff --git a/MicroPython_BUILD/components/micropython/py/obj.h b/MicroPython_BUILD/components/micropython/py/obj.h index 3c38b41f..ee784b64 100644 --- a/MicroPython_BUILD/components/micropython/py/obj.h +++ b/MicroPython_BUILD/components/micropython/py/obj.h @@ -180,7 +180,7 @@ static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o) #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 1) | 0x0002000000000001)) #if MICROPY_PY_BUILTINS_FLOAT -#define mp_const_float_e {((mp_obj_t)((uint64_t)0x4005bf0a8b125769 + 0x8004000000000000))} +#define mp_const_float_e {((mp_obj_t)((uint64_t)0x4005bf0a8b145769 + 0x8004000000000000))} #define mp_const_float_pi {((mp_obj_t)((uint64_t)0x400921fb54442d18 + 0x8004000000000000))} static inline bool mp_obj_is_float(mp_const_obj_t o) { diff --git a/MicroPython_BUILD/components/micropython/py/objdeque.c b/MicroPython_BUILD/components/micropython/py/objdeque.c index bbb07810..1cff1f8d 100644 --- a/MicroPython_BUILD/components/micropython/py/objdeque.c +++ b/MicroPython_BUILD/components/micropython/py/objdeque.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include // for ssize_t #include #include "py/mpconfig.h" @@ -75,7 +76,7 @@ STATIC mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) { case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->i_get != self->i_put); case MP_UNARY_OP_LEN: { - mp_int_t len = self->i_put - self->i_get; + ssize_t len = self->i_put - self->i_get; if (len < 0) { len += self->alloc; } diff --git a/MicroPython_BUILD/components/micropython/py/repl.c b/MicroPython_BUILD/components/micropython/py/repl.c index 61ae2c1f..5dce8bbb 100644 --- a/MicroPython_BUILD/components/micropython/py/repl.c +++ b/MicroPython_BUILD/components/micropython/py/repl.c @@ -158,7 +158,7 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print // lookup will fail return 0; } - mp_load_method_maybe(obj, q, dest); + mp_load_method_protected(obj, q, dest, true); obj = dest[0]; // attribute, method, or MP_OBJ_NULL if nothing found if (obj == MP_OBJ_NULL) { @@ -175,12 +175,12 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print // look for matches const char *match_str = NULL; size_t match_len = 0; - qstr q_first = 0, q_last; - for (qstr q = 1; q < nqstr; ++q) { + qstr q_first = 0, q_last = 0; + for (qstr q = MP_QSTR_ + 1; q < nqstr; ++q) { size_t d_len; const char *d_str = (const char*)qstr_data(q, &d_len); if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { - mp_load_method_maybe(obj, q, dest); + mp_load_method_protected(obj, q, dest, true); if (dest[0] != MP_OBJ_NULL) { if (match_str == NULL) { match_str = d_str; @@ -234,7 +234,7 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print size_t d_len; const char *d_str = (const char*)qstr_data(q, &d_len); if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { - mp_load_method_maybe(obj, q, dest); + mp_load_method_protected(obj, q, dest, true); if (dest[0] != MP_OBJ_NULL) { int gap = (line_len + WORD_SLOT_LEN - 1) / WORD_SLOT_LEN * WORD_SLOT_LEN - line_len; if (gap < 2) { diff --git a/MicroPython_BUILD/components/micropython/py/runtime.c b/MicroPython_BUILD/components/micropython/py/runtime.c index d00f001a..7db041b0 100644 --- a/MicroPython_BUILD/components/micropython/py/runtime.c +++ b/MicroPython_BUILD/components/micropython/py/runtime.c @@ -1086,6 +1086,22 @@ void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) { } } +// Acts like mp_load_method_maybe but catches AttributeError, and all other exceptions if requested +void mp_load_method_protected(mp_obj_t obj, qstr attr, mp_obj_t *dest, bool catch_all_exc) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_load_method_maybe(obj, attr, dest); + nlr_pop(); + } else { + if (!catch_all_exc + && !mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type), + MP_OBJ_FROM_PTR(&mp_type_AttributeError))) { + // Re-raise the exception + nlr_raise(MP_OBJ_FROM_PTR(nlr.ret_val)); + } + } +} + void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) { DEBUG_OP_printf("store attr %p.%s <- %p\n", base, qstr_str(attr), value); mp_obj_type_t *type = mp_obj_get_type(base); diff --git a/MicroPython_BUILD/components/micropython/py/runtime.h b/MicroPython_BUILD/components/micropython/py/runtime.h index 3fe5be97..6ca89a6d 100644 --- a/MicroPython_BUILD/components/micropython/py/runtime.h +++ b/MicroPython_BUILD/components/micropython/py/runtime.h @@ -175,6 +175,7 @@ mp_obj_t mp_load_attr(mp_obj_t base, qstr attr); void mp_convert_member_lookup(mp_obj_t obj, const mp_obj_type_t *type, mp_obj_t member, mp_obj_t *dest); void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest); void mp_load_method_maybe(mp_obj_t base, qstr attr, mp_obj_t *dest); +void mp_load_method_protected(mp_obj_t obj, qstr attr, mp_obj_t *dest, bool catch_all_exc); void mp_load_super_method(qstr attr, mp_obj_t *dest); void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t val); diff --git a/MicroPython_BUILD/components/micropython/py/stream.c b/MicroPython_BUILD/components/micropython/py/stream.c index f51f634b..393988d2 100644 --- a/MicroPython_BUILD/components/micropython/py/stream.c +++ b/MicroPython_BUILD/components/micropython/py/stream.c @@ -32,13 +32,6 @@ #include "py/stream.h" #include "py/runtime.h" -#if MICROPY_STREAMS_NON_BLOCK -#include -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) -#define EWOULDBLOCK 140 -#endif -#endif - // This file defines generic Python stream read/write methods which // dispatch to the underlying stream interface of an object. diff --git a/MicroPython_BUILD/components/micropython/py/stream.h b/MicroPython_BUILD/components/micropython/py/stream.h index a7d8d08f..a1d1c4f8 100644 --- a/MicroPython_BUILD/components/micropython/py/stream.h +++ b/MicroPython_BUILD/components/micropython/py/stream.h @@ -107,7 +107,7 @@ int mp_stream_posix_fsync(mp_obj_t stream); #endif #if MICROPY_STREAMS_NON_BLOCK -#define mp_is_nonblocking_error(errno) ((errno) == EAGAIN || (errno) == EWOULDBLOCK) +#define mp_is_nonblocking_error(errno) ((errno) == MP_EAGAIN || (errno) == MP_EWOULDBLOCK) #else #define mp_is_nonblocking_error(errno) (0) #endif diff --git a/MicroPython_BUILD/components/micropython/py/vm.c b/MicroPython_BUILD/components/micropython/py/vm.c index 262030e6..c72d3b0e 100644 --- a/MicroPython_BUILD/components/micropython/py/vm.c +++ b/MicroPython_BUILD/components/micropython/py/vm.c @@ -1328,25 +1328,28 @@ unwind_jump:; #if MICROPY_PY_THREAD_GIL #if MICROPY_PY_THREAD_GIL_VM_DIVISOR - if (--gil_divisor == 0) { - gil_divisor = MICROPY_PY_THREAD_GIL_VM_DIVISOR; - #else - { + if (--gil_divisor == 0) #endif - #if MICROPY_ENABLE_SCHEDULER - // can only switch threads if the scheduler is unlocked - if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) + { + #if MICROPY_PY_THREAD_GIL_VM_DIVISOR + gil_divisor = MICROPY_PY_THREAD_GIL_VM_DIVISOR; #endif - { - // LoBo - volatile uint32_t sp = (uint32_t)get_sp(); - mp_thread_set_sp((void *)sp, MP_STATE_THREAD(stack_top)); - void **ptrs = (void**)(void*)&mp_state_ctx; - mp_thread_set_ptrs(ptrs, offsetof(mp_state_ctx_t, vm.qstr_last_chunk) / sizeof(void*)); - mp_hal_reset_wdt(); - // Switch threads - MP_THREAD_GIL_EXIT(); - MP_THREAD_GIL_ENTER(); + if (!MP_STATE_VM(thread_lock)) { // LoBo + #if MICROPY_ENABLE_SCHEDULER + // can only switch threads if the scheduler is unlocked + if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) + #endif + { + // LoBo + volatile uint32_t sp = (uint32_t)get_sp(); + mp_thread_set_sp((void *)sp, MP_STATE_THREAD(stack_top)); + void **ptrs = (void**)(void*)&mp_state_ctx; + mp_thread_set_ptrs(ptrs, offsetof(mp_state_ctx_t, vm.qstr_last_chunk) / sizeof(void*)); + mp_hal_reset_wdt(); + // Switch threads + MP_THREAD_GIL_EXIT(); + MP_THREAD_GIL_ENTER(); + } } } #endif diff --git a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32.zip b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32.zip index 17189fcd..5fb6aa19 100644 Binary files a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32.zip and b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32.zip differ diff --git a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_all.zip b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_all.zip index 4e9393b5..4fd65425 100644 Binary files a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_all.zip and b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_all.zip differ diff --git a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_ota.zip b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_ota.zip index f7f65cff..707f70e4 100644 Binary files a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_ota.zip and b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_ota.zip differ diff --git a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram.zip b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram.zip index f8af340f..04780d53 100644 Binary files a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram.zip and b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram.zip differ diff --git a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram_all.zip b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram_all.zip index 49cc7797..2c8b201e 100644 Binary files a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram_all.zip and b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram_all.zip differ diff --git a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram_ota.zip b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram_ota.zip index ebc99d0c..0a0526d2 100644 Binary files a/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram_ota.zip and b/MicroPython_BUILD/firmware/MicroPython_LoBo_esp32_psram_ota.zip differ diff --git a/MicroPython_BUILD/firmware/esp32/MicroPython.bin b/MicroPython_BUILD/firmware/esp32/MicroPython.bin index d19ca952..f876d583 100644 Binary files a/MicroPython_BUILD/firmware/esp32/MicroPython.bin and b/MicroPython_BUILD/firmware/esp32/MicroPython.bin differ diff --git a/MicroPython_BUILD/firmware/esp32/bootloader/bootloader.bin b/MicroPython_BUILD/firmware/esp32/bootloader/bootloader.bin index db7e3e2f..c3d3bd47 100644 Binary files a/MicroPython_BUILD/firmware/esp32/bootloader/bootloader.bin and b/MicroPython_BUILD/firmware/esp32/bootloader/bootloader.bin differ diff --git a/MicroPython_BUILD/firmware/esp32/sdkconfig b/MicroPython_BUILD/firmware/esp32/sdkconfig index 849d1dc4..e46899b3 100644 --- a/MicroPython_BUILD/firmware/esp32/sdkconfig +++ b/MicroPython_BUILD/firmware/esp32/sdkconfig @@ -94,6 +94,7 @@ CONFIG_MICRO_PY_LOG_LEVEL3= CONFIG_MICRO_PY_LOG_LEVEL4= CONFIG_MICRO_PY_LOG_LEVEL5= CONFIG_MICROPY_USE_UNICODE=y +CONFIG_MICROPY_ENABLE_FINALISER=y CONFIG_MICROPY_GC_COLLECT_RETVAL= CONFIG_MICROPY_SCHEDULER_DEPTH=8 CONFIG_MICROPY_PY_THREAD_GIL_VM_DIVISOR=32 @@ -131,11 +132,11 @@ CONFIG_MICROPY_USE_WEBSOCKETS= CONFIG_MICROPY_USE_DISPLAY=y CONFIG_MICROPY_USE_EVE= CONFIG_MICROPY_USE_GSM= +CONFIG_MICROPY_USE_GPS=y +CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_ETHERNET= CONFIG_MICROPY_USE_MDNS=y CONFIG_MICROPY_USE_CURL= -CONFIG_MICROPY_USE_GPS=y -CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_SSH= CONFIG_MICROPY_USE_MQTT=y @@ -518,7 +519,7 @@ CONFIG_LWIP_MAX_RAW_PCBS=16 # # mbedTLS # -CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192 CONFIG_MBEDTLS_DEBUG= CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_HARDWARE_MPI= diff --git a/MicroPython_BUILD/firmware/esp32_all/MicroPython.bin b/MicroPython_BUILD/firmware/esp32_all/MicroPython.bin index 3a05bf4f..a6a94560 100644 Binary files a/MicroPython_BUILD/firmware/esp32_all/MicroPython.bin and b/MicroPython_BUILD/firmware/esp32_all/MicroPython.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_all/bootloader/bootloader.bin b/MicroPython_BUILD/firmware/esp32_all/bootloader/bootloader.bin index 79b51c4b..c76a2880 100644 Binary files a/MicroPython_BUILD/firmware/esp32_all/bootloader/bootloader.bin and b/MicroPython_BUILD/firmware/esp32_all/bootloader/bootloader.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_all/sdkconfig b/MicroPython_BUILD/firmware/esp32_all/sdkconfig index ad1052b1..1a0e7118 100644 --- a/MicroPython_BUILD/firmware/esp32_all/sdkconfig +++ b/MicroPython_BUILD/firmware/esp32_all/sdkconfig @@ -94,6 +94,7 @@ CONFIG_MICRO_PY_LOG_LEVEL3= CONFIG_MICRO_PY_LOG_LEVEL4= CONFIG_MICRO_PY_LOG_LEVEL5= CONFIG_MICROPY_USE_UNICODE=y +CONFIG_MICROPY_ENABLE_FINALISER=y CONFIG_MICROPY_GC_COLLECT_RETVAL= CONFIG_MICROPY_SCHEDULER_DEPTH=8 CONFIG_MICROPY_PY_THREAD_GIL_VM_DIVISOR=32 @@ -131,11 +132,11 @@ CONFIG_MICROPY_USE_WEBSOCKETS=y CONFIG_MICROPY_USE_DISPLAY=y CONFIG_MICROPY_USE_EVE= CONFIG_MICROPY_USE_GSM=y +CONFIG_MICROPY_USE_GPS=y +CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_ETHERNET= CONFIG_MICROPY_USE_MDNS=y CONFIG_MICROPY_USE_CURL=y -CONFIG_MICROPY_USE_GPS=y -CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_CURL_TLS=y CONFIG_MICROPY_USE_CURLFTP=y CONFIG_MICROPY_USE_SSH=y @@ -520,7 +521,7 @@ CONFIG_LWIP_MAX_RAW_PCBS=16 # # mbedTLS # -CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=4096 +CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192 CONFIG_MBEDTLS_DEBUG= CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_HARDWARE_MPI= diff --git a/MicroPython_BUILD/firmware/esp32_ota/MicroPython.bin b/MicroPython_BUILD/firmware/esp32_ota/MicroPython.bin index f7c64057..1b709a0f 100644 Binary files a/MicroPython_BUILD/firmware/esp32_ota/MicroPython.bin and b/MicroPython_BUILD/firmware/esp32_ota/MicroPython.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_ota/bootloader/bootloader.bin b/MicroPython_BUILD/firmware/esp32_ota/bootloader/bootloader.bin index b7efdb40..3bbbc514 100644 Binary files a/MicroPython_BUILD/firmware/esp32_ota/bootloader/bootloader.bin and b/MicroPython_BUILD/firmware/esp32_ota/bootloader/bootloader.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_ota/sdkconfig b/MicroPython_BUILD/firmware/esp32_ota/sdkconfig index 059e60b2..dadd78c2 100644 --- a/MicroPython_BUILD/firmware/esp32_ota/sdkconfig +++ b/MicroPython_BUILD/firmware/esp32_ota/sdkconfig @@ -95,6 +95,7 @@ CONFIG_MICRO_PY_LOG_LEVEL3= CONFIG_MICRO_PY_LOG_LEVEL4= CONFIG_MICRO_PY_LOG_LEVEL5= CONFIG_MICROPY_USE_UNICODE=y +CONFIG_MICROPY_ENABLE_FINALISER=y CONFIG_MICROPY_GC_COLLECT_RETVAL= CONFIG_MICROPY_SCHEDULER_DEPTH=8 CONFIG_MICROPY_PY_THREAD_GIL_VM_DIVISOR=32 @@ -132,11 +133,11 @@ CONFIG_MICROPY_USE_WEBSOCKETS= CONFIG_MICROPY_USE_DISPLAY=y CONFIG_MICROPY_USE_EVE= CONFIG_MICROPY_USE_GSM= +CONFIG_MICROPY_USE_GPS=y +CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_ETHERNET= CONFIG_MICROPY_USE_MDNS=y CONFIG_MICROPY_USE_CURL= -CONFIG_MICROPY_USE_GPS=y -CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_SSH= CONFIG_MICROPY_USE_MQTT=y @@ -519,7 +520,7 @@ CONFIG_LWIP_MAX_RAW_PCBS=16 # # mbedTLS # -CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192 CONFIG_MBEDTLS_DEBUG= CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_HARDWARE_MPI= diff --git a/MicroPython_BUILD/firmware/esp32_psram/MicroPython.bin b/MicroPython_BUILD/firmware/esp32_psram/MicroPython.bin index c19da3e9..15b51f3f 100644 Binary files a/MicroPython_BUILD/firmware/esp32_psram/MicroPython.bin and b/MicroPython_BUILD/firmware/esp32_psram/MicroPython.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_psram/bootloader/bootloader.bin b/MicroPython_BUILD/firmware/esp32_psram/bootloader/bootloader.bin index 4b8137de..9c28e657 100644 Binary files a/MicroPython_BUILD/firmware/esp32_psram/bootloader/bootloader.bin and b/MicroPython_BUILD/firmware/esp32_psram/bootloader/bootloader.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_psram/sdkconfig b/MicroPython_BUILD/firmware/esp32_psram/sdkconfig index 2fb4de2c..f4698c9a 100644 --- a/MicroPython_BUILD/firmware/esp32_psram/sdkconfig +++ b/MicroPython_BUILD/firmware/esp32_psram/sdkconfig @@ -94,6 +94,7 @@ CONFIG_MICRO_PY_LOG_LEVEL3= CONFIG_MICRO_PY_LOG_LEVEL4= CONFIG_MICRO_PY_LOG_LEVEL5= CONFIG_MICROPY_USE_UNICODE=y +CONFIG_MICROPY_ENABLE_FINALISER=y CONFIG_MICROPY_GC_COLLECT_RETVAL= CONFIG_MICROPY_SCHEDULER_DEPTH=8 CONFIG_MICROPY_PY_THREAD_GIL_VM_DIVISOR=32 @@ -131,11 +132,11 @@ CONFIG_MICROPY_USE_WEBSOCKETS= CONFIG_MICROPY_USE_DISPLAY=y CONFIG_MICROPY_USE_EVE= CONFIG_MICROPY_USE_GSM= +CONFIG_MICROPY_USE_GPS=y +CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_ETHERNET= CONFIG_MICROPY_USE_MDNS=y CONFIG_MICROPY_USE_CURL= -CONFIG_MICROPY_USE_GPS=y -CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_SSH= CONFIG_MICROPY_USE_MQTT=y diff --git a/MicroPython_BUILD/firmware/esp32_psram_all/MicroPython.bin b/MicroPython_BUILD/firmware/esp32_psram_all/MicroPython.bin index e15f16cb..2a3cf35f 100644 Binary files a/MicroPython_BUILD/firmware/esp32_psram_all/MicroPython.bin and b/MicroPython_BUILD/firmware/esp32_psram_all/MicroPython.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_psram_all/bootloader/bootloader.bin b/MicroPython_BUILD/firmware/esp32_psram_all/bootloader/bootloader.bin index bd5eb802..eadda6ac 100644 Binary files a/MicroPython_BUILD/firmware/esp32_psram_all/bootloader/bootloader.bin and b/MicroPython_BUILD/firmware/esp32_psram_all/bootloader/bootloader.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_psram_all/sdkconfig b/MicroPython_BUILD/firmware/esp32_psram_all/sdkconfig index dfc67c67..df48c112 100644 --- a/MicroPython_BUILD/firmware/esp32_psram_all/sdkconfig +++ b/MicroPython_BUILD/firmware/esp32_psram_all/sdkconfig @@ -94,6 +94,7 @@ CONFIG_MICRO_PY_LOG_LEVEL3= CONFIG_MICRO_PY_LOG_LEVEL4= CONFIG_MICRO_PY_LOG_LEVEL5= CONFIG_MICROPY_USE_UNICODE=y +CONFIG_MICROPY_ENABLE_FINALISER=y CONFIG_MICROPY_GC_COLLECT_RETVAL= CONFIG_MICROPY_SCHEDULER_DEPTH=8 CONFIG_MICROPY_PY_THREAD_GIL_VM_DIVISOR=32 @@ -131,11 +132,11 @@ CONFIG_MICROPY_USE_WEBSOCKETS=y CONFIG_MICROPY_USE_DISPLAY=y CONFIG_MICROPY_USE_EVE= CONFIG_MICROPY_USE_GSM=y +CONFIG_MICROPY_USE_GPS=y +CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_ETHERNET= CONFIG_MICROPY_USE_MDNS=y CONFIG_MICROPY_USE_CURL=y -CONFIG_MICROPY_USE_GPS=y -CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_CURL_TLS=y CONFIG_MICROPY_USE_CURLFTP=y CONFIG_MICROPY_USE_SSH=y @@ -535,7 +536,7 @@ CONFIG_LWIP_MAX_RAW_PCBS=16 # # mbedTLS # -CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=4096 +CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384 CONFIG_MBEDTLS_DEBUG= CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_HARDWARE_MPI= diff --git a/MicroPython_BUILD/firmware/esp32_psram_ota/MicroPython.bin b/MicroPython_BUILD/firmware/esp32_psram_ota/MicroPython.bin index 3ccdb2df..56205d8d 100644 Binary files a/MicroPython_BUILD/firmware/esp32_psram_ota/MicroPython.bin and b/MicroPython_BUILD/firmware/esp32_psram_ota/MicroPython.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_psram_ota/bootloader/bootloader.bin b/MicroPython_BUILD/firmware/esp32_psram_ota/bootloader/bootloader.bin index 2f56acc4..e10afb4b 100644 Binary files a/MicroPython_BUILD/firmware/esp32_psram_ota/bootloader/bootloader.bin and b/MicroPython_BUILD/firmware/esp32_psram_ota/bootloader/bootloader.bin differ diff --git a/MicroPython_BUILD/firmware/esp32_psram_ota/sdkconfig b/MicroPython_BUILD/firmware/esp32_psram_ota/sdkconfig index 21a2db75..d3fe1b39 100644 --- a/MicroPython_BUILD/firmware/esp32_psram_ota/sdkconfig +++ b/MicroPython_BUILD/firmware/esp32_psram_ota/sdkconfig @@ -95,6 +95,7 @@ CONFIG_MICRO_PY_LOG_LEVEL3= CONFIG_MICRO_PY_LOG_LEVEL4= CONFIG_MICRO_PY_LOG_LEVEL5= CONFIG_MICROPY_USE_UNICODE=y +CONFIG_MICROPY_ENABLE_FINALISER=y CONFIG_MICROPY_GC_COLLECT_RETVAL= CONFIG_MICROPY_SCHEDULER_DEPTH=8 CONFIG_MICROPY_PY_THREAD_GIL_VM_DIVISOR=32 @@ -132,11 +133,11 @@ CONFIG_MICROPY_USE_WEBSOCKETS= CONFIG_MICROPY_USE_DISPLAY=y CONFIG_MICROPY_USE_EVE= CONFIG_MICROPY_USE_GSM= +CONFIG_MICROPY_USE_GPS=y +CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_ETHERNET= CONFIG_MICROPY_USE_MDNS=y CONFIG_MICROPY_USE_CURL= -CONFIG_MICROPY_USE_GPS=y -CONFIG_MICROPY_GPS_SERVICE_STACK=3072 CONFIG_MICROPY_USE_SSH= CONFIG_MICROPY_USE_MQTT=y diff --git a/MicroPython_BUILD/sdkconfig.defaults b/MicroPython_BUILD/sdkconfig.defaults index 8db97f27..c55ec86f 100644 --- a/MicroPython_BUILD/sdkconfig.defaults +++ b/MicroPython_BUILD/sdkconfig.defaults @@ -96,7 +96,7 @@ CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 # # mbedTLS # -CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=4096 +CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192 # # FatFS diff --git a/MicroPython_BUILD/ver20180516.id b/MicroPython_BUILD/ver20180516.id new file mode 100644 index 00000000..c6c3344d --- /dev/null +++ b/MicroPython_BUILD/ver20180516.id @@ -0,0 +1 @@ +Build ID, do not delete this file