Skip to content

Commit dc8c876

Browse files
SohKamYung-Espressifmantriyogesh
authored andcommitted
bugfix(uart_building): Fix IRAM usage when building uart for IDF 5.5
ESP-IDF v5.5 fails to build for UART transport on co-processor due to not enough IRAM space - reduce IRAM use by moving ringbuffer to flash - added note to UART doc about this - cause a build error if UART is build without config to reduce IRAM usage
1 parent 1de76d1 commit dc8c876

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

docs/uart.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ Configure the co-processor project using
146146
idf.py menuconfig
147147
```
148148
149+
> [!NOTE]
150+
> When building with ESP-IDF v5.5, you may see this build error:
151+
>
152+
> `Building for UART transport can fail due to lack of IRAM space`
153+
>
154+
> To reduce IRAM usage, you can either:
155+
> - run `idf.py menuconfig` and enable `Component config` --> `ESP Ringbuf` ---> `Place non-ISR ringbuf functions into flash`, or
156+
> - uncomment `CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y` in `slave/sdkconfig.defaults.esp32` and regenerate the `sdkconfig`
157+
149158
#### 6.2.1 Transport config
150159
- Navigate to "Example configuration" -> "Bus Config in between Host and Co-processor"
151160
- In "Transport layer", select "UART"

slave/main/uart_slave_api.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
// SPDX-License-Identifier: Apache-2.0
2-
// Copyright 2015-2024 Espressif Systems (Shanghai) PTE LTD
3-
//
4-
// Licensed under the Apache License, Version 2.0 (the "License");
5-
// you may not use this file except in compliance with the License.
6-
// You may obtain a copy of the License at
7-
//
8-
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
10-
// Unless required by applicable law or agreed to in writing, software
11-
// distributed under the License is distributed on an "AS IS" BASIS,
12-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// See the License for the specific language governing permissions and
14-
// limitations under the License.
1+
/*
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
156

167
#include "sdkconfig.h"
178

@@ -28,6 +19,7 @@
2819
#include "interface.h"
2920
#include "mempool.h"
3021
#include "stats.h"
22+
#include "esp_idf_version.h"
3123
#include "esp_hosted_interface.h"
3224
#include "esp_hosted_transport.h"
3325
#include "esp_hosted_transport_init.h"
@@ -47,6 +39,20 @@
4739

4840
#define BUFFER_SIZE MAX_TRANSPORT_BUF_SIZE
4941

42+
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) && (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0))
43+
/**
44+
* For ESP-IDF v5.5, Building with UART Transport can fail due to
45+
* lack of IRAM space.
46+
* To reduce IRAM usage, `CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y`
47+
* should be enabled
48+
*/
49+
#if !CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH
50+
#error Building for UART transport can fail due to lack of IRAM space
51+
#error To free up IRAM, enable Component config --> ESP Ringbuf ---> Place non-ISR ringbuf functions into flash
52+
#error or uncomment CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y in sdkconfig.defaults.esp32 and regenerate sdkconfig
53+
#endif
54+
#endif
55+
5056
static const char TAG[] = "UART_DRIVER";
5157

5258
// UART is low throughput, so throttling should not be needed

slave/sdkconfig.ci.uart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
### To reduce IRAM usage on ESP-IDF v5.5
2+
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y
3+
14
CONFIG_ESP_UART_HOST_INTERFACE=y

slave/sdkconfig.defaults.esp32

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.esp32.csv"
3737
# iram text saving
3838
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
3939

40+
# for ESP-IDF v5.5, enable this setting if building for UART transport
41+
# needed to reduce iram usage
42+
# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y
43+
4044
# OS
4145
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
4246
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF=n

0 commit comments

Comments
 (0)