-
Notifications
You must be signed in to change notification settings - Fork 16
Closed as not planned
Labels
Description
The compilation of the code below result in link error with "mbedtls" things.
- using Platform IO on MacOS.
- WifiProvisioner related doesn't matter. Just to make it complete (but not tested).
- HTTPClient is not an option because I'd like to use chunk send to save RAM usage.
#include <Arduino.h>
#include <list>
#include <WiFi.h>
#include <WiFiProvisioner.h>
#include <esp_http_client.h>
static const char* WEB_SERVER = "http://test.com/upload";
static const char* PASSCODE = "";
static const size_t CHUNK_SIZE = 256;
bool post_chunked(const char* ptr, size_t len)
{
esp_http_client_config_t config = {
.url = WEB_SERVER,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
// Transfer-Encoding: chunked
esp_err_t err = esp_http_client_open(client, -1);
Serial.println("HTTP: Open connection");
if (err != ESP_OK) {
Serial.print("HTTP: Failed to open connection");
Serial.println(esp_err_to_name(err));
return false;
}
size_t sent_len = 0;
while(sent_len < len)
{
size_t chunk_len = len - sent_len;
if (chunk_len > CHUNK_SIZE) {
chunk_len = CHUNK_SIZE;
}
Serial.println("HTTP: Sending a chunk");
int written = esp_http_client_write(client, ptr + sent_len, chunk_len);
if (written < 0) {
Serial.println("HTTP: Failed to write a chunk");
break;
}
sent_len += written;
}
Serial.println("HTTP: Sending chunks complete");
// get the HTTP response status code
int status = esp_http_client_fetch_headers(client);
Serial.print("HTTP: POST Status = ");
Serial.println(esp_http_client_get_status_code(client));
esp_http_client_close(client);
esp_http_client_cleanup(client);
return status == 200; // 200 OK
}
void setup() {
WiFi.mode(WIFI_STA);
WiFi.begin();
int retryCount = 0;
const int maxRetries = 10;
while (WiFi.status() != WL_CONNECTED && retryCount < maxRetries)
{
Serial.print(".");
delay(1000);
retryCount++;
}
if (WiFi.status() == WL_CONNECTED)
{
Serial.println("\nConnected to WiFi!");
Serial.println(WiFi.localIP());
}
else
{
Serial.println("\nWiFi connect failed. Start provisioning.");
WiFiProvisioner provisioner;
provisioner.getConfig().SHOW_INPUT_FIELD = false;
provisioner.getConfig().SHOW_RESET_FIELD = false;
// Set the success callback
provisioner.onSuccess(
[](const char *ssid, const char *password, const char *input)
{
Serial.printf("Provisioning successful! Connected to SSID: %s\n", ssid);
if (password)
{
Serial.printf("Password: %s\n", password);
}
});
// Start provisioning
Serial.println("Starting WiFi provisioning...");
provisioner.startProvisioning();
}
uint8_t data[1000];
for(size_t i = 0; i < 1000; i++)
data[i] = i;
post_chunked((char*)&data, 1000);
}
void loop() {
// put your main code here, to run repeatedly:
}
Here's a part of the compilation output.
Linking .pio/build/seeed_xiao_esp32_c6/firmware.elf
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: /Users/myname/.platformio/packages/framework-arduinoespressif32/tools/esp32-arduino-libs/esp32c6/lib/libesp-tls.a(esp_tls_mbedtls.c.obj): in function `.L0 ':
(.text.esp_mbedtls_read+0xa): undefined reference to `mbedtls_ssl_read'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.esp_mbedtls_write+0x22): undefined reference to `mbedtls_ssl_write'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.set_ca_cert+0x50): undefined reference to `mbedtls_ssl_conf_authmode'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: /Users/myname/.platformio/packages/framework-arduinoespressif32/tools/esp32-arduino-libs/esp32c6/lib/libesp-tls.a(esp_tls_mbedtls.c.obj): in function `.LVL30':
(.text.set_ca_cert+0x60): undefined reference to `mbedtls_ssl_conf_ca_chain'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: /Users/myname/.platformio/packages/framework-arduinoespressif32/tools/esp32-arduino-libs/esp32c6/lib/libesp-tls.a(esp_tls_mbedtls.c.obj): in function `.LVL48':
(.text.set_pki_context+0x98): undefined reference to `mbedtls_ssl_conf_own_cert'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: /Users/myname/.platformio/packages/framework-arduinoespressif32/tools/esp32-arduino-libs/esp32c6/lib/libesp-tls.a(esp_tls_mbedtls.c.obj): in function `.L0 ':
(.text.esp_mbedtls_verify_certificate+0xa): undefined reference to `mbedtls_ssl_get_verify_result'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.esp_mbedtls_handshake+0xc): undefined reference to `mbedtls_ssl_handshake'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.esp_mbedtls_get_bytes_avail+0x2): undefined reference to `mbedtls_ssl_get_bytes_avail'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.esp_mbedtls_cleanup+0x48): undefined reference to `mbedtls_ssl_config_free'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.esp_mbedtls_cleanup+0x5a): undefined reference to `mbedtls_ssl_free'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.set_client_config+0x40): undefined reference to `mbedtls_ssl_set_hostname'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.set_client_config+0x86): undefined reference to `mbedtls_ssl_config_defaults'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.set_client_config+0xb6): undefined reference to `mbedtls_ssl_conf_authmode'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.set_client_config+0x112): undefined reference to `mbedtls_ssl_conf_ciphersuites'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.set_client_config+0x136): undefined reference to `mbedtls_ssl_conf_authmode'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: /Users/myname/.platformio/packages/framework-arduinoespressif32/tools/esp32-arduino-libs/esp32c6/lib/libesp-tls.a(esp_tls_mbedtls.c.obj): in function `.LVL139':
(.text.set_client_config+0x146): undefined reference to `mbedtls_ssl_conf_ca_chain'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: /Users/myname/.platformio/packages/framework-arduinoespressif32/tools/esp32-arduino-libs/esp32c6/lib/libesp-tls.a(esp_tls_mbedtls.c.obj): in function `.L0 ':
(.text.esp_create_mbedtls_handle+0x22): undefined reference to `mbedtls_ssl_init'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.esp_create_mbedtls_handle+0x34): undefined reference to `mbedtls_ssl_config_init'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.esp_create_mbedtls_handle+0x82): undefined reference to `mbedtls_ssl_conf_rng'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.esp_create_mbedtls_handle+0xc0): undefined reference to `mbedtls_ssl_setup'
/Users/myname/.platformio/packages/[email protected]+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: (.text.esp_create_mbedtls_handle+0x11e): undefined reference to `mbedtls_ssl_set_bio'
collect2: error: ld returned 1 exit status
*** [.pio/build/seeed_xiao_esp32_c6/firmware.elf] Error 1
platform.ini for your reference.
[env:seeed_xiao_esp32_c6]
;;; Seeed XIAO ESP32-C6 board configuration
platform = https://github.com/Seeed-Studio/platform-seeedboards.git
; below results in same result
; platform = Seeed Studio
board = seeed-xiao-esp32-c6
framework = arduino
monitor_speed = 115200
lib_deps =
santerilindfors/WiFiProvisioner@^2.0.0
I tried https://github.com/pioarduino/platform-espressif32 too. It compiled well, but I2C error occured thus not usable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done