Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp32c6 compatibility #56

Open
arthurbabu opened this issue Nov 13, 2024 · 12 comments
Open

esp32c6 compatibility #56

arthurbabu opened this issue Nov 13, 2024 · 12 comments

Comments

@arthurbabu
Copy link

Hello,

I want to make an HTTPS client with TLS+Certificates.
esp32-c6 chip compatibility is foreseen ?
Or is there another way to do TLS+certificates on no_std environment ?

@bjoernQ
Copy link
Collaborator

bjoernQ commented Nov 13, 2024

Getting this to work with ESP32-C6 should be straightforward

Applying this diff should add support for C6

diff --git a/.cargo/config.toml b/.cargo/config.toml
index 4d9defd..881904f 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -19,6 +19,18 @@ rustflags = [
   "-C", "force-frame-pointers",
 ]
 
+[target.riscv32imac-unknown-none-elf]
+runner = "espflash flash --monitor --baud 921600"
+
+rustflags = [
+  "-C", "link-arg=-Tlinkall.x",
+  "-C", "link-arg=-Trom_functions.x",
+
+  # Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
+  # NOTE: May negatively impact performance of produced code
+  "-C", "force-frame-pointers",
+]
+
 [target.xtensa-esp32s2-none-elf]
 runner = "espflash flash --monitor --baud 921600"
 
diff --git a/Cargo.toml b/Cargo.toml
index 06f0722..48483b9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,7 +32,7 @@ esp-println = { version = "0.12.0", features = ["log"] }
 esp-hal-embassy = { version = "0.4.0", optional = true }
 
 embassy-time = { version = "0.3.0", optional = true }
-embassy-executor = { version = "=0.6.0", package = "embassy-executor", features = [
+embassy-executor = { version = "0.6.3", package = "embassy-executor", features = [
     "nightly",
     "integrated-timers",
 ], optional = true }
@@ -112,6 +112,14 @@ esp32c3 = [
     "esp-wifi/esp32c3",
     "esp-mbedtls/esp32c3",
 ]
+esp32c6 = [
+    "esp-hal/esp32c6",
+    "esp-hal-embassy?/esp32c6",
+    "esp-backtrace/esp32c6",
+    "esp-println/esp32c6",
+    "esp-wifi/esp32c6",
+    "esp-mbedtls/esp32c6",
+]
 esp32s2 = [
     "esp-hal/esp32s2",
     "esp-hal-embassy?/esp32s2",
@@ -152,8 +160,3 @@ edge-server = [
 edge-http = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
 edge-nal = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
 edge-nal-embassy = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
-
-# Patch before 0.6.0 got yanked
-embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
-embassy-time-driver = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
-embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
diff --git a/esp-mbedtls-sys/Cargo.toml b/esp-mbedtls-sys/Cargo.toml
index fa332c6..27ce712 100644
--- a/esp-mbedtls-sys/Cargo.toml
+++ b/esp-mbedtls-sys/Cargo.toml
@@ -14,5 +14,6 @@ default = []
 # Exactly *one* chip MUST be selected via its feature:
 esp32 = []
 esp32c3 = []
+esp32c6 = []
 esp32s2 = []
 esp32s3 = []
diff --git a/esp-mbedtls-sys/src/lib.rs b/esp-mbedtls-sys/src/lib.rs
index bf1f67a..a105dce 100644
--- a/esp-mbedtls-sys/src/lib.rs
+++ b/esp-mbedtls-sys/src/lib.rs
@@ -4,6 +4,7 @@ pub mod c_types;
 
 #[cfg_attr(feature = "esp32", path = "include/esp32.rs")]
 #[cfg_attr(feature = "esp32c3", path = "include/esp32c3.rs")]
+#[cfg_attr(feature = "esp32c6", path = "include/esp32c3.rs")]
 #[cfg_attr(feature = "esp32s2", path = "include/esp32s2.rs")]
 #[cfg_attr(feature = "esp32s3", path = "include/esp32s3.rs")]
 pub mod bindings;
diff --git a/esp-mbedtls/Cargo.toml b/esp-mbedtls/Cargo.toml
index 35e3645..1f2c4df 100644
--- a/esp-mbedtls/Cargo.toml
+++ b/esp-mbedtls/Cargo.toml
@@ -21,6 +21,7 @@ critical-section = "1.1.3"
 async = ["dep:embedded-io-async"]
 esp32 = ["esp-hal/esp32", "esp-mbedtls-sys/esp32"]
 esp32c3 = ["esp-hal/esp32c3", "esp-mbedtls-sys/esp32c3"]
+esp32c6 = ["esp-hal/esp32c6", "esp-mbedtls-sys/esp32c6"]
 esp32s2 = ["esp-hal/esp32s2", "esp-mbedtls-sys/esp32s2"]
 esp32s3 = ["esp-hal/esp32s3", "esp-mbedtls-sys/esp32s3"]
 
diff --git a/esp-mbedtls/src/bignum.rs b/esp-mbedtls/src/bignum.rs
index 9622da7..65be520 100644
--- a/esp-mbedtls/src/bignum.rs
+++ b/esp-mbedtls/src/bignum.rs
@@ -21,7 +21,7 @@ macro_rules! error_checked {
 
 #[cfg(feature = "esp32")]
 const SOC_RSA_MAX_BIT_LEN: usize = 4096;
-#[cfg(feature = "esp32c3")]
+#[cfg(any(feature = "esp32c3", feature = "esp32c6"))]
 const SOC_RSA_MAX_BIT_LEN: usize = 3072;
 #[cfg(feature = "esp32s2")]
 const SOC_RSA_MAX_BIT_LEN: usize = 4096;
@@ -319,7 +319,7 @@ pub unsafe extern "C" fn mbedtls_mpi_exp_mod(
                         mod_exp.read_results(&mut out);
                         copy_bytes(out.as_ptr(), (*Z).private_p, m_words);
                     }
-                    #[cfg(not(feature = "esp32c3"))]
+                    #[cfg(not(any(feature = "esp32c3", feature = "esp32c6")))]
                     U4096::LIMBS => {
                         const OP_SIZE: usize = U4096::LIMBS;
                         let mut base = [0u32; OP_SIZE];
diff --git a/esp-mbedtls/src/compat/mod.rs b/esp-mbedtls/src/compat/mod.rs
index d05b33c..d125246 100644
--- a/esp-mbedtls/src/compat/mod.rs
+++ b/esp-mbedtls/src/compat/mod.rs
@@ -47,3 +47,14 @@ impl core::fmt::Write for StrBuf {
         Ok(())
     }
 }
+
+#[cfg(feature = "esp32c6")]
+#[no_mangle]
+unsafe extern "C" fn memchr(ptr: *const u8, ch: u8, count: usize) -> *const u8{
+    for i in 0..count {
+        if ptr.add(i).read() == ch {
+            return ptr.add(i);
+        } 
+    }
+
+    return core::ptr::null()
+}
\ No newline at end of file
diff --git a/esp-mbedtls/src/lib.rs b/esp-mbedtls/src/lib.rs
index 578d4d2..818e6e8 100644
--- a/esp-mbedtls/src/lib.rs
+++ b/esp-mbedtls/src/lib.rs
@@ -14,7 +14,7 @@ use hal::{
 
 mod compat;
 
-#[cfg(any(feature = "esp32c3", feature = "esp32s2", feature = "esp32s3"))]
+#[cfg(any(feature = "esp32c3", feature = "esp32s2", feature = "esp32s3", feature = "esp32c6"))]
 mod bignum;
 #[cfg(not(feature = "esp32"))]
 mod sha;

Ideally, we should change the xtask to name the artifacts for RISC-V differently (= we can just use the same for all currently supported RISC-V targets) - but it should work this way

@yanshay
Copy link
Contributor

yanshay commented Nov 13, 2024

For options for no_std TLS, depending on your exact needs, see esp-rs/esp-hal#1924

@TuEmb
Copy link

TuEmb commented Jan 20, 2025

Hello @bjoernQ,

I'm trying to make it work with esp32c6. My code: https://github.com/TuEmb/esp-mbedtls/tree/esp32c6_support
I can build and run it on esp32c6, but I got a panic when making TLS connection. I think this error is from the timeout of the socket when it's stuck at making connection with server.

Image

Steps:

  1. Re-new the certs by using the command:
./genssl.sh
  1. Build and run the example async_client
SSID=<your_ssid> PASSWORD=<your_password> cargo +nightly run --release --example async_client -F esp32c6,examples-async,mtls --target riscv32imac-unknown-none-elf

Could you help me to overcome that problem ?

@bjoernQ
Copy link
Collaborator

bjoernQ commented Jan 21, 2025

I am at least sometimes able to get cargo +nightly run --release --features esp32c6 --target riscv32imac-unknown-none-elf --features esp-hal/default,examples-async --example async_client working on your branch:

Image

Sometimes it results in the same error as in your screenshot.

I can make it more realiable by adding this to .cargo/config.toml

[env]
ESP_WIFI_CONFIG_PHY_ENABLE_USB = "false"

We enable this by default now, but it will make WiFi/BLE performance worse. So, changing it seems to make things better

Probably, @AnthonyGrondin or @ivmarkov are of more help here.

@TuEmb
Copy link

TuEmb commented Jan 21, 2025

It's so strange with me. From my side, I also run the same command with you on my branch, but It's always failed even when I try with ESP_WIFI_CONFIG_PHY_ENABLE_USB = "false"

cargo +nightly run --release --features esp32c6 --target riscv32imac-unknown-none-elf  --features esp-hal/default,examples-async --example async_client

I also try with esp32 chip, it can work as your screenshot. but my esp326 can't.
Here is my DEBUG log:

admin1@admin1-Katana-15-B13VGK:~/Workspaces/esp-mbedtls$ cargo +nightly run --release --features esp32c6 --target riscv32imac-unknown-none-elf  --features esp-hal/default,examples-async --example async_client
   Compiling examples v0.1.0 (/home/admin1/Workspaces/esp-mbedtls)
    Finished `release` profile [optimized + debuginfo] target(s) in 3.64s
     Running `espflash flash --monitor --baud 921600 target/riscv32imac-unknown-none-elf/release/examples/async_client`
[2025-01-21T09:35:51Z INFO ] 🚀 A new version of espflash is available: v3.3.0
[2025-01-21T09:35:51Z INFO ] Detected 4 serial ports
[2025-01-21T09:35:51Z INFO ] Ports which match a known common dev board are highlighted
[2025-01-21T09:35:51Z INFO ] Please select a port
[2025-01-21T09:35:53Z INFO ] Serial port: '/dev/ttyACM0'
[2025-01-21T09:35:53Z INFO ] Connecting...
[2025-01-21T09:35:54Z INFO ] Using flash stub
[2025-01-21T09:35:54Z WARN ] Setting baud rate higher than 115,200 can cause issues
Chip type:         esp32c6 (revision v0.0)
Crystal frequency: 40 MHz
Flash size:        8MB
Features:          WiFi 6, BT 5
MAC address:       40:4c:ca:56:0f:64
App/part. size:    1,092,208/4,128,768 bytes, 26.45%
[2025-01-21T09:35:54Z INFO ] Segment at address '0x0' has not changed, skipping write
[2025-01-21T09:35:54Z INFO ] Segment at address '0x8000' has not changed, skipping write
[00:00:06] [========================================]     645/645     0x10000                                                                                                                               [2025-01-21T09:36:02Z INFO ] Flashing has completed!
Commands:
    CTRL+R    Reset chip
    CTRL+C    Exit

ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x15 (USB_UART_HPSYS),boot:0x3e (SPI_FAST_FLASH_BOOT)
Saved PC:0x408005b6
0x408005b6 - core::num::<impl u32>::trailing_zeros
    at /home/admin1/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/uint_macros.rs:162
SPIWP:0xee
mode:DIO, clock div:2
load:0x4086c410,len:0xd48
load:0x4086e610,len:0x2d68
load:0x40875720,len:0x1800
entry 0x4086c410
I (23) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (23) boot: compile time Jun  7 2023 08:02:08
I (24) boot: chip revision: v0.0
I (28) boot.esp32c6: SPI Speed      : 40MHz
I (33) boot.esp32c6: SPI Mode       : DIO
I (37) boot.esp32c6: SPI Flash Size : 4MB
I (42) boot: Enabling RNG early entropy source...
I (48) boot: Partition Table:
I (51) boot: ## Label            Usage          Type ST Offset   Length
I (58) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (66) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (73) boot:  2 factory          factory app      00 00 00010000 003f0000
I (81) boot: End of partition table
I (85) esp_image: segment 0: paddr=00010020 vaddr=40800000 size=0c070h ( 49264) load
I (105) esp_image: segment 1: paddr=0001c098 vaddr=4200c098 size=c6350h (811856) map
I (271) esp_image: segment 2: paddr=000e23f0 vaddr=4080c070 size=00afch (  2812) load
I (273) esp_image: segment 3: paddr=000e2ef4 vaddr=4080cb70 size=00df4h (  3572) load
I (278) esp_image: segment 4: paddr=000e3cf0 vaddr=420d3cf0 size=3625ch (221788) map
I (331) esp_image: segment 5: paddr=00119f54 vaddr=4080d964 size=00904h (  2308) load
I (332) esp_image: segment 6: paddr=0011a860 vaddr=40833058 size=001e0h (   480) load
I (339) boot: Loaded app from partition at offset 0x10000
I (342) boot: Disabling RNG early entropy source...
DEBUG - DHCP send DISCOVER to 255.255.255.255: Repr { message_type: Discover, transaction_id: 133118937, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 0.0.0.0, server_ip: 0.0.0.0, router: None, subnet_mask: None, relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: Some(Address([64, 76, 202, 86, 15, 100])), server_identifier: None, parameter_request_list: Some([1, 3, 6]), dns_servers: None, max_size: Some(1410), lease_duration: None, renew_duration: None, rebind_duration: None, additional_options: [] }
start connection task
Device capabilities: Ok(EnumSet(Client))
Starting wifi
Wifi started!
About to connect...
Failed to connect to wifi: Disconnected
About to connect...
Failed to connect to wifi: Disconnected
DEBUG - DHCP send DISCOVER to 255.255.255.255: Repr { message_type: Discover, transaction_id: 1404460363, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 0.0.0.0, server_ip: 0.0.0.0, router: None, subnet_mask: None, relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: Some(Address([64, 76, 202, 86, 15, 100])), server_identifier: None, parameter_request_list: Some([1, 3, 6]), dns_servers: None, max_size: Some(1410), lease_duration: None, renew_duration: None, rebind_duration: None, additional_options: [] }
About to connect...
Wifi connected!
DEBUG - DHCP send DISCOVER to 255.255.255.255: Repr { message_type: Discover, transaction_id: 418236822, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 0.0.0.0, server_ip: 0.0.0.0, router: None, subnet_mask: None, relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: Some(Address([64, 76, 202, 86, 15, 100])), server_identifier: None, parameter_request_list: Some([1, 3, 6]), dns_servers: None, max_size: Some(1410), lease_duration: None, renew_duration: None, rebind_duration: None, additional_options: [] }
DEBUG - DHCP recv Offer from 10.14.0.1: Repr { message_type: Offer, transaction_id: 418236822, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 10.14.0.16, server_ip: 10.14.0.1, router: Some(10.14.0.1), subnet_mask: Some(255.255.240.0), relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: None, server_identifier: Some(10.14.0.1), parameter_request_list: None, dns_servers: Some([203.113.131.2, 203.113.188.8]), max_size: None, lease_duration: Some(86400), renew_duration: Some(43200), rebind_duration: Some(75600), additional_options: [] }
DEBUG - DHCP send request to 255.255.255.255: Repr { message_type: Request, transaction_id: 1359024961, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 0.0.0.0, server_ip: 0.0.0.0, router: None, subnet_mask: None, relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: Some(10.14.0.16), client_identifier: Some(Address([64, 76, 202, 86, 15, 100])), server_identifier: Some(10.14.0.1), parameter_request_list: Some([1, 3, 6]), dns_servers: None, max_size: Some(1410), lease_duration: None, renew_duration: None, rebind_duration: None, additional_options: [] }
DEBUG - DHCP recv Ack from 10.14.0.1: Repr { message_type: Ack, transaction_id: 1359024961, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 10.14.0.16, server_ip: 10.14.0.1, router: Some(10.14.0.1), subnet_mask: Some(255.255.240.0), relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: None, server_identifier: Some(10.14.0.1), parameter_request_list: None, dns_servers: Some([203.113.131.2, 203.113.188.8]), max_size: None, lease_duration: Some(86400), renew_duration: Some(43200), rebind_duration: Some(75600), additional_options: [] }
Waiting to get IP address...
Got IP: 10.14.0.16/20
connecting...
DEBUG - address 10.14.0.1 not in neighbor cache, sending ARP request
DEBUG - retransmitting at t+0.700s
DEBUG - received a keep-alive or window probe packet, will send an ACK
DEBUG - sending sACK option with current assembler ranges
Start tls connect
DEBUG - Establishing SSL connection
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3939) => handshake
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2133) <= flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_HELLO_REQUEST
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2133) <= flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_CLIENT_HELLO
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:906) => write client hello
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_generic.c:1471) Perform PSA-based ECDH computation.
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001d)
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(0017)
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(0018)
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001e)
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(0019)
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001a)
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001b)
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001c)
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2554) => write handshake message
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2714) => write record
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2851) <= write record
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2675) <= write handshake message
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:994) <= write client hello
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2140) message length: 213, out_left: 213
DEBUG - Send 213B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2145) ssl->f_send() returned 213 (-0xffffff2b)
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2172) <= flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_SERVER_HELLO
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2039) => ssl_tls13_process_server_hello
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:3887) => read record
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 0, nb_want: 5
DEBUG - Recv 5B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 0, nb_want: 5
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2087) <= ssl_tls13_process_server_hello ( ServerHello )
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3950) <= handshake
DEBUG - received a keep-alive or window probe packet, will send an ACK
DEBUG - retransmitting at t+0.700s
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3939) => handshake
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2133) <= flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_SERVER_HELLO
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2039) => ssl_tls13_process_server_hello
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:3887) => read record
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 0, nb_want: 5
DEBUG - Recv 5B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 0, nb_want: 5
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 5, nb_want: 127
DEBUG - Recv 122B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 5, nb_want: 127
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 122 (-0xffffff86)
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:3959) <= read record
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:1520) received ServerHello message
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:492) ECDH curve: x25519
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_keys.c:1339) => ssl_tls13_generate_handshake_keys
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_keys.c:1425) <= ssl_tls13_generate_handshake_keys
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:1991) Switch to handshake keys for inbound traffic
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2087) <= ssl_tls13_process_server_hello ( ServerHello )
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2133) <= flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_ENCRYPTED_EXTENSIONS
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2220) => parse encrypted extensions
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:3887) => read record
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 0, nb_want: 5
DEBUG - Recv 5B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 0, nb_want: 5
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 5, nb_want: 6
DEBUG - Recv 1B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 5, nb_want: 6
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 1 (-0xffffffff)
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
WARN - 1 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:4771) Ignore ChangeCipherSpec in TLS 1.3 compatibility mode
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 0, nb_want: 5
DEBUG - Recv 5B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 0, nb_want: 5
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 5, nb_want: 3958
DEBUG - Recv 3953B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 5, nb_want: 3958
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 588 (-0xfffffdb4)
DEBUG - Recv 3365B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 593, nb_want: 3958
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2254) <= parse encrypted extensions
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3950) <= handshake
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3939) => handshake
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2133) <= flush output
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_ENCRYPTED_EXTENSIONS
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2220) => parse encrypted extensions
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:3887) => read record
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 593, nb_want: 5
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 593, nb_want: 3958
DEBUG - Recv 3365B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 593, nb_want: 3958
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 726 (-0xfffffd2a)
DEBUG - Recv 2639B
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 1319, nb_want: 3958
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2254) <= parse encrypted extensions
DEBUG - 2 (/home/ivan/dev/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3950) <= handshake
DEBUG - timeout exceeded


====================== PANIC ======================
panicked at examples/async_client.rs:188:29:
called `Result::unwrap()` on an `Err` value: Io(ConnectionReset)

Backtrace:

0x420109d4
0x420109d4 - async_client::____embassy_main_task::{{closure}}
    at ??:??
0x4201cb5a
0x4201cb5a - embassy_executor::raw::util::SyncUnsafeCell<T>::get
    at /home/admin1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/embassy-executor-0.7.0/src/raw/util.rs:55
0x4201ca8c
0x4201ca8c - main
    at /home/admin1/Workspaces/esp-mbedtls/examples/async_client.rs:60
0x4200c1a8
0x4200c1a8 - hal_main
    at /home/admin1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/esp-hal-0.23.1/src/lib.rs:511

@ivmarkov
Copy link
Collaborator

@bjoernQ Are we actually sure, that using an .a lib compiled for riscv32imc-unknown-none-elf is fine on a chip which does have hardware atomics enabled (i.e. on riscv32imAc-unknown-none-elf)?

@bjoernQ
Copy link
Collaborator

bjoernQ commented Jan 21, 2025

@bjoernQ Are we actually sure, that using an .a lib compiled for riscv32imc-unknown-none-elf is fine on a chip which does have hardware atomics enabled (i.e. on riscv32imAc-unknown-none-elf)?

I'd say it should be fine as long as the code doesn't try to compensate the missing atomics by calling some substitutions which are not available. But it's an assumption without any proof on my side

I wonder a bit about "DEBUG - timeout exceeded" - we don't provide timer functionality for mbedtls, do we?

@ivmarkov
Copy link
Collaborator

I wonder a bit about "DEBUG - timeout exceeded" - we don't provide timer functionality for mbedtls, do we?

Not that I'm aware of, no.

@TuEmb
Copy link

TuEmb commented Jan 21, 2025

The timeout is not from mbedtls, it's from TcpSocket (in the example, we set it to 10s).

I re-compile the mbedtls libs for esp32c6 and esp32c3 at my branch: https://github.com/TuEmb/esp-mbedtls/commits/esp32c6_support/

But the result is still the same, the async_client example can work with esp32c3. but got an error on esp32c6

@ivmarkov
Copy link
Collaborator

What happens if you increase the timeout? I wonder if the mbedtls computations is slow and therefore the timeout is hit on the next request, or is it that it gets stuck and waits for a packet that never arrives?

@TuEmb
Copy link

TuEmb commented Jan 21, 2025

I removed the timeout of the TcpSocket and re-try again. It gets stucks at mbedtls/library/ssl_tls.c:3950) <= handshake

I (23) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (23) boot: compile time Jun  7 2023 08:02:08
I (24) boot: chip revision: v0.0
I (28) boot.esp32c6: SPI Speed      : 40MHz
I (33) boot.esp32c6: SPI Mode       : DIO
I (37) boot.esp32c6: SPI Flash Size : 4MB
I (42) boot: Enabling RNG early entropy source...
I (48) boot: Partition Table:
I (51) boot: ## Label            Usage          Type ST Offset   Length
I (58) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (66) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (73) boot:  2 factory          factory app      00 00 00010000 003f0000
I (81) boot: End of partition table
I (85) esp_image: segment 0: paddr=00010020 vaddr=40800000 size=0c070h ( 49264) load
I (105) esp_image: segment 1: paddr=0001c098 vaddr=4200c098 size=c6300h (811776) map
I (271) esp_image: segment 2: paddr=000e23a0 vaddr=4080c070 size=00afch (  2812) load
I (273) esp_image: segment 3: paddr=000e2ea4 vaddr=4080cb70 size=00df4h (  3572) load
I (278) esp_image: segment 4: paddr=000e3ca0 vaddr=420d3ca0 size=362ach (221868) map
I (331) esp_image: segment 5: paddr=00119f54 vaddr=4080d964 size=00904h (  2308) load
I (332) esp_image: segment 6: paddr=0011a860 vaddr=40833058 size=001e0h (   480) load
I (339) boot: Loaded app from partition at offset 0x10000
I (342) boot: Disabling RNG early entropy source...
DEBUG - DHCP send DISCOVER to 255.255.255.255: Repr { message_type: Discover, transaction_id: 133118937, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 0.0.0.0, server_ip: 0.0.0.0, router: None, subnet_mask: None, relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: Some(Address([64, 76, 202, 86, 15, 100])), server_identifier: None, parameter_request_list: Some([1, 3, 6]), dns_servers: None, max_size: Some(1410), lease_duration: None, renew_duration: None, rebind_duration: None, additional_options: [] }
start connection task
Device capabilities: Ok(EnumSet(Client))
Starting wifi
Wifi started!
About to connect...
Failed to connect to wifi: Disconnected
About to connect...
Failed to connect to wifi: Disconnected
DEBUG - DHCP send DISCOVER to 255.255.255.255: Repr { message_type: Discover, transaction_id: 1404460363, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 0.0.0.0, server_ip: 0.0.0.0, router: None, subnet_mask: None, relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: Some(Address([64, 76, 202, 86, 15, 100])), server_identifier: None, parameter_request_list: Some([1, 3, 6]), dns_servers: None, max_size: Some(1410), lease_duration: None, renew_duration: None, rebind_duration: None, additional_options: [] }
About to connect...
Wifi connected!
DEBUG - DHCP send DISCOVER to 255.255.255.255: Repr { message_type: Discover, transaction_id: 418236822, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 0.0.0.0, server_ip: 0.0.0.0, router: None, subnet_mask: None, relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: Some(Address([64, 76, 202, 86, 15, 100])), server_identifier: None, parameter_request_list: Some([1, 3, 6]), dns_servers: None, max_size: Some(1410), lease_duration: None, renew_duration: None, rebind_duration: None, additional_options: [] }
DEBUG - DHCP recv Offer from 10.14.0.1: Repr { message_type: Offer, transaction_id: 418236822, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 10.14.0.16, server_ip: 10.14.0.1, router: Some(10.14.0.1), subnet_mask: Some(255.255.240.0), relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: None, server_identifier: Some(10.14.0.1), parameter_request_list: None, dns_servers: Some([203.113.131.2, 203.113.188.8]), max_size: None, lease_duration: Some(86400), renew_duration: Some(43200), rebind_duration: Some(75600), additional_options: [] }
DEBUG - DHCP send request to 255.255.255.255: Repr { message_type: Request, transaction_id: 1359024961, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 0.0.0.0, server_ip: 0.0.0.0, router: None, subnet_mask: None, relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: Some(10.14.0.16), client_identifier: Some(Address([64, 76, 202, 86, 15, 100])), server_identifier: Some(10.14.0.1), parameter_request_list: Some([1, 3, 6]), dns_servers: None, max_size: Some(1410), lease_duration: None, renew_duration: None, rebind_duration: None, additional_options: [] }
DEBUG - DHCP recv Ack from 10.14.0.1: Repr { message_type: Ack, transaction_id: 1359024961, secs: 0, client_hardware_address: Address([64, 76, 202, 86, 15, 100]), client_ip: 0.0.0.0, your_ip: 10.14.0.16, server_ip: 10.14.0.1, router: Some(10.14.0.1), subnet_mask: Some(255.255.240.0), relay_agent_ip: 0.0.0.0, broadcast: false, requested_ip: None, client_identifier: None, server_identifier: Some(10.14.0.1), parameter_request_list: None, dns_servers: Some([203.113.131.2, 203.113.188.8]), max_size: None, lease_duration: Some(86400), renew_duration: Some(43200), rebind_duration: Some(75600), additional_options: [] }
Waiting to get IP address...
Got IP: 10.14.0.16/20
connecting...
DEBUG - address 10.14.0.1 not in neighbor cache, sending ARP request
DEBUG - retransmitting at t+0.700s
DEBUG - received a keep-alive or window probe packet, will send an ACK
DEBUG - sending sACK option with current assembler ranges
Start tls connect
DEBUG - Establishing SSL connection
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3939) => handshake
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2133) <= flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_HELLO_REQUEST
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2133) <= flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_CLIENT_HELLO
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:906) => write client hello
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_generic.c:1471) Perform PSA-based ECDH computation.
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001d)
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(0017)
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(0018)
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001e)
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(0019)
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001a)
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001b)
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:258) got supported group(001c)
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2554) => write handshake message
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2714) => write record
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2851) <= write record
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2675) <= write handshake message
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_client.c:994) <= write client hello
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2140) message length: 213, out_left: 213
DEBUG - Send 213B
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2145) ssl->f_send() returned 213 (-0xffffff2b)
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2172) <= flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_SERVER_HELLO
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2039) => ssl_tls13_process_server_hello
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:3887) => read record
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 0, nb_want: 5
DEBUG - Recv 5B
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 0, nb_want: 5
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2087) <= ssl_tls13_process_server_hello ( ServerHello )
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3950) <= handshake
DEBUG - retransmitting at t+0.700s
DEBUG - received a keep-alive or window probe packet, will send an ACK
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3939) => handshake
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2133) <= flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_SERVER_HELLO
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2039) => ssl_tls13_process_server_hello
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:3887) => read record
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 0, nb_want: 5
DEBUG - Recv 5B
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 0, nb_want: 5
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 5, nb_want: 127
DEBUG - Recv 122B
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 5, nb_want: 127
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 122 (-0xffffff86)
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:3959) <= read record
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:1520) received ServerHello message
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:492) ECDH curve: x25519
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_keys.c:1339) => ssl_tls13_generate_handshake_keys
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_keys.c:1425) <= ssl_tls13_generate_handshake_keys
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:1991) Switch to handshake keys for inbound traffic
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2087) <= ssl_tls13_process_server_hello ( ServerHello )
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2124) => flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2133) <= flush output
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3860) client state: MBEDTLS_SSL_ENCRYPTED_EXTENSIONS
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2220) => parse encrypted extensions
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:3887) => read record
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 0, nb_want: 5
DEBUG - Recv 5B
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 0, nb_want: 5
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 5, nb_want: 6
DEBUG - Recv 1B
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 5, nb_want: 6
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 1 (-0xffffffff)
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
WARN - 1 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:4771) Ignore ChangeCipherSpec in TLS 1.3 compatibility mode
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 0, nb_want: 5
DEBUG - Recv 5B
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 0, nb_want: 5
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2111) <= fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:1926) => fetch input
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2068) in_left: 5, nb_want: 3957
DEBUG - Recv 3952B
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 5, nb_want: 3957
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2089) ssl->f_recv(_timeout)() returned 588 (-0xfffffdb4)
DEBUG - Recv 3364B
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2088) in_left: 593, nb_want: 3957
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls13_client.c:2254) <= parse encrypted extensions
DEBUG - 2 (/home/admin1/Workspaces/esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_tls.c:3950) <= handshake

@TuEmb
Copy link

TuEmb commented Jan 23, 2025

Refer the issue from: esp-rs/esp-hal#3014
turning off power saving by wifi_controller.set_power_saving(PowerSaveMode::None) solved that issue.

esp32c6 can work now, a big thank to @bugadani:

I (23) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (24) boot: compile time Jun  7 2023 08:02:08
I (25) boot: chip revision: v0.0
I (29) boot.esp32c6: SPI Speed      : 40MHz
I (33) boot.esp32c6: SPI Mode       : DIO
I (38) boot.esp32c6: SPI Flash Size : 4MB
I (43) boot: Enabling RNG early entropy source...
I (49) boot: Partition Table:
I (52) boot: ## Label            Usage          Type ST Offset   Length
I (59) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (67) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (74) boot:  2 factory          factory app      00 00 00010000 003f0000
I (82) boot: End of partition table
I (86) esp_image: segment 0: paddr=00010020 vaddr=40800000 size=0c070h ( 49264) load
I (106) esp_image: segment 1: paddr=0001c098 vaddr=4200c098 size=c63fch (812028) map
I (272) esp_image: segment 2: paddr=000e249c vaddr=4080c070 size=00afch (  2812) load
I (273) esp_image: segment 3: paddr=000e2fa0 vaddr=4080cb70 size=00df0h (  3568) load
I (278) esp_image: segment 4: paddr=000e3d98 vaddr=420d3d98 size=362cch (221900) map
I (331) esp_image: segment 5: paddr=0011a06c vaddr=4080d960 size=00908h (  2312) load
I (333) esp_image: segment 6: paddr=0011a97c vaddr=40833058 size=001e0h (   480) load
I (340) boot: Loaded app from partition at offset 0x10000
I (343) boot: Disabling RNG early entropy source...
start connection task
Device capabilities: Ok(EnumSet(Client))
Starting wifi
Wifi started!
About to connect...
Failed to connect to wifi: Disconnected
About to connect...
Failed to connect to wifi: Disconnected
About to connect...
Wifi connected!
Waiting to get IP address...
Got IP: 10.14.0.20/20
connecting...
Start tls connect
connected!
HTTP/1.0 404 Not Found
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Content-Length: 1569
Date: Thu, 23 Jan 2025 02:37:17 GMT
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/notfound</code> was not found on this server.  <ins>That’s all we know.</ins>

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants