Skip to content

Commit e06e7a8

Browse files
committed
ESP32: Prepare for esp-idf 6
Minimal changes. Running this on top of the mbedtls4 branch gives full green simtest CI on v6.0-beta1. Signed-off-by: Peter M <petermm@gmail.com>
1 parent b875e60 commit e06e7a8

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

src/platforms/esp32/components/avm_builtins/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ endif()
4949

5050
# WHOLE_ARCHIVE option is supported only with esp-idf 5.x
5151
# A link option will be used with esp-idf 4.x
52-
if (IDF_VERSION_MAJOR EQUAL 5)
52+
if (IDF_VERSION_MAJOR GREATER_EQUAL 5)
5353
set(OPTIONAL_WHOLE_ARCHIVE WHOLE_ARCHIVE)
5454
else()
5555
set(OPTIONAL_WHOLE_ARCHIVE "")

src/platforms/esp32/components/avm_builtins/network_driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ static void start_network(Context *ctx, term pid, term ref, term config)
747747
// Set up STA mode, if configured
748748
//
749749
if (!IS_NULL_PTR(sta_wifi_config)) {
750-
if ((err = esp_wifi_set_config(ESP_IF_WIFI_STA, sta_wifi_config)) != ESP_OK) {
750+
if ((err = esp_wifi_set_config(WIFI_IF_STA, sta_wifi_config)) != ESP_OK) {
751751
ESP_LOGE(TAG, "Error setting STA mode config %d", err);
752752
free(sta_wifi_config);
753753
if (!IS_NULL_PTR(ap_wifi_config)) {
@@ -766,7 +766,7 @@ static void start_network(Context *ctx, term pid, term ref, term config)
766766
// Set up AP mode, if configured
767767
//
768768
if (!IS_NULL_PTR(ap_wifi_config)) {
769-
if ((err = esp_wifi_set_config(ESP_IF_WIFI_AP, ap_wifi_config)) != ESP_OK) {
769+
if ((err = esp_wifi_set_config(WIFI_IF_AP, ap_wifi_config)) != ESP_OK) {
770770
ESP_LOGE(TAG, "Error setting AP mode config %d", err);
771771
free(ap_wifi_config);
772772
term error = port_create_error_tuple(ctx, term_from_int(err));

src/platforms/esp32/components/avm_sys/CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ set(AVM_SYS_COMPONENT_SRCS
3333
"../../../../libAtomVM/portnifloader.c"
3434
)
3535

36-
if (IDF_VERSION_MAJOR GREATER_EQUAL 5)
37-
set(ADDITIONAL_COMPONENTS "esp_partition")
38-
# available starting from v4.4
36+
if (IDF_VERSION_MAJOR GREATER_EQUAL 6)
37+
set(ADDITIONAL_COMPONENTS "esp_partition" "esp_driver_ledc" "esp_driver_uart")
38+
set(ADDITIONAL_PRIV_REQUIRES "esp_hw_support")
39+
elseif (IDF_VERSION_MAJOR GREATER_EQUAL 5 AND IDF_VERSION_MAJOR LESS 6)
40+
set(ADDITIONAL_COMPONENTS "newlib" "esp_partition")
3941
set(ADDITIONAL_PRIV_REQUIRES "esp_hw_support")
4042
else()
4143
set(ADDITIONAL_COMPONENTS "")
@@ -45,7 +47,7 @@ endif()
4547
idf_component_register(
4648
SRCS ${AVM_SYS_COMPONENT_SRCS}
4749
INCLUDE_DIRS "include"
48-
REQUIRES "spi_flash" "soc" "newlib" "pthread" "vfs" "mbedtls" ${ADDITIONAL_COMPONENTS}
50+
REQUIRES "spi_flash" "soc" "pthread" "vfs" "mbedtls" ${ADDITIONAL_COMPONENTS}
4951
PRIV_REQUIRES "libatomvm" "esp_timer" ${ADDITIONAL_PRIV_REQUIRES}
5052
)
5153

@@ -54,8 +56,15 @@ target_compile_features(${COMPONENT_LIB} INTERFACE c_std_11)
5456
idf_component_get_property(soc_dir soc COMPONENT_DIR)
5557
idf_component_get_property(soc_include_dirs soc INCLUDE_DIRS)
5658
idf_build_get_property(idf_target IDF_TARGET)
59+
60+
if (IDF_VERSION_MAJOR LESS 6)
5761
idf_component_get_property(newlib_dir newlib COMPONENT_DIR)
5862
idf_component_get_property(newlib_include_dirs newlib INCLUDE_DIRS)
63+
else()
64+
idf_component_get_property(newlib_dir esp_libc COMPONENT_DIR)
65+
idf_component_get_property(newlib_include_dirs esp_libc INCLUDE_DIRS)
66+
endif()
67+
5968
idf_component_get_property(pthread_dir pthread COMPONENT_DIR)
6069
idf_component_get_property(pthread_include_dirs pthread INCLUDE_DIRS)
6170
idf_component_get_property(pthread_srcs pthread SRCS)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dependencies:
2+
"espressif/dp83848":
3+
version: "~1.0.0"
4+
rules:
5+
- if: "idf_version >=6.0"
6+
- if: target in ["esp32", "esp32p4"]
7+
- if: "$CONFIG{ETH_USE_OPENETH} == True"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-License-Identifier: Apache-2.0
2+
SPDX-FileCopyrightText: AtomVM Contributors

src/platforms/esp32/test/main/test_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
#include "sys.h"
3535

3636
#include <driver/sdmmc_host.h>
37+
38+
// Since IDF v6 it's a separate component
39+
#if ESP_IDF_VERSION_MAJOR >= 6 && CONFIG_ETH_USE_OPENETH
40+
#include "esp_eth_phy_dp83848.h"
41+
#endif
42+
3743
#include <esp_eth.h>
3844
#include <esp_event.h>
3945
#include <esp_log.h>

0 commit comments

Comments
 (0)