Skip to content

Commit

Permalink
extmod: Always use custom mbedtls error message code.
Browse files Browse the repository at this point in the history
All ports that use mbedtls use the custom error messages in
mp_mbedtls_errors.c.  This commit simplifies the build so that ports don't
need to explicitly add this file, it's now used by default when mbedtls is
enabled.

Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Jul 18, 2022
1 parent b87f796 commit b89422c
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion extmod/extmod.cmake
Expand Up @@ -114,6 +114,7 @@ if(MICROPY_SSL_MBEDTLS)
)

target_sources(micropy_lib_mbedtls INTERFACE
${MICROPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c
${MICROPY_LIB_MBEDTLS_DIR}/library/aes.c
${MICROPY_LIB_MBEDTLS_DIR}/library/aesni.c
${MICROPY_LIB_MBEDTLS_DIR}/library/arc4.c
Expand Down Expand Up @@ -141,7 +142,6 @@ if(MICROPY_SSL_MBEDTLS)
${MICROPY_LIB_MBEDTLS_DIR}/library/ecp_curves.c
${MICROPY_LIB_MBEDTLS_DIR}/library/entropy.c
${MICROPY_LIB_MBEDTLS_DIR}/library/entropy_poll.c
${MICROPY_LIB_MBEDTLS_DIR}/library/error.c
${MICROPY_LIB_MBEDTLS_DIR}/library/gcm.c
${MICROPY_LIB_MBEDTLS_DIR}/library/havege.c
${MICROPY_LIB_MBEDTLS_DIR}/library/hmac_drbg.c
Expand Down
2 changes: 1 addition & 1 deletion extmod/extmod.mk
Expand Up @@ -119,6 +119,7 @@ SRC_MOD += $(addprefix $(AXTLS_DIR)/,\
else ifeq ($(MICROPY_SSL_MBEDTLS),1)
MBEDTLS_DIR = lib/mbedtls
CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(TOP)/$(MBEDTLS_DIR)/include
SRC_MOD += lib/mbedtls_errors/mp_mbedtls_errors.c
SRC_MOD += $(addprefix $(MBEDTLS_DIR)/library/,\
aes.c \
aesni.c \
Expand Down Expand Up @@ -147,7 +148,6 @@ SRC_MOD += $(addprefix $(MBEDTLS_DIR)/library/,\
ecp_curves.c \
entropy.c \
entropy_poll.c \
error.c \
gcm.c \
havege.c \
hmac_drbg.c \
Expand Down
4 changes: 1 addition & 3 deletions ports/mimxrt/Makefile
Expand Up @@ -96,15 +96,13 @@ SRC_TINYUSB_C += \

# All settings for Ethernet support are controller by the value of MICROPY_PY_LWIP
ifeq ($(MICROPY_PY_LWIP),1)
SRC_MOD := $(filter-out %/mbedtls/library/error.c, $(SRC_MOD))
SRC_ETH_C += \
$(MCU_DIR)/drivers/fsl_enet.c \
hal/phy/device/phydp83825/fsl_phydp83825.c \
hal/phy/device/phydp83848/fsl_phydp83848.c \
hal/phy/device/phyksz8081/fsl_phyksz8081.c \
hal/phy/device/phylan8720/fsl_phylan8720.c \
hal/phy/mdio/enet/fsl_enet_mdio.c \
lib/mbedtls_errors/mp_mbedtls_errors.c
hal/phy/mdio/enet/fsl_enet_mdio.c
endif

# NXP SDK sources
Expand Down
7 changes: 0 additions & 7 deletions ports/rp2/CMakeLists.txt
Expand Up @@ -77,7 +77,6 @@ set(MICROPY_SOURCE_LIB
${MICROPY_DIR}/lib/littlefs/lfs1_util.c
${MICROPY_DIR}/lib/littlefs/lfs2.c
${MICROPY_DIR}/lib/littlefs/lfs2_util.c
${MICROPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c
${MICROPY_DIR}/lib/oofatfs/ff.c
${MICROPY_DIR}/lib/oofatfs/ffunicode.c
${MICROPY_DIR}/shared/netutils/dhcpserver.c
Expand Down Expand Up @@ -343,12 +342,6 @@ target_sources(${MICROPY_TARGET} PRIVATE

target_link_libraries(${MICROPY_TARGET} micropy_lib_mbedtls)

# Filter out library/error.c as we're using mp_mbedtls_errors.c instead.
set_source_files_properties(${MICROPY_LIB_MBEDTLS_DIR}/library/error.c
TARGET_DIRECTORY micropy_lib_mbedtls
PROPERTIES HEADER_FILE_ONLY ON
)

target_link_libraries(${MICROPY_TARGET} usermod)

target_include_directories(${MICROPY_TARGET} PRIVATE
Expand Down
3 changes: 0 additions & 3 deletions ports/stm32/Makefile
Expand Up @@ -499,9 +499,6 @@ endif
ifeq ($(MICROPY_SSL_MBEDTLS),1)
CFLAGS_MOD += -DMBEDTLS_CONFIG_FILE='"mbedtls/mbedtls_config.h"'
SRC_MOD += mbedtls/mbedtls_port.c
# replace mbedtls' error.c by ours
SRC_MOD := $(filter-out %/mbedtls/library/error.c, $(SRC_MOD))
LIB_SRC_C += lib/mbedtls_errors/mp_mbedtls_errors.c
endif

ifeq ($(MICROPY_PY_BLUETOOTH),1)
Expand Down
3 changes: 0 additions & 3 deletions ports/unix/Makefile
Expand Up @@ -140,9 +140,6 @@ endif
ifeq ($(MICROPY_SSL_MBEDTLS),1)
GIT_SUBMODULES += lib/mbedtls
CFLAGS_MOD += -DMBEDTLS_CONFIG_FILE='"mbedtls/mbedtls_config.h"'
# replace mbedtls' error.c by ours
SRC_MOD := $(filter-out %/mbedtls/library/error.c, $(SRC_MOD))
LIB_SRC_C += lib/mbedtls_errors/mp_mbedtls_errors.c
endif
endif

Expand Down

0 comments on commit b89422c

Please sign in to comment.