extmod: Always use custom mbedtls error message code.

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>
This commit is contained in:
Damien George 2022-07-18 22:55:22 +10:00
parent b87f796ef5
commit b89422ceaa
6 changed files with 3 additions and 18 deletions

View File

@ -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
@ -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

View File

@ -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 \
@ -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 \

View File

@ -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

View File

@ -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
@ -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

View File

@ -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)

View File

@ -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