Skip to content

Support for Espressif chipsets via ESP-IDF #2142

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

Draft
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

vikramdattu
Copy link
Contributor

@vikramdattu vikramdattu commented May 23, 2025

*** This is a placeholder PR: Not to be merged ****

This PR is meant to showcase the work which will bring the support for ESP-IDF build support and hence the Espressif chipsets.

Structure:

  • Changes specific to ESP-IDF are put under esp_port directory.
  • Go to the example webrtc_classic and build it as ESP-IDF example.

Setup ESP-IDF

Setup ESP_IDF with release/v5.4 branch: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/linux-macos-setup.html

BUILD

cd esp_port/examples/webrtc_classic
idf.py set-target esp32s3 # Or esp32p4 etc
idf.py build

Flash the code on chip and run monitor

idf.py flash
idf.py monitor

The work is under progress, will keep rebasing as and when common functionality code keeps getting into main repository.

@sirknightj @unicornss

We have two options:

  1. Upstream and merge all the changes to this repo: Not as-is of course and will have reviews from structure and code point of view
  2. The esp_port maintained by Espressif with some suitable name under espressif/ organisation. It will use amazon-kinesis-video-sdk-c as a submodule or need developer to set path of cloned repo.

We can keep this PR for discussion ground continue discussion on other aspects of how best we can go about this. I prefer the option 1, simply because it remains maintained under single roof without needing to constant rebasing.

…bsockets

 - This way, one could write a new CMakeLists.txt, with ApiCalls using different websocket implementation
 - One should simply remove existing Signaling.c and LwsApiCalls.c from compilation and add their own
 - mbedtls 2.8.x is getting out of support: https://github.com/Mbed-TLS/mbedtls/releases/tag/mbedtls-2.28.10
 - Clone mbedtls 3.6.x instead of 2.8.x via CMake dependencies
 - Add related code to mbedtls usage keeping the 2.8.x support intact under mbedtls version macros
 - This release handles mbedtls_3.x version support and has some fixes
 - Cleanup: removed libwebsocket patches as they are not needed anymore
 - New API tlsSessionStartWithHostname can receive optional hostname and set the same
 - It is recommened to set the hostname and is on by default for mbedtls v3.6.3 and above
 - Since we receive ICE server credentials via secure API and anyway are use DTLS as WebRTC standard,
 we could skip this, but let's follow the recommendation as precaution
 - Newer(3.6.x) mbedtls versions does not test builds on GCC versions as old as 4.4
 - We keep this test for older mbedtls version (2.28.x)
 - Since, we only use a single ICE server config anyway. To save space we might want to set the value to say 1
 - The received list may have more than one entries. We gracefully drop the remaining entries and continue.
 - Handle partial writes by sending data in multiple iterations
 - Use retries when message send fails
 - Track and handle message receive if in parts using `receiveMessage` var
 - Retries increased from 3 to 10
 - Consider ENOMEM or PBUF errors also for retries

These changes help to retain sockets longer for embedded devices
 - Added ifaddr altenate for ESP-IDF
 - Created abstracted API for IDF_CMAKE platform to query local IP
 - Do not treat SO_SNDBUF not available as fatal
 - Use custom thread implementation for receiveLwsMessageWrapper
 - Custom thread implementation for connectionListener
 - Cleanly added the support under esp_port directory
 - Added ESP specific components, submodules and an webrtc_classic example
 - Also added `app_common` needed as a common functionality for webrtc example/s.
 - Also added network_adapter example: Needed when we want to use the webrtc_classic on P4+C6 board
 - Added esp_websocket_client over libwebsockets for ESP-IDF
 - Using this as default for ESP port as it provides better flexibility for ESP-IDF
@vikramdattu vikramdattu force-pushed the esp_amazon_kvs_sdk_c branch from a2a10df to d9ab49b Compare May 28, 2025 11:56
 - Also moved AWS config options from examples to app_common Kconfig
 - Setting env variable is not an elegant solution to pass credentials
 - Pass these in config structure instead
@vikramdattu vikramdattu force-pushed the esp_amazon_kvs_sdk_c branch from d9ab49b to b3e9d05 Compare May 28, 2025 11:57
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

Successfully merging this pull request may close these issues.

1 participant