diff --git a/esp32/Makefile b/esp32/Makefile index a92ab5d53a..2d3805268c 100644 --- a/esp32/Makefile +++ b/esp32/Makefile @@ -72,6 +72,10 @@ endif FROZEN_MPY_DIR = frozen +MICROPY_PY_BTREE = 1 + +GIT_SUBMODULES = lib/berkeley-db-1.xx + include ../py/mkenv.mk CROSS_COMPILE = xtensa-esp32-elf- diff --git a/esp32/application.mk b/esp32/application.mk index 70c0f7d96d..2d87bd1249 100644 --- a/esp32/application.mk +++ b/esp32/application.mk @@ -94,6 +94,43 @@ APP_MAIN_SRC_C = \ pycom_config.c \ mpthreadport.c \ +################################################################################ +# btree + +ifeq ($(MICROPY_PY_BTREE), 1) +BTREE_DIR = lib/berkeley-db-1.xx +BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ "-Dvirt_fd_t=void*" $(BTREE_DEFS_EXTRA) +APP_INC += -I../lib/berkeley-db-1.xx/PORT/include + +APP_BTREE_SRC_C = $(addprefix $(BTREE_DIR)/,\ + btree/bt_close.c \ + btree/bt_conv.c \ + btree/bt_debug.c \ + btree/bt_delete.c \ + btree/bt_get.c \ + btree/bt_open.c \ + btree/bt_overflow.c \ + btree/bt_page.c \ + btree/bt_put.c \ + btree/bt_search.c \ + btree/bt_seq.c \ + btree/bt_split.c \ + btree/bt_utils.c \ + mpool/mpool.c \ + ) + +APP_BTREE_MOD_SRC_C = $(addprefix extmod/,\ + modbtree.c \ + ) + +CFLAGS += -DMICROPY_PY_BTREE=1 +# we need to suppress certain warnings to get berkeley-db to compile cleanly +# and we have separate BTREE_DEFS so the definitions don't interfere with other source code +$(BTREE_DIR)/btree/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter $(BTREE_DEFS) +$(BTREE_DIR)/modbtree.o: CFLAGS += $(BTREE_DEFS) +endif + + APP_HAL_SRC_C = $(addprefix hal/,\ esp32_mphal.c \ ) @@ -342,6 +379,10 @@ OBJ += $(addprefix $(BUILD)/, $(APP_FATFS_SRC_C:.c=.o) $(APP_LITTLEFS_SRC_C:.c=. OBJ += $(addprefix $(BUILD)/, $(APP_FTP_SRC_C:.c=.o) $(APP_CAN_SRC_C:.c=.o)) OBJ += $(BUILD)/pins.o +ifeq ($(MICROPY_PY_BTREE), 1) +OBJ += $(addprefix $(BUILD)/, $(APP_BTREE_SRC_C:.c=.o) $(APP_BTREE_MOD_SRC_C:.c=.o)) +endif + BOOT_OBJ = $(addprefix $(BUILD)/, $(BOOT_SRC_C:.c=.o)) # List of sources for qstr extraction @@ -362,6 +403,11 @@ SRC_QSTR += $(APP_MOD_MESH_SRC_C) endif endif # ifeq ($(OPENTHREAD), on) +ifeq ($(MICROPY_PY_BTREE), 1) +# SRC_QSTR += lib/berkeley-db-1.xx/modbtree.c +SRC_QSTR += $(APP_BTREE_MOD_SRC_C) +endif + # Append any auto-generated sources that are needed by sources listed in # SRC_QSTR SRC_QSTR_AUTO_DEPS += diff --git a/esp32/mpconfigport.h b/esp32/mpconfigport.h index 51a30b2e05..2c3a0eedd9 100644 --- a/esp32/mpconfigport.h +++ b/esp32/mpconfigport.h @@ -119,6 +119,7 @@ #define MICROPY_PY_UZLIB (1) #define MICROPY_STREAMS_NON_BLOCK (1) +#define MICROPY_STREAMS_POSIX_API (1) #define MICROPY_PY_BUILTINS_TIMEOUTERROR (1) #define MICROPY_PY_ALL_SPECIAL_METHODS (1) diff --git a/esp32/tools/fw_updater/updater.py b/esp32/tools/fw_updater/updater.py index e9bda31ce7..d57518164f 100755 --- a/esp32/tools/fw_updater/updater.py +++ b/esp32/tools/fw_updater/updater.py @@ -751,9 +751,9 @@ def set_pycom_config(self, config_block, boot_fs_type=None): return self.set_pybytes_config(new_config_block, force_update=True) def print_cb(self, config_block): - if DEBUG: - for x in range(0, 30): - print(binascii.hexlify(config_block[x * 32:x * 32 + 32])) + if DEBUG: + for x in range(0, 30): + print(binascii.hexlify(config_block[x * 32:x * 32 + 32])) def set_pybytes_config(self, config_block, userid=None, device_token=None, mqttServiceAddress=None, network_preferences=None, extra_preferences=None, force_update=None, auto_start=None): config_block = config_block.ljust(int(PARTITIONS.get('config')[1], 16), b'\x00') diff --git a/py/py.mk b/py/py.mk index 3d8d849e2b..830a133159 100644 --- a/py/py.mk +++ b/py/py.mk @@ -104,8 +104,7 @@ endif ifeq ($(MICROPY_PY_BTREE),1) BTREE_DIR = lib/berkeley-db-1.xx BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ "-Dvirt_fd_t=void*" $(BTREE_DEFS_EXTRA) -INC += -I$(TOP)/$(BTREE_DIR)/PORT/include -SRC_MOD += extmod/modbtree.c +INC += -I$(BTREE_DIR)/PORT/include SRC_MOD += $(addprefix $(BTREE_DIR)/,\ btree/bt_close.c \ btree/bt_conv.c \ @@ -122,6 +121,10 @@ btree/bt_split.c \ btree/bt_utils.c \ mpool/mpool.c \ ) + +SRC_MOD += $(addprefix extmod/,\ +modbtree.c \ + ) CFLAGS_MOD += -DMICROPY_PY_BTREE=1 # we need to suppress certain warnings to get berkeley-db to compile cleanly # and we have separate BTREE_DEFS so the definitions don't interfere with other source code