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

Remove SPI RAM requirement #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ESP32-S3 target
CONFIG_IDF_TARGET="esp32s3"
CONFIG_IDF_TARGET_ESP32S3=y

# ESP Event Loop on Linux
CONFIG_ESP_EVENT_POST_FROM_ISR=n
CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=n
Expand All @@ -11,16 +15,17 @@ CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y

# libpeer requires large stack allocations
CONFIG_ESP_MAIN_TASK_STACK_SIZE=16384
CONFIG_ESP_MAIN_TASK_STACK_SIZE=10240

# Defaults to partitions.csv
CONFIG_PARTITION_TABLE_CUSTOM=y

# Set highest CPU Freq
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y

CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
# No PSRAM by default.
# CONFIG_SPIRAM=y
# CONFIG_SPIRAM_MODE_OCT=y

# Disable Watchdog
# CONFIG_ESP_INT_WDT is not set
Expand All @@ -29,3 +34,7 @@ CONFIG_SPIRAM_MODE_OCT=y
# Enable Compiler Optimization
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y

# Optimize internal SRAM utilization.
# Allocate WiFi TX buffer dynamically to reduce max RAM usage.
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y
18 changes: 14 additions & 4 deletions src/webrtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,20 @@ static void oai_onconnectionstatechange_task(PeerConnectionState state,
#endif
} else if (state == PEER_CONNECTION_CONNECTED) {
#ifndef LINUX_BUILD
StackType_t *stack_memory = (StackType_t *)heap_caps_malloc(
20000 * sizeof(StackType_t), MALLOC_CAP_SPIRAM);
xTaskCreateStaticPinnedToCore(oai_send_audio_task, "audio_publisher", 20000,
NULL, 7, stack_memory, &task_buffer, 0);
constexpr size_t stack_size = 20000;
// Allocate the stack memory from the PSRAM if available. Otherwise,
// allocate from the internal memory.
StackType_t *stack_memory = (StackType_t *)heap_caps_malloc_prefer(
stack_size * sizeof(StackType_t), 2,
MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT,
MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (stack_memory == nullptr) {
ESP_LOGE(LOG_TAG, "Failed to allocate stack memory for audio publisher.");
esp_restart();
}
xTaskCreateStaticPinnedToCore(oai_send_audio_task, "audio_publisher",
stack_size, NULL, 7, stack_memory,
&task_buffer, 0);
#endif
}
}
Expand Down