Skip to content

Commit

Permalink
Merge branch 'bugfix/uart_vfs_select_in_iram' into 'master'
Browse files Browse the repository at this point in the history
fix: add UART VFS select callback in IRAM when CONFIG_UART_ISR_IN_IRAM is enabled

See merge request espressif/esp-idf!24899
  • Loading branch information
RathiSonika committed Nov 9, 2023
2 parents c8c7f99 + 9c82ad0 commit c824346
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/driver/uart/Kconfig.uart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ menu "UART Configuration"
config UART_ISR_IN_IRAM
bool "Place UART ISR function into IRAM"
depends on !RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH
select VFS_SELECT_IN_RAM if VFS_SUPPORT_SELECT
default n
help
If this option is not selected, UART interrupt will be disabled for a long time and
Expand Down
2 changes: 2 additions & 0 deletions components/lwip/linker.lf
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,5 @@ entries:
memp:do_memp_malloc_pool (noflash_text)
if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
* (extram_bss)
if VFS_SELECT_IN_RAM = y:
vfs_lwip:lwip_stop_socket_select_isr (noflash)
1 change: 1 addition & 0 deletions components/vfs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ list(APPEND pr driver
esp_timer)

idf_component_register(SRCS ${sources}
LDFRAGMENTS "linker.lf"
INCLUDE_DIRS include
PRIV_INCLUDE_DIRS private_include
PRIV_REQUIRES ${pr})
Expand Down
7 changes: 7 additions & 0 deletions components/vfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ menu "Virtual file system"
It is possible to suppress these debug outputs by enabling this
option.

config VFS_SELECT_IN_RAM
bool "Make VFS driver select() callbacks IRAM-safe"
default n
depends on VFS_SUPPORT_SELECT
help
If enabled, VFS driver select() callback function will be placed in IRAM.

config VFS_SUPPORT_TERMIOS
bool "Provide termios.h functions"
default y
Expand Down
6 changes: 6 additions & 0 deletions components/vfs/linker.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mapping:vfs]
archive: libvfs.a
entries:
if VFS_SELECT_IN_RAM = y:
vfs:esp_vfs_select_triggered_isr (noflash)
vfs_uart:select_notif_callback_isr (noflash)
2 changes: 1 addition & 1 deletion components/vfs/test_apps/pytest_vfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@pytest.mark.esp32h2
@pytest.mark.generic
@pytest.mark.parametrize('config', [
'default',
'default', 'iram',
], indirect=True)
def test_vfs_default(dut: Dut) -> None:
dut.run_all_single_board_cases()
Expand Down
1 change: 1 addition & 0 deletions components/vfs/test_apps/sdkconfig.ci.iram
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_UART_ISR_IN_IRAM=y
1 change: 1 addition & 0 deletions components/vfs/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ void esp_vfs_select_triggered_isr(esp_vfs_select_sem_t sem, BaseType_t *woken)
// matter here stop_socket_select() will be called for only valid VFS drivers.
const vfs_entry_t *vfs = s_vfs[i];
if (vfs != NULL && vfs->vfs.stop_socket_select_isr != NULL) {
// Note: If the UART ISR resides in IRAM, the function referenced by stop_socket_select_isr should also be placed in IRAM.
vfs->vfs.stop_socket_select_isr(sem.sem, woken);
break;
}
Expand Down

0 comments on commit c824346

Please sign in to comment.