Skip to content

Commit 16f4b0f

Browse files
me-no-devigrrvaleros
authored
IDF master d93887f9f (#5336)
* Update toolchain * Update package_esp32_index.template.json * add optional component dependencies after Kconfig options are known (#5404) Until this commit, Kconfig options (e.g. CONFIG_TINYUSB_ENABLED) were used in conditions preceding idf_component_register to determine which components need to be added to `arduino` component requirements. However the Kconfig options aren't known at the early expansion stage, when the component CMakeLists.txt files are expanded the first time and requirements are evaluated. So all the conditions evaluated as if the options were not set. This commit changes the logic to only add these components as dependencies when the Kconfig options are known. Dependencies become "weak", which means that if one of the components isn't included into the build for some reason, it is not added as a dependency. This may happen, for example, if the component is not present in the `components` directory or is excluded by setting `COMPONENTS` variable in the project CMakeLists.txt file. This also ensures that if the component is not present, it will not be added as a dependency, and this will allow the build to proceed. Follow-up to #5391. Closes #5319. * IDF master d93887f9f * PlatformIO updates for CI (#5387) * Update PlatformIO CI build script - Switch to the latest toolchains 8.4.0 for ESP32, ESP32S2, ESP32C3 - Use PlatformIO from master branch for better robustness * Update package.json for PlatformIO Co-authored-by: Ivan Grokhotkov <[email protected]> Co-authored-by: Valerii Koval <[email protected]>
1 parent 780588d commit 16f4b0f

File tree

812 files changed

+29969
-7336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

812 files changed

+29969
-7336
lines changed

Diff for: .github/scripts/install-platformio-esp32.sh

+30-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,43 @@
11
#!/bin/bash
22

33
export PLATFORMIO_ESP32_PATH="$HOME/.platformio/packages/framework-arduinoespressif32"
4-
PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git#feature/idf-master"
4+
PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master"
5+
6+
XTENSA32_TOOLCHAIN_VERSION="8.4.0+2021r1"
7+
XTENSA32S2_TOOLCHAIN_VERSION="8.4.0+2021r1"
8+
RISCV_TOOLCHAIN_VERSION="8.4.0+2021r1"
9+
ESPTOOLPY_VERSION="~1.30100.0"
10+
ESPRESSIF_ORGANIZATION_NAME="espressif"
511

612
echo "Installing Python Wheel ..."
713
pip install wheel > /dev/null 2>&1
814

915
echo "Installing PlatformIO ..."
10-
pip install -U https://github.com/platformio/platformio/archive/develop.zip > /dev/null 2>&1
16+
pip install -U https://github.com/platformio/platformio/archive/master.zip > /dev/null 2>&1
1117

1218
echo "Installing Platform ESP32 ..."
13-
python -m platformio platform install $PLATFORMIO_ESP32_URL > /dev/null 2>&1
14-
15-
echo "Replacing the framework version ..."
16-
python -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/espressif32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoespressif32']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()"
19+
python -m platformio platform install $PLATFORMIO_ESP32_URL > /dev/null 2>&1
20+
21+
echo "Replacing the package versions ..."
22+
replace_script="import json; import os;"
23+
replace_script+="fp=open(os.path.expanduser('~/.platformio/platforms/espressif32/platform.json'), 'r+');"
24+
replace_script+="data=json.load(fp);"
25+
# Use framework sources from the repository
26+
replace_script+="data['packages']['framework-arduinoespressif32']['version'] = '*';"
27+
replace_script+="del data['packages']['framework-arduinoespressif32']['owner'];"
28+
# Use toolchain packages from the "espressif" organization
29+
replace_script+="data['packages']['toolchain-xtensa-esp32']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
30+
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
31+
replace_script+="data['packages']['toolchain-riscv32-esp']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
32+
# Update versions to use the upstream
33+
replace_script+="data['packages']['toolchain-xtensa-esp32']['version']='$XTENSA32_TOOLCHAIN_VERSION';"
34+
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['version']='$XTENSA32S2_TOOLCHAIN_VERSION';"
35+
replace_script+="data['packages']['toolchain-riscv32-esp']['version']='$RISCV_TOOLCHAIN_VERSION';"
36+
# esptool.py may require an upstream version (for now platformio is the owner)
37+
replace_script+="data['packages']['tool-esptoolpy']['version']='$ESPTOOLPY_VERSION';"
38+
# Save results
39+
replace_script+="fp.seek(0);fp.truncate();json.dump(data, fp, indent=2);fp.close()"
40+
python -c "$replace_script"
1741

1842
if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then
1943
echo "Linking Core..."

Diff for: CMakeLists.txt

+31-18
Original file line numberDiff line numberDiff line change
@@ -163,26 +163,16 @@ set(priv_includes cores/esp32/libb64)
163163
set(requires spi_flash mbedtls mdns esp_adc_cal wifi_provisioning nghttp)
164164
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support openssl bt esp_ipc)
165165

166-
if(IDF_TARGET MATCHES "esp32s2|esp32s3" AND CONFIG_TINYUSB_ENABLED)
167-
list(APPEND priv_requires arduino_tinyusb)
168-
endif()
169-
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoOTA)
170-
list(APPEND priv_requires esp_https_ota)
171-
endif()
172-
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_LITTLEFS)
173-
if(CONFIG_LITTLEFS_PAGE_SIZE)
174-
list(APPEND priv_requires esp_littlefs)
175-
endif()
176-
endif()
177-
178166
idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
179167

180-
if(IDF_TARGET STREQUAL "esp32")
181-
target_compile_options(${COMPONENT_TARGET} PUBLIC -DARDUINO=10812 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD="ESP32_DEV" -DARDUINO_VARIANT="esp32" -DESP32)
182-
endif()
183-
if(IDF_TARGET STREQUAL "esp32s2")
184-
target_compile_options(${COMPONENT_TARGET} PUBLIC -DARDUINO=10812 -DARDUINO_ESP32S2_DEV -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD="ESP32S2_DEV" -DARDUINO_VARIANT="esp32s2" -DESP32)
185-
endif()
168+
string(TOUPPER ${CONFIG_IDF_TARGET} idf_target_caps)
169+
target_compile_options(${COMPONENT_TARGET} PUBLIC
170+
-DARDUINO=10812
171+
-DARDUINO_${idf_target_caps}_DEV
172+
-DARDUINO_ARCH_ESP32
173+
-DARDUINO_BOARD="${idf_target_caps}_DEV"
174+
-DARDUINO_VARIANT="${CONFIG_IDF_TARGET}"
175+
-DESP32)
186176

187177
if(CONFIG_AUTOSTART_ARDUINO)
188178
# in autostart mode, arduino-esp32 contains app_main() function and needs to
@@ -195,3 +185,26 @@ if(CONFIG_AUTOSTART_ARDUINO)
195185
# (As they are C++ symbol, we need to add the C++ mangled names.)
196186
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u _Z5setupv -u _Z4loopv")
197187
endif()
188+
189+
# This function adds a dependency on the given component if the component is included into the build.
190+
function(maybe_add_component component_name)
191+
idf_build_get_property(components BUILD_COMPONENTS)
192+
if (${component_name} IN_LIST components)
193+
idf_component_get_property(lib_name ${component_name} COMPONENT_LIB)
194+
target_link_libraries(${COMPONENT_LIB} PUBLIC ${lib_name})
195+
endif()
196+
endfunction()
197+
198+
if(IDF_TARGET MATCHES "esp32" AND CONFIG_ESP_RMAKER_TASK_STACK)
199+
maybe_add_component(esp_rainmaker)
200+
maybe_add_component(qrcode)
201+
endif()
202+
if(IDF_TARGET MATCHES "esp32s2|esp32s3" AND CONFIG_TINYUSB_ENABLED)
203+
maybe_add_component(arduino_tinyusb)
204+
endif()
205+
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoOTA)
206+
maybe_add_component(esp_https_ota)
207+
endif()
208+
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_LITTLEFS)
209+
maybe_add_component(esp_littlefs)
210+
endif()

Diff for: cores/esp32/esp32-hal-tinyusb.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ __attribute__ ((weak)) bool tinyusb_vendor_control_complete_cb(uint8_t rhport, t
327327
/**
328328
* @brief Handle WebUSB and Vendor requests.
329329
*/
330-
bool tud_vendor_control_request_cb(uint8_t rhport, tusb_control_request_t const * request)
330+
bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request)
331331
{
332332
if(WEBUSB_ENABLED && (request->bRequest == VENDOR_REQUEST_WEBUSB
333333
|| (request->bRequest == VENDOR_REQUEST_MICROSOFT && request->wIndex == 7))){
@@ -346,14 +346,14 @@ bool tud_vendor_control_request_cb(uint8_t rhport, tusb_control_request_t const
346346
return tinyusb_vendor_control_request_cb(rhport, request);
347347
}
348348

349-
bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_request_t const * request)
350-
{
351-
if(!WEBUSB_ENABLED || !(request->bRequest == VENDOR_REQUEST_WEBUSB
352-
|| (request->bRequest == VENDOR_REQUEST_MICROSOFT && request->wIndex == 7))){
353-
return tinyusb_vendor_control_complete_cb(rhport, request);
354-
}
355-
return true;
356-
}
349+
// bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_request_t const * request)
350+
// {
351+
// if(!WEBUSB_ENABLED || !(request->bRequest == VENDOR_REQUEST_WEBUSB
352+
// || (request->bRequest == VENDOR_REQUEST_MICROSOFT && request->wIndex == 7))){
353+
// return tinyusb_vendor_control_complete_cb(rhport, request);
354+
// }
355+
// return true;
356+
// }
357357

358358
/*
359359
* Required Callbacks

Diff for: libraries/WiFi/src/WiFiAP.cpp

+15-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,19 @@ esp_netif_t* get_esp_interface_netif(esp_interface_t interface);
5050
esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPAddress(), IPAddress gateway=IPAddress(), IPAddress subnet=IPAddress());
5151
static bool softap_config_equal(const wifi_config_t& lhs, const wifi_config_t& rhs);
5252

53-
53+
static size_t _wifi_strncpy(char * dst, const char * src, size_t dst_len){
54+
if(!dst || !src || !dst_len){
55+
return 0;
56+
}
57+
size_t src_len = strlen(src);
58+
if(src_len >= dst_len){
59+
src_len = dst_len;
60+
} else {
61+
src_len += 1;
62+
}
63+
memcpy(dst, src, src_len);
64+
return src_len;
65+
}
5466

5567
/**
5668
* compare two AP configurations
@@ -98,12 +110,12 @@ void wifi_softap_config(wifi_config_t *wifi_config, const char * ssid=NULL, cons
98110
wifi_config->ap.password[0] = 0;
99111
wifi_config->ap.ftm_responder = ftm_responder;
100112
if(ssid != NULL && ssid[0] != 0){
101-
strncpy((char*)wifi_config->ap.ssid, ssid, 32);
113+
_wifi_strncpy((char*)wifi_config->ap.ssid, ssid, 32);
102114
wifi_config->ap.ssid_len = strlen(ssid);
103115
if(password != NULL && password[0] != 0){
104116
wifi_config->ap.authmode = authmode;
105117
wifi_config->ap.pairwise_cipher = WIFI_CIPHER_TYPE_CCMP; // Disable by default enabled insecure TKIP and use just CCMP.
106-
strncpy((char*)wifi_config->ap.password, password, 64);
118+
_wifi_strncpy((char*)wifi_config->ap.password, password, 64);
107119
}
108120
}
109121
}

Diff for: libraries/WiFi/src/WiFiGeneric.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ extern "C" {
4141
#include "lwip/err.h"
4242
#include "lwip/dns.h"
4343
#include "dhcpserver/dhcpserver_options.h"
44-
#include "esp_ipc.h"
4544

4645
} //extern "C"
4746

Diff for: libraries/WiFi/src/WiFiSTA.cpp

+18-4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ esp_err_t set_esp_interface_dns(esp_interface_t interface, IPAddress main_dns=IP
5353
esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPAddress(), IPAddress gateway=IPAddress(), IPAddress subnet=IPAddress());
5454
static bool sta_config_equal(const wifi_config_t& lhs, const wifi_config_t& rhs);
5555

56+
static size_t _wifi_strncpy(char * dst, const char * src, size_t dst_len){
57+
if(!dst || !src || !dst_len){
58+
return 0;
59+
}
60+
size_t src_len = strlen(src);
61+
if(src_len >= dst_len){
62+
src_len = dst_len;
63+
} else {
64+
src_len += 1;
65+
}
66+
memcpy(dst, src, src_len);
67+
return src_len;
68+
}
69+
5670

5771
/**
5872
* compare two STA configurations
@@ -82,10 +96,10 @@ static void wifi_sta_config(wifi_config_t * wifi_config, const char * ssid=NULL,
8296
wifi_config->sta.ssid[0] = 0;
8397
wifi_config->sta.password[0] = 0;
8498
if(ssid != NULL && ssid[0] != 0){
85-
strncpy((char*)wifi_config->sta.ssid, ssid, 32);
99+
_wifi_strncpy((char*)wifi_config->sta.ssid, ssid, 32);
86100
if(password != NULL && password[0] != 0){
87101
wifi_config->sta.threshold.authmode = WIFI_AUTH_WEP;
88-
strncpy((char*)wifi_config->sta.password, password, 64);
102+
_wifi_strncpy((char*)wifi_config->sta.password, password, 64);
89103
}
90104
if(bssid != NULL){
91105
wifi_config->sta.bssid_set = 1;
@@ -161,11 +175,11 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
161175

162176
wifi_config_t conf;
163177
memset(&conf, 0, sizeof(wifi_config_t));
164-
strncpy(reinterpret_cast<char*>(conf.sta.ssid), ssid, 32);
178+
_wifi_strncpy(reinterpret_cast<char*>(conf.sta.ssid), ssid, 32);
165179
conf.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; //force full scan to be able to choose the nearest / strongest AP
166180

167181
if(passphrase) {
168-
strncpy(reinterpret_cast<char*>(conf.sta.password), passphrase, 64);
182+
_wifi_strncpy(reinterpret_cast<char*>(conf.sta.password), passphrase, 64);
169183
}
170184

171185
wifi_config_t current_conf;

Diff for: package.json

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{
2-
"name": "framework-arduinoespressif32",
3-
"description": "Arduino Wiring-based Framework (ESP32 Core)",
4-
"version": "0.0.0",
2+
"name": "framework-arduinoespressif32",
3+
"version": "0.0.0",
4+
"description": "Arduino Wiring-based Framework for the Espressif ESP32, ESP32-S and ESP32-C series of SoCs",
5+
"keywords": [
6+
"framework",
7+
"arduino",
8+
"espressif",
9+
"esp32"
10+
],
11+
"license": "LGPL-2.1-or-later",
12+
"repository": {
13+
"type": "git",
514
"url": "https://github.com/espressif/arduino-esp32"
6-
}
15+
}
16+
}

0 commit comments

Comments
 (0)