Skip to content

Commit 3701bc7

Browse files
tannewtclaude
andcommitted
Fix linker and API issues for ESP-IDF v6.0 migration
- Disable esp-camera (needs separate v6.0 update) - Add esp_hal_* components to link line (split from monolithic hal) - Add tf-psa-crypto and mbed-builtin libraries for mbedtls 4.x - Add ROM WDT linker scripts (moved from esp_rom to esp_hal_wdt) - Add -nostartfiles to avoid picolibc crt0.o conflicts - Migrate hashlib to PSA crypto API (mbedtls 4.x removed direct SHA API when hardware acceleration is enabled) - Guard entropy/ctr_drbg in SSL with MBEDTLS_VERSION_MAJOR < 4 (RNG is internal in mbedtls 4.x) - Add missing include paths for esp_hal_pmu, esp_hal_wdt, esp_hal_usb - Suppress legacy driver deprecation warnings globally Builds successfully for ESP32-S3 (Xtensa) and ESP32-C6 (RISC-V). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be0af5f commit 3701bc7

8 files changed

Lines changed: 84 additions & 68 deletions

File tree

ports/espressif/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ cmake_minimum_required(VERSION 3.16)
55
set(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf)
66

77
# The component list here determines what options we get in menuconfig and what the ninja file can build.
8-
set(COMPONENTS bt driver esp_driver_dac esp_driver_gpio esp_driver_gptimer esp_driver_i2c esp_driver_i2s esp_driver_ledc esp_driver_pcnt esp_driver_rmt esp_driver_sdmmc esp_driver_spi esp_driver_tsens esp_driver_uart esp-tls esp_adc esp_event esp_netif esp_psram esp_wifi esptool_py freertos log lwip main mbedtls mdns soc ulp wpa_supplicant esp-camera esp_lcd vfs esp_stdio sdmmc)
9-
set(EXTRA_COMPONENT_DIRS "esp-protocols/components/mdns" "esp-camera")
8+
set(COMPONENTS bt driver esp_driver_dac esp_driver_gpio esp_driver_gptimer esp_driver_i2c esp_driver_i2s esp_driver_ledc esp_driver_pcnt esp_driver_rmt esp_driver_sdmmc esp_driver_spi esp_driver_tsens esp_driver_uart esp-tls esp_adc esp_event esp_netif esp_psram esp_wifi esptool_py freertos log lwip main mbedtls mdns soc ulp wpa_supplicant esp_lcd vfs esp_stdio sdmmc)
9+
set(EXTRA_COMPONENT_DIRS "esp-protocols/components/mdns")
1010

1111
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
1212
project(circuitpython)

ports/espressif/Makefile

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ INC += \
7777
-isystem esp-idf/components/esp_event/include \
7878
-isystem esp-idf/components/esp_hw_support/include \
7979
-isystem esp-idf/components/esp_hw_support/include/soc \
80+
-isystem esp-idf/components/esp_hw_support/port/$(IDF_TARGET)/private_include \
8081
-isystem esp-idf/components/esp_hw_support/etm/include \
8182
-isystem esp-idf/components/esp_mm/include \
8283
-isystem esp-idf/components/esp_netif/include \
@@ -126,7 +127,12 @@ INC += \
126127
-isystem esp-idf/components/esp_hal_lcd/include \
127128
-isystem esp-idf/components/esp_hal_lcd/$(IDF_TARGET)/include \
128129
-isystem esp-idf/components/esp_hal_usb/include \
130+
-isystem esp-idf/components/esp_hal_usb/$(IDF_TARGET)/include \
129131
-isystem esp-idf/components/esp_hal_parlio/include \
132+
-isystem esp-idf/components/esp_hal_pmu/include \
133+
-isystem esp-idf/components/esp_hal_pmu/$(IDF_TARGET)/include \
134+
-isystem esp-idf/components/esp_hal_wdt/include \
135+
-isystem esp-idf/components/esp_hal_wdt/$(IDF_TARGET)/include \
130136
-isystem esp-idf/components/esp_hal_security/include \
131137
-isystem esp-idf/components/heap/include \
132138
-isystem esp-idf/components/log/include \
@@ -225,7 +231,7 @@ endif
225231
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
226232
CFLAGS += $(OPTIMIZATION_FLAGS)
227233

228-
CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes -Werror=old-style-definition
234+
CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes -Werror=old-style-definition -Wno-error=cpp -Wno-cpp
229235

230236
# ESP-IDF v6.0 uses picolibc instead of newlib.
231237
CFLAGS += --specs=picolibc.specs
@@ -237,7 +243,7 @@ ifeq ($(IDF_TARGET_ARCH),xtensa)
237243
# Remove the last two flags once TinyUSB is updated with the `#include <xtensa_api.h>` instead of
238244
# `#include "xtensa/xtensa_api.h"`.
239245

240-
CFLAGS += -mlongcalls -isystem esp-idf/components/xtensa/deprecated_include/ -Wno-error=cpp
246+
CFLAGS += -mlongcalls -isystem esp-idf/components/xtensa/deprecated_include/
241247
CFLAGS += -DMICROPY_GCREGS_SETJMP=1
242248

243249
# Wrap longjmp with a patched version that protects register window update with a critical section
@@ -261,12 +267,13 @@ else ifeq ($(IDF_TARGET_ARCH),riscv)
261267
endif
262268

263269

264-
LDFLAGS += $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
270+
LDFLAGS += $(CFLAGS) -nostartfiles -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
265271

266272
LDFLAGS += \
267273
-L$(BUILD)/esp-idf/esp-idf/esp_system/ld \
268274
-Lesp-idf/components/esp_rom/$(IDF_TARGET)/ld \
269275
-Lesp-idf/components/soc/$(IDF_TARGET)/ld \
276+
-Lesp-idf/components/esp_hal_wdt/$(IDF_TARGET) \
270277
-Tmemory.ld \
271278
-Tsections.ld \
272279
-T$(IDF_TARGET).peripherals.ld \
@@ -286,7 +293,8 @@ LDFLAGS += \
286293
-Tesp32.rom.newlib-reent-funcs.ld
287294

288295
CHIP_COMPONENTS = \
289-
esp_driver_dac
296+
esp_driver_dac \
297+
esp_hal_i2s esp_hal_lcd esp_hal_pcnt esp_hal_touch_sens esp_hal_twai
290298

291299
else ifeq ($(IDF_TARGET),esp32c2)
292300
LDFLAGS += \
@@ -296,14 +304,16 @@ LDFLAGS += \
296304
-Tesp32c2.rom.newlib.ld \
297305
-Tesp32c2.rom.newlib-nano.ld \
298306
-Tesp32c2.rom.version.ld \
299-
-Tesp32c2.rom.systimer.ld
307+
-Tesp32c2.rom.systimer.ld \
308+
-Trom.wdt.ld
300309

301310
CFLAGS += -DSOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ
302311

303312
CHIP_COMPONENTS = \
304313
esp_driver_tsens
305314

306315
else ifeq ($(IDF_TARGET),esp32c3)
316+
# esp32c2 has none of: esp_hal_i2s esp_hal_lcd esp_hal_pcnt esp_hal_touch_sens esp_hal_twai
307317
LDFLAGS += \
308318
-Tesp32c3.rom.newlib.ld \
309319
-Tesp32c3.rom.libc.ld \
@@ -313,7 +323,8 @@ LDFLAGS += \
313323
-Tesp32c3.rom.bt_funcs.ld
314324

315325
CHIP_COMPONENTS = \
316-
esp_driver_tsens
326+
esp_driver_tsens \
327+
esp_hal_i2s esp_hal_twai
317328

318329
else ifeq ($(IDF_TARGET),esp32c6)
319330
LDFLAGS += \
@@ -324,11 +335,13 @@ LDFLAGS += \
324335
-Tesp32c6.rom.newlib.ld \
325336
-Tesp32c6.rom.coexist.ld \
326337
-Tesp32c6.rom.heap.ld \
327-
-Tesp32c6.rom.systimer.ld
338+
-Tesp32c6.rom.systimer.ld \
339+
-Trom.wdt.ld
328340

329341

330342
CHIP_COMPONENTS = \
331-
esp_driver_tsens
343+
esp_driver_tsens \
344+
esp_hal_i2s esp_hal_pcnt esp_hal_twai
332345

333346
else ifeq ($(IDF_TARGET),esp32c61)
334347
LDFLAGS += \
@@ -340,32 +353,38 @@ LDFLAGS += \
340353
-Tesp32c61.rom.version.ld \
341354
-Tesp32c61.rom.coexist.ld \
342355
-Tesp32c61.rom.heap.ld \
343-
-Tesp32c61.rom.systimer.ld
356+
-Tesp32c61.rom.systimer.ld \
357+
-Trom.wdt.ld
344358

345359

346360
CHIP_COMPONENTS = \
347-
esp_driver_tsens
361+
esp_driver_tsens \
362+
esp_hal_i2s
348363

349364
else ifeq ($(IDF_TARGET),esp32p4)
350365
LDFLAGS += \
351366
-Tesp32p4.rom.libc.ld \
352367
-Tesp32p4.rom.newlib.ld \
353-
-Tesp32p4.rom.systimer.ld
368+
-Tesp32p4.rom.systimer.ld \
369+
-Trom.wdt.ld
354370

355371

356372
CHIP_COMPONENTS = \
357373
esp_driver_tsens \
358-
esp_driver_usb_serial_jtag
374+
esp_driver_usb_serial_jtag \
375+
esp_hal_i2s esp_hal_lcd esp_hal_pcnt esp_hal_touch_sens esp_hal_twai
359376

360377
else ifeq ($(IDF_TARGET),esp32h2)
361378
LDFLAGS += \
362379
-Tesp32h2.rom.heap.ld \
363380
-Tesp32h2.rom.libc.ld \
364381
-Tesp32h2.rom.newlib.ld \
365-
-Tesp32h2.rom.systimer.ld
382+
-Tesp32h2.rom.systimer.ld \
383+
-Trom.wdt.ld
366384

367385
CHIP_COMPONENTS = \
368-
esp_driver_tsens
386+
esp_driver_tsens \
387+
esp_hal_i2s esp_hal_pcnt esp_hal_twai
369388

370389
else ifeq ($(IDF_TARGET),esp32s2)
371390
LDFLAGS += \
@@ -375,18 +394,21 @@ LDFLAGS += \
375394

376395
CHIP_COMPONENTS = \
377396
esp_driver_dac \
378-
esp_driver_tsens
397+
esp_driver_tsens \
398+
esp_hal_i2s esp_hal_lcd esp_hal_pcnt esp_hal_touch_sens esp_hal_twai
379399

380400
else ifeq ($(IDF_TARGET),esp32s3)
381401
LDFLAGS += \
382402
-Tesp32s3.rom.libc.ld \
383403
-Tesp32s3.rom.newlib.ld \
384404
-Tesp32s3.rom.version.ld \
385405
-Tesp32s3.rom.systimer.ld \
386-
-Tesp32s3.rom.bt_funcs.ld
406+
-Tesp32s3.rom.bt_funcs.ld \
407+
-Trom.wdt.ld
387408

388409
CHIP_COMPONENTS = \
389-
esp_driver_tsens
410+
esp_driver_tsens \
411+
esp_hal_i2s esp_hal_lcd esp_hal_pcnt esp_hal_touch_sens esp_hal_twai
390412

391413
endif
392414

@@ -737,7 +759,7 @@ ifeq ($(IDF_TARGET),esp32)
737759
BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/librtc.a
738760
endif
739761

740-
ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) $(CHIP_COMPONENTS) app_update bootloader_support driver esp_driver_gpio esp_driver_gptimer esp_driver_i2c esp_driver_ledc esp_driver_spi esp_driver_uart efuse esp_adc esp_app_format esp_common esp_event esp_hw_support esp_mm esp_partition esp_pm esp_ringbuf esp_rom esp_system esp_timer freertos hal heap log esp_libc nvs_flash pthread soc spi_flash vfs esp_stdio
762+
ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) $(CHIP_COMPONENTS) app_update bootloader_support driver esp_driver_dma esp_driver_gpio esp_driver_gptimer esp_driver_i2c esp_driver_ledc esp_driver_spi esp_driver_uart esp_driver_usb_serial_jtag efuse esp_adc esp_app_format esp_common esp_event esp_gdbstub esp_hal_ana_conv esp_hal_clock esp_hal_dma esp_hal_gpio esp_hal_gpspi esp_hal_i2c esp_hal_ledc esp_hal_mspi esp_hal_pmu esp_hal_rmt esp_hal_security esp_hal_timg esp_hal_uart esp_hal_usb esp_hal_wdt esp_hw_support esp_mm esp_partition esp_pm esp_ringbuf esp_rom esp_system esp_timer freertos hal heap log esp_libc nvs_flash nvs_sec_provider pthread soc spi_flash vfs esp_stdio
741763
ifneq ($(CIRCUITPY_WIFI),0)
742764
ESP_IDF_COMPONENTS_LINK += esp_coex esp_netif esp_security esp-tls esp_wifi lwip mbedtls mdns wpa_supplicant esp_phy
743765
endif
@@ -795,13 +817,17 @@ ifneq ($(CIRCUITPY_QSPIBUS),0)
795817
ESP_IDF_COMPONENTS_LINK += esp_lcd
796818
endif
797819
ifneq ($(CIRCUITPY_SDIOIO),0)
798-
ESP_IDF_COMPONENTS_LINK += sdmmc esp_driver_sdmmc
820+
ESP_IDF_COMPONENTS_LINK += sdmmc esp_driver_sdmmc esp_driver_sd_intf
799821
endif
800822

801823
ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a)
802824

803825
MBEDTLS_COMPONENTS_LINK = crypto tls x509
804826
MBEDTLS_COMPONENTS_LINK_EXPANDED = $(foreach component, $(MBEDTLS_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/mbedtls/mbedtls/library/libmbed$(component).a)
827+
MBEDTLS_COMPONENTS_LINK_EXPANDED += $(BUILD)/esp-idf/esp-idf/mbedtls/mbedtls/library/libtfpsacrypto.a
828+
MBEDTLS_COMPONENTS_LINK_EXPANDED += $(BUILD)/esp-idf/esp-idf/mbedtls/mbedtls/tf-psa-crypto/drivers/builtin/libmbed-builtin.a
829+
MBEDTLS_COMPONENTS_LINK_EXPANDED += $(BUILD)/esp-idf/esp-idf/mbedtls/mbedtls/tf-psa-crypto/drivers/everest/libeverest.a
830+
MBEDTLS_COMPONENTS_LINK_EXPANDED += $(BUILD)/esp-idf/esp-idf/mbedtls/mbedtls/tf-psa-crypto/drivers/p256-m/libp256m.a
805831

806832
ifeq ($(IDF_TARGET_ARCH),xtensa)
807833
BINARY_BLOBS += esp-idf/components/xtensa/$(IDF_TARGET)/libxt_hal.a

ports/espressif/mpconfigport.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ CIRCUITPY_BLEIO_HCI = 0
7373
CIRCUITPY_BLEIO_NATIVE ?= 1
7474
CIRCUITPY_CANIO ?= 1
7575
CIRCUITPY_COUNTIO ?= 1
76-
CIRCUITPY_ESPCAMERA ?= 1
76+
CIRCUITPY_ESPCAMERA ?= 0
7777
CIRCUITPY_ESPIDF ?= 1
7878
CIRCUITPY_ESPULP ?= 1
7979
CIRCUITPY_FRAMEBUFFERIO ?= 1

shared-module/hashlib/Hash.c

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,23 @@
77
#include "shared-bindings/hashlib/Hash.h"
88
#include "shared-module/hashlib/__init__.h"
99

10-
#include "mbedtls/ssl.h"
10+
#include "psa/crypto.h"
1111

1212
void common_hal_hashlib_hash_update(hashlib_hash_obj_t *self, const uint8_t *data, size_t datalen) {
13-
if (self->hash_type == MBEDTLS_SSL_HASH_SHA1) {
14-
mbedtls_sha1_update_ret(&self->sha1, data, datalen);
15-
return;
16-
} else if (self->hash_type == MBEDTLS_SSL_HASH_SHA256) {
17-
mbedtls_sha256_update_ret(&self->sha256, data, datalen);
18-
return;
19-
}
13+
psa_hash_update(&self->hash_op, data, datalen);
2014
}
2115

2216
void common_hal_hashlib_hash_digest(hashlib_hash_obj_t *self, uint8_t *data, size_t datalen) {
2317
if (datalen < common_hal_hashlib_hash_get_digest_size(self)) {
2418
return;
2519
}
26-
if (self->hash_type == MBEDTLS_SSL_HASH_SHA1) {
27-
// We copy the sha1 state so we can continue to update if needed or get
28-
// the digest a second time.
29-
mbedtls_sha1_context copy;
30-
mbedtls_sha1_clone(&copy, &self->sha1);
31-
mbedtls_sha1_finish_ret(&self->sha1, data);
32-
mbedtls_sha1_clone(&self->sha1, &copy);
33-
} else if (self->hash_type == MBEDTLS_SSL_HASH_SHA256) {
34-
mbedtls_sha256_context copy;
35-
mbedtls_sha256_clone(&copy, &self->sha256);
36-
mbedtls_sha256_finish_ret(&self->sha256, data);
37-
mbedtls_sha256_clone(&self->sha256, &copy);
38-
}
20+
// Clone the operation so we can continue to update or get digest again.
21+
psa_hash_operation_t clone = PSA_HASH_OPERATION_INIT;
22+
psa_hash_clone(&self->hash_op, &clone);
23+
size_t hash_len;
24+
psa_hash_finish(&clone, data, datalen, &hash_len);
3925
}
4026

4127
size_t common_hal_hashlib_hash_get_digest_size(hashlib_hash_obj_t *self) {
42-
if (self->hash_type == MBEDTLS_SSL_HASH_SHA1) {
43-
return 20;
44-
} else if (self->hash_type == MBEDTLS_SSL_HASH_SHA256) {
45-
return 32;
46-
}
47-
return 0;
28+
return PSA_HASH_LENGTH(self->hash_alg);
4829
}

shared-module/hashlib/Hash.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@
66

77
#pragma once
88

9-
#include "mbedtls/private/sha1.h"
10-
#include "mbedtls/private/sha256.h"
9+
#include "psa/crypto.h"
1110

1211
typedef struct {
1312
mp_obj_base_t base;
14-
union {
15-
mbedtls_sha1_context sha1;
16-
mbedtls_sha256_context sha256;
17-
};
18-
// Of MBEDTLS_SSL_HASH_*
19-
uint8_t hash_type;
13+
psa_hash_operation_t hash_op;
14+
psa_algorithm_t hash_alg;
2015
} hashlib_hash_obj_t;

shared-module/hashlib/__init__.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@
77
#include "shared-bindings/hashlib/__init__.h"
88
#include "shared-module/hashlib/__init__.h"
99

10-
#include "mbedtls/ssl.h"
11-
10+
#include "psa/crypto.h"
1211

1312
bool common_hal_hashlib_new(hashlib_hash_obj_t *self, const char *algorithm) {
1413
if (strcmp(algorithm, "sha1") == 0) {
15-
self->hash_type = MBEDTLS_SSL_HASH_SHA1;
16-
mbedtls_sha1_init(&self->sha1);
17-
mbedtls_sha1_starts_ret(&self->sha1);
18-
return true;
14+
self->hash_alg = PSA_ALG_SHA_1;
1915
} else if (strcmp(algorithm, "sha256") == 0) {
20-
self->hash_type = MBEDTLS_SSL_HASH_SHA256;
21-
mbedtls_sha256_init(&self->sha256);
22-
mbedtls_sha256_starts_ret(&self->sha256, 0);
23-
return true;
16+
self->hash_alg = PSA_ALG_SHA_256;
17+
} else {
18+
return false;
2419
}
25-
return false;
20+
self->hash_op = psa_hash_operation_init();
21+
psa_hash_setup(&self->hash_op, self->hash_alg);
22+
return true;
2623
}

shared-module/ssl/SSLSocket.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,24 @@ ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t
238238
mbedtls_x509_crt_init(&o->cacert);
239239
mbedtls_x509_crt_init(&o->cert);
240240
mbedtls_pk_init(&o->pkey);
241+
#if MBEDTLS_VERSION_MAJOR < 4
241242
mbedtls_ctr_drbg_init(&o->ctr_drbg);
243+
#endif
242244
#ifdef MBEDTLS_DEBUG_C
243245
// Debug level (0-4) 1=warning, 2=info, 3=debug, 4=verbose
244246
mbedtls_debug_set_threshold(4);
245247
#endif
246248

249+
#if MBEDTLS_VERSION_MAJOR < 4
247250
mbedtls_entropy_init(&o->entropy);
248251
const byte seed[] = "upy";
249252
int ret = mbedtls_ctr_drbg_seed(&o->ctr_drbg, mbedtls_entropy_func, &o->entropy, seed, sizeof(seed));
250253
if (ret != 0) {
251254
goto cleanup;
252255
}
256+
#else
257+
int ret;
258+
#endif
253259

254260
ret = mbedtls_ssl_config_defaults(&o->conf,
255261
server_side ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT,
@@ -322,8 +328,10 @@ ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t
322328
mbedtls_x509_crt_free(&o->cacert);
323329
mbedtls_ssl_free(&o->ssl);
324330
mbedtls_ssl_config_free(&o->conf);
331+
#if MBEDTLS_VERSION_MAJOR < 4
325332
mbedtls_ctr_drbg_free(&o->ctr_drbg);
326333
mbedtls_entropy_free(&o->entropy);
334+
#endif
327335

328336
if (ret == MBEDTLS_ERR_SSL_ALLOC_FAILED) {
329337
mp_raise_type(&mp_type_MemoryError);
@@ -386,8 +394,10 @@ void common_hal_ssl_sslsocket_close(ssl_sslsocket_obj_t *self) {
386394
mbedtls_x509_crt_free(&self->cacert);
387395
mbedtls_ssl_free(&self->ssl);
388396
mbedtls_ssl_config_free(&self->conf);
397+
#if MBEDTLS_VERSION_MAJOR < 4
389398
mbedtls_ctr_drbg_free(&self->ctr_drbg);
390399
mbedtls_entropy_free(&self->entropy);
400+
#endif
391401
}
392402

393403
static void do_handshake(ssl_sslsocket_obj_t *self) {
@@ -412,8 +422,10 @@ static void do_handshake(ssl_sslsocket_obj_t *self) {
412422
mbedtls_x509_crt_free(&self->cacert);
413423
mbedtls_ssl_free(&self->ssl);
414424
mbedtls_ssl_config_free(&self->conf);
425+
#if MBEDTLS_VERSION_MAJOR < 4
415426
mbedtls_ctr_drbg_free(&self->ctr_drbg);
416427
mbedtls_entropy_free(&self->entropy);
428+
#endif
417429

418430
if (ret == MBEDTLS_ERR_SSL_ALLOC_FAILED) {
419431
mp_raise_type(&mp_type_MemoryError);

0 commit comments

Comments
 (0)