Skip to content

Commit

Permalink
Merge branch 'master' into ci/refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Jun 4, 2024
2 parents f7cc27e + dc5bd38 commit 1472c21
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 29 deletions.
26 changes: 22 additions & 4 deletions .github/scripts/on-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ find "$PKG_DIR" -name '*.git*' -type f -delete
##
RVTC_NAME="riscv32-esp-elf-gcc"
RVTC_NEW_NAME="esp-rv32"
X32TC_NAME="xtensa-esp32-elf-gcc"
X32TC_NEW_NAME="esp-x32"
XS2TC_NAME="xtensa-esp32s2-elf-gcc"
XS2TC_NEW_NAME="esp-xs2"
XS3TC_NAME="xtensa-esp32s3-elf-gcc"
XS3TC_NEW_NAME="esp-xs3"

# Replace tools locations in platform.txt
echo "Generating platform.txt..."
Expand All @@ -224,9 +230,9 @@ sed "s/version=.*/version=$RELEASE_TAG/g" | \
sed 's/tools\.esp32-arduino-libs\.path\.windows=.*//g' | \
sed 's/{runtime\.platform\.path}.tools.esp32-arduino-libs/\{runtime.tools.esp32-arduino-libs.path\}/g' | \
sed 's/{runtime\.platform\.path}.tools.xtensa-esp-elf-gdb/\{runtime.tools.xtensa-esp-elf-gdb.path\}/g' | \
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32-elf/\{runtime.tools.xtensa-esp32-elf-gcc.path\}/g' | \
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32s2-elf/\{runtime.tools.xtensa-esp32s2-elf-gcc.path\}/g' | \
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32s3-elf/\{runtime.tools.xtensa-esp32s3-elf-gcc.path\}/g' | \
sed "s/{runtime\.platform\.path}.tools.xtensa-esp32-elf/\\{runtime.tools.$X32TC_NEW_NAME.path\\}/g" | \
sed "s/{runtime\.platform\.path}.tools.xtensa-esp32s2-elf/\\{runtime.tools.$XS2TC_NEW_NAME.path\\}/g" | \
sed "s/{runtime\.platform\.path}.tools.xtensa-esp32s3-elf/\\{runtime.tools.$XS3TC_NEW_NAME.path\\}/g" | \
sed 's/{runtime\.platform\.path}.tools.riscv32-esp-elf-gdb/\{runtime.tools.riscv32-esp-elf-gdb.path\}/g' | \
sed "s/{runtime\.platform\.path}.tools.riscv32-esp-elf/\\{runtime.tools.$RVTC_NEW_NAME.path\\}/g" | \
sed 's/{runtime\.platform\.path}.tools.esptool/\{runtime.tools.esptool_py.path\}/g' | \
Expand Down Expand Up @@ -342,7 +348,19 @@ rvtc_jq_arg="\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$RVTC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$RVTC_NAME\")).name = \"$RVTC_NEW_NAME\" |\
(.packages[0].tools[] | select(.name==\"$RVTC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].tools[] | select(.name==\"$RVTC_NAME\")).name = \"$RVTC_NEW_NAME\""
(.packages[0].tools[] | select(.name==\"$RVTC_NAME\")).name = \"$RVTC_NEW_NAME\" |\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$X32TC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$X32TC_NAME\")).name = \"$X32TC_NEW_NAME\" |\
(.packages[0].tools[] | select(.name==\"$X32TC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].tools[] | select(.name==\"$X32TC_NAME\")).name = \"$X32TC_NEW_NAME\" |\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$XS2TC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$XS2TC_NAME\")).name = \"$XS2TC_NEW_NAME\" |\
(.packages[0].tools[] | select(.name==\"$XS2TC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].tools[] | select(.name==\"$XS2TC_NAME\")).name = \"$XS2TC_NEW_NAME\" |\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$XS3TC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$XS3TC_NAME\")).name = \"$XS3TC_NEW_NAME\" |\
(.packages[0].tools[] | select(.name==\"$XS3TC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].tools[] | select(.name==\"$XS3TC_NAME\")).name = \"$XS3TC_NEW_NAME\""
cat "$PACKAGE_JSON_TEMPLATE" | jq "$rvtc_jq_arg" > "$OUTPUT_DIR/package-$LIBS_PROJ_NAME-rvfix.json"
PACKAGE_JSON_TEMPLATE="$OUTPUT_DIR/package-$LIBS_PROJ_NAME-rvfix.json"

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRA
set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS})
set(priv_includes cores/esp32/libb64)
set(requires spi_flash esp_partition mbedtls wifi_provisioning wpa_supplicant esp_adc esp_eth http_parser)
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid usb ${ARDUINO_LIBRARIES_REQUIRES})
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid usb esp_psram ${ARDUINO_LIBRARIES_REQUIRES})

idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})

Expand Down
24 changes: 24 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ esp32c2.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SP
esp32c2.menu.PartitionScheme.default.build.partitions=default
esp32c2.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
esp32c2.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
esp32c2.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
esp32c2.menu.PartitionScheme.no_fs.build.partitions=no_fs
esp32c2.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
esp32c2.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
esp32c2.menu.PartitionScheme.no_ota.build.partitions=no_ota
esp32c2.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
Expand Down Expand Up @@ -223,6 +226,9 @@ esp32h2.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
esp32h2.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
esp32h2.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
esp32h2.menu.PartitionScheme.minimal.build.partitions=minimal
esp32h2.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
esp32h2.menu.PartitionScheme.no_fs.build.partitions=no_fs
esp32h2.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
esp32h2.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
esp32h2.menu.PartitionScheme.no_ota.build.partitions=no_ota
esp32h2.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
Expand Down Expand Up @@ -400,6 +406,9 @@ esp32c6.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
esp32c6.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
esp32c6.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
esp32c6.menu.PartitionScheme.minimal.build.partitions=minimal
esp32c6.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
esp32c6.menu.PartitionScheme.no_fs.build.partitions=no_fs
esp32c6.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
esp32c6.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
esp32c6.menu.PartitionScheme.no_ota.build.partitions=no_ota
esp32c6.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
Expand Down Expand Up @@ -666,6 +675,9 @@ esp32s3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
esp32s3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
esp32s3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
esp32s3.menu.PartitionScheme.minimal.build.partitions=minimal
esp32s3.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
esp32s3.menu.PartitionScheme.no_fs.build.partitions=no_fs
esp32s3.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
esp32s3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
esp32s3.menu.PartitionScheme.no_ota.build.partitions=no_ota
esp32s3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
Expand Down Expand Up @@ -828,6 +840,9 @@ esp32c3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
esp32c3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
esp32c3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
esp32c3.menu.PartitionScheme.minimal.build.partitions=minimal
esp32c3.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
esp32c3.menu.PartitionScheme.no_fs.build.partitions=no_fs
esp32c3.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
esp32c3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
esp32c3.menu.PartitionScheme.no_ota.build.partitions=no_ota
esp32c3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
Expand Down Expand Up @@ -1026,6 +1041,9 @@ esp32s2.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
esp32s2.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
esp32s2.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
esp32s2.menu.PartitionScheme.minimal.build.partitions=minimal
esp32s2.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
esp32s2.menu.PartitionScheme.no_fs.build.partitions=no_fs
esp32s2.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
esp32s2.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
esp32s2.menu.PartitionScheme.no_ota.build.partitions=no_ota
esp32s2.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
Expand Down Expand Up @@ -1199,6 +1217,9 @@ esp32.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
esp32.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
esp32.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
esp32.menu.PartitionScheme.minimal.build.partitions=minimal
esp32.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
esp32.menu.PartitionScheme.no_fs.build.partitions=no_fs
esp32.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
esp32.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
esp32.menu.PartitionScheme.no_ota.build.partitions=no_ota
esp32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
Expand Down Expand Up @@ -1369,6 +1390,9 @@ esp32da.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
esp32da.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
esp32da.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
esp32da.menu.PartitionScheme.minimal.build.partitions=minimal
esp32da.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
esp32da.menu.PartitionScheme.no_fs.build.partitions=no_fs
esp32da.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
esp32da.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
esp32da.menu.PartitionScheme.no_ota.build.partitions=no_ota
esp32da.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
Expand Down
9 changes: 7 additions & 2 deletions cores/esp32/esp32-hal-tinyusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#elif CONFIG_IDF_TARGET_ESP32S3
#if defined __has_include && __has_include("hal/usb_phy_ll.h")
#include "hal/usb_phy_ll.h"
#else
#elif defined __has_include && __has_include("hal/usb_fsls_phy_ll.h")
#include "hal/usb_fsls_phy_ll.h"
#endif
#include "hal/usb_serial_jtag_ll.h"
Expand Down Expand Up @@ -503,8 +503,13 @@ static void usb_switch_to_cdc_jtag() {
// Initialize CDC+JTAG ISR to listen for BUS_RESET
#if defined __has_include && __has_include("hal/usb_phy_ll.h")
usb_phy_ll_int_jtag_enable(&USB_SERIAL_JTAG);
#else
#elif defined __has_include && __has_include("hal/usb_fsls_phy_ll.h")
usb_fsls_phy_ll_int_jtag_enable(&USB_SERIAL_JTAG);
#else
// usb_serial_jtag_ll_phy_set_defaults();
const usb_serial_jtag_pull_override_vals_t pull_conf = {.dp_pu = 1, .dm_pu = 0, .dp_pd = 0, .dm_pd = 0};
usb_serial_jtag_ll_phy_enable_pull_override(&pull_conf);
usb_serial_jtag_ll_phy_disable_pull_override();
#endif
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
Expand Down
16 changes: 7 additions & 9 deletions docs/en/esp-idf_component.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
Arduino as an ESP-IDF component
###############################

This method is recommended for advanced users. To use this method, you will need to have the ESP-IDF toolchain installed.

For a simplified method, see `Installing using Boards Manager <https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-boards-manager>`_.
About
-----

ESP32 Arduino lib-builder
-------------------------
You can use the Arduino framework as an ESP-IDF component. This allows you to use the Arduino framework in your ESP-IDF projects with the full flexibility of the ESP-IDF.

If you don't need any modifications in the default Arduino ESP32 core, we recommend you to install using the Boards Manager.

Arduino Lib Builder is the tool that integrates ESP-IDF into Arduino. It allows you to customize the default settings used by Espressif and try them in Arduino IDE.
This method is recommended for advanced users. To use this method, you will need to have the ESP-IDF toolchain installed.

For more information see `Arduino lib builder <https://github.com/espressif/esp32-arduino-lib-builder>`_
For a simplified method, see `Installing using Boards Manager <https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-boards-manager>`_.

If you plan to use these modified settings multiple times, for different projects and targets, you can recompile the Arduino core with the new settings using the Arduino Static Library Builder.
For more information, see the `Lib Builder documentation <lib_builder.html>`_.

Installation
------------
Expand Down
16 changes: 10 additions & 6 deletions idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ files:
dependencies:
idf: ">=5.1,<5.2"
# mdns 1.2.1 is necessary to build H2 with no WiFi
mdns: "^1.2.3"
espressif/esp_modem: "^1.1.0"
chmorgan/esp-libhelix-mp3:
version: "1.0.3"
espressif/mdns:
version: "^1.2.3"
require: public
espressif/esp_modem:
version: "^1.1.0"
espressif/esp-zboss-lib:
version: "^1.0.1"
rules:
Expand All @@ -57,7 +57,7 @@ dependencies:
version: "^1.0.1"
rules:
- if: "target != esp32c2"
esp-dsp:
espressif/esp-dsp:
version: "^1.3.4"
rules:
- if: "target != esp32c2"
Expand All @@ -77,10 +77,14 @@ dependencies:
version: "^0.1.0~1"
rules:
- if: "target != esp32c2"
joltwallet/littlefs: "^1.10.2"
espressif/esp-sr:
version: "^1.4.2"
rules:
- if: "target in [esp32s3]"
joltwallet/littlefs:
version: "^1.10.2"
chmorgan/esp-libhelix-mp3:
version: "1.0.3"
require: public
examples:
- path: ./idf_component_examples/Hello_world
38 changes: 37 additions & 1 deletion libraries/NetworkClientSecure/src/NetworkClientSecure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ NetworkClientSecure::NetworkClientSecure() {
sslclient->socket = -1;
sslclient->handshake_timeout = 120000;
_use_insecure = false;
_stillinPlainStart = false;
_ca_cert_free = false;
_cert_free = false;
_private_key_free = false;
_CA_cert = NULL;
_cert = NULL;
_private_key = NULL;
Expand Down Expand Up @@ -68,6 +72,11 @@ NetworkClientSecure::NetworkClientSecure(int sock) {
_connected = true;
}

_use_insecure = false;
_stillinPlainStart = false;
_ca_cert_free = false;
_cert_free = false;
_private_key_free = false;
_CA_cert = NULL;
_cert = NULL;
_private_key = NULL;
Expand All @@ -77,7 +86,17 @@ NetworkClientSecure::NetworkClientSecure(int sock) {
_alpn_protos = NULL;
}

NetworkClientSecure::~NetworkClientSecure() {}
NetworkClientSecure::~NetworkClientSecure() {
if (_ca_cert_free && _CA_cert) {
free((void *)_CA_cert);
}
if (_cert_free && _cert) {
free((void *)_cert);
}
if (_private_key_free && _private_key) {
free((void *)_private_key);
}
}

void NetworkClientSecure::stop() {
stop_ssl_socket(sslclient.get());
Expand Down Expand Up @@ -310,25 +329,39 @@ void NetworkClientSecure::setInsecure() {
}

void NetworkClientSecure::setCACert(const char *rootCA) {
if (_ca_cert_free && _CA_cert) {
free((void *)_CA_cert);
_ca_cert_free = false;
}
_CA_cert = rootCA;
_use_insecure = false;
}

void NetworkClientSecure::setCACertBundle(const uint8_t *bundle) {
if (bundle != NULL) {
esp_crt_bundle_set(bundle, sizeof(bundle));
attach_ssl_certificate_bundle(sslclient.get(), true);
_use_ca_bundle = true;
} else {
esp_crt_bundle_detach(NULL);
attach_ssl_certificate_bundle(sslclient.get(), false);
_use_ca_bundle = false;
}
}

void NetworkClientSecure::setCertificate(const char *client_ca) {
if (_cert_free && _cert) {
free((void *)_cert);
_cert_free = false;
}
_cert = client_ca;
}

void NetworkClientSecure::setPrivateKey(const char *private_key) {
if (_private_key_free && _private_key) {
free((void *)_private_key);
_private_key_free = false;
}
_private_key = private_key;
}

Expand Down Expand Up @@ -367,6 +400,7 @@ bool NetworkClientSecure::loadCACert(Stream &stream, size_t size) {
bool ret = false;
if (dest) {
setCACert(dest);
_ca_cert_free = true;
ret = true;
}
return ret;
Expand All @@ -380,6 +414,7 @@ bool NetworkClientSecure::loadCertificate(Stream &stream, size_t size) {
bool ret = false;
if (dest) {
setCertificate(dest);
_cert_free = true;
ret = true;
}
return ret;
Expand All @@ -393,6 +428,7 @@ bool NetworkClientSecure::loadPrivateKey(Stream &stream, size_t size) {
bool ret = false;
if (dest) {
setPrivateKey(dest);
_private_key_free = true;
ret = true;
}
return ret;
Expand Down
5 changes: 4 additions & 1 deletion libraries/NetworkClientSecure/src/NetworkClientSecure.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class NetworkClientSecure : public NetworkClient {
std::shared_ptr<sslclient_context> sslclient;

bool _use_insecure;
bool _stillinPlainStart = false;
bool _stillinPlainStart;
bool _ca_cert_free;
bool _cert_free;
bool _private_key_free;
const char *_CA_cert;
const char *_cert;
const char *_private_key;
Expand Down
21 changes: 16 additions & 5 deletions libraries/NetworkClientSecure/src/ssl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ void ssl_init(sslclient_context *ssl_client) {
ssl_client->peek_buf = -1;
}

void attach_ssl_certificate_bundle(sslclient_context *ssl_client, bool att) {
if (att) {
ssl_client->bundle_attach_cb = &esp_crt_bundle_attach;
} else {
ssl_client->bundle_attach_cb = NULL;
}
}

int start_ssl_client(
sslclient_context *ssl_client, const IPAddress &ip, uint32_t port, const char *hostname, int timeout, const char *rootCABuff, bool useRootCABundle,
const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure, const char **alpn_protos
Expand Down Expand Up @@ -195,11 +203,14 @@ int start_ssl_client(
return handle_error(ret);
}
} else if (useRootCABundle) {
log_v("Attaching root CA cert bundle");
ret = esp_crt_bundle_attach(&ssl_client->ssl_conf);

if (ret < 0) {
return handle_error(ret);
if (ssl_client->bundle_attach_cb != NULL) {
log_v("Attaching root CA cert bundle");
ret = ssl_client->bundle_attach_cb(&ssl_client->ssl_conf);
if (ret < 0) {
return handle_error(ret);
}
} else {
log_e("useRootCABundle is set, but attach_ssl_certificate_bundle(ssl, true); was not called!");
}
} else if (pskIdent != NULL && psKey != NULL) {
log_v("Setting up PSK");
Expand Down
Loading

0 comments on commit 1472c21

Please sign in to comment.