Skip to content

Commit b89422c

Browse files
committed
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>
1 parent b87f796 commit b89422c

6 files changed

Lines changed: 3 additions & 18 deletions

File tree

extmod/extmod.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ if(MICROPY_SSL_MBEDTLS)
114114
)
115115

116116
target_sources(micropy_lib_mbedtls INTERFACE
117+
${MICROPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c
117118
${MICROPY_LIB_MBEDTLS_DIR}/library/aes.c
118119
${MICROPY_LIB_MBEDTLS_DIR}/library/aesni.c
119120
${MICROPY_LIB_MBEDTLS_DIR}/library/arc4.c
@@ -141,7 +142,6 @@ if(MICROPY_SSL_MBEDTLS)
141142
${MICROPY_LIB_MBEDTLS_DIR}/library/ecp_curves.c
142143
${MICROPY_LIB_MBEDTLS_DIR}/library/entropy.c
143144
${MICROPY_LIB_MBEDTLS_DIR}/library/entropy_poll.c
144-
${MICROPY_LIB_MBEDTLS_DIR}/library/error.c
145145
${MICROPY_LIB_MBEDTLS_DIR}/library/gcm.c
146146
${MICROPY_LIB_MBEDTLS_DIR}/library/havege.c
147147
${MICROPY_LIB_MBEDTLS_DIR}/library/hmac_drbg.c

extmod/extmod.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ SRC_MOD += $(addprefix $(AXTLS_DIR)/,\
119119
else ifeq ($(MICROPY_SSL_MBEDTLS),1)
120120
MBEDTLS_DIR = lib/mbedtls
121121
CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(TOP)/$(MBEDTLS_DIR)/include
122+
SRC_MOD += lib/mbedtls_errors/mp_mbedtls_errors.c
122123
SRC_MOD += $(addprefix $(MBEDTLS_DIR)/library/,\
123124
aes.c \
124125
aesni.c \
@@ -147,7 +148,6 @@ SRC_MOD += $(addprefix $(MBEDTLS_DIR)/library/,\
147148
ecp_curves.c \
148149
entropy.c \
149150
entropy_poll.c \
150-
error.c \
151151
gcm.c \
152152
havege.c \
153153
hmac_drbg.c \

ports/mimxrt/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,13 @@ SRC_TINYUSB_C += \
9696

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

110108
# NXP SDK sources

ports/rp2/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ set(MICROPY_SOURCE_LIB
7777
${MICROPY_DIR}/lib/littlefs/lfs1_util.c
7878
${MICROPY_DIR}/lib/littlefs/lfs2.c
7979
${MICROPY_DIR}/lib/littlefs/lfs2_util.c
80-
${MICROPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c
8180
${MICROPY_DIR}/lib/oofatfs/ff.c
8281
${MICROPY_DIR}/lib/oofatfs/ffunicode.c
8382
${MICROPY_DIR}/shared/netutils/dhcpserver.c
@@ -343,12 +342,6 @@ target_sources(${MICROPY_TARGET} PRIVATE
343342

344343
target_link_libraries(${MICROPY_TARGET} micropy_lib_mbedtls)
345344

346-
# Filter out library/error.c as we're using mp_mbedtls_errors.c instead.
347-
set_source_files_properties(${MICROPY_LIB_MBEDTLS_DIR}/library/error.c
348-
TARGET_DIRECTORY micropy_lib_mbedtls
349-
PROPERTIES HEADER_FILE_ONLY ON
350-
)
351-
352345
target_link_libraries(${MICROPY_TARGET} usermod)
353346

354347
target_include_directories(${MICROPY_TARGET} PRIVATE

ports/stm32/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,6 @@ endif
499499
ifeq ($(MICROPY_SSL_MBEDTLS),1)
500500
CFLAGS_MOD += -DMBEDTLS_CONFIG_FILE='"mbedtls/mbedtls_config.h"'
501501
SRC_MOD += mbedtls/mbedtls_port.c
502-
# replace mbedtls' error.c by ours
503-
SRC_MOD := $(filter-out %/mbedtls/library/error.c, $(SRC_MOD))
504-
LIB_SRC_C += lib/mbedtls_errors/mp_mbedtls_errors.c
505502
endif
506503

507504
ifeq ($(MICROPY_PY_BLUETOOTH),1)

ports/unix/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ endif
140140
ifeq ($(MICROPY_SSL_MBEDTLS),1)
141141
GIT_SUBMODULES += lib/mbedtls
142142
CFLAGS_MOD += -DMBEDTLS_CONFIG_FILE='"mbedtls/mbedtls_config.h"'
143-
# replace mbedtls' error.c by ours
144-
SRC_MOD := $(filter-out %/mbedtls/library/error.c, $(SRC_MOD))
145-
LIB_SRC_C += lib/mbedtls_errors/mp_mbedtls_errors.c
146143
endif
147144
endif
148145

0 commit comments

Comments
 (0)