Skip to content

Commit

Permalink
Merge branch 'master' into idf-release/v5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
me-no-dev committed Jun 4, 2024
2 parents 1d7a245 + dc5bd38 commit df64b49
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 20 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
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
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
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
5 changes: 5 additions & 0 deletions libraries/NetworkClientSecure/src/ssl_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/error.h"

typedef esp_err_t (*crt_bundle_attach_cb)(void *conf);

typedef struct sslclient_context {
int socket;
mbedtls_ssl_context ssl_ctx;
Expand All @@ -24,6 +26,8 @@ typedef struct sslclient_context {
mbedtls_x509_crt client_cert;
mbedtls_pk_context client_key;

crt_bundle_attach_cb bundle_attach_cb;

unsigned long socket_timeout;
unsigned long handshake_timeout;

Expand All @@ -37,6 +41,7 @@ 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
);
void attach_ssl_certificate_bundle(sslclient_context *ssl_client, bool att);
int ssl_starttls_handshake(sslclient_context *ssl_client);
void stop_ssl_socket(sslclient_context *ssl_client);
int data_to_read(sslclient_context *ssl_client);
Expand Down
6 changes: 6 additions & 0 deletions tools/partitions/no_fs.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1F0000,
app1, app, ota_1, 0x200000,0x1F0000,
coredump, data, coredump,0x3F0000,0x10000,

0 comments on commit df64b49

Please sign in to comment.