mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-03 10:30:58 +02:00
fix(esp_vfs_console): Update placement of cdcacm_xx_cb when ETS print enabled
This commit is contained in:
@@ -51,14 +51,6 @@ entries:
|
||||
if APP_BUILD_TYPE_RAM = n:
|
||||
image_process (noflash)
|
||||
|
||||
[mapping:vfs_cdcacm]
|
||||
archive: libvfs.a
|
||||
entries:
|
||||
if ESP_SYSTEM_IN_IRAM = y:
|
||||
if ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF:
|
||||
vfs_cdcacm:cdcacm_tx_cb (noflash)
|
||||
vfs_cdcacm:cdcacm_rx_cb (noflash)
|
||||
|
||||
[mapping:esp_system_hal]
|
||||
archive: libhal.a
|
||||
entries:
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -494,11 +494,13 @@ void esp_usb_console_write_char(char c)
|
||||
esp_usb_console_write_buf(&c, 1);
|
||||
}
|
||||
}
|
||||
static inline void write_lock_acquire(void)
|
||||
|
||||
static inline __attribute__((always_inline)) void write_lock_acquire(void)
|
||||
{
|
||||
portENTER_CRITICAL_SAFE(&s_lock);
|
||||
}
|
||||
static inline void write_lock_release(void)
|
||||
|
||||
static inline __attribute__((always_inline)) void write_lock_release(void)
|
||||
{
|
||||
portEXIT_CRITICAL_SAFE(&s_lock);
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ set(srcs "vfs_console.c")
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS include
|
||||
PRIV_REQUIRES vfs esp_driver_uart esp_driver_usb_serial_jtag
|
||||
)
|
||||
LDFRAGMENTS linker.lf)
|
||||
|
||||
if(CONFIG_ESP_CONSOLE_USB_CDC)
|
||||
target_sources(${COMPONENT_LIB} PRIVATE "vfs_cdcacm.c")
|
||||
|
6
components/esp_vfs_console/linker.lf
Normal file
6
components/esp_vfs_console/linker.lf
Normal file
@@ -0,0 +1,6 @@
|
||||
[mapping:esp_vfs_console]
|
||||
archive: libesp_vfs_console.a
|
||||
entries:
|
||||
if ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF:
|
||||
vfs_cdcacm:cdcacm_tx_cb (noflash)
|
||||
vfs_cdcacm:cdcacm_rx_cb (noflash)
|
@@ -7,3 +7,17 @@ set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(usb_cdc_vfs_test)
|
||||
|
||||
idf_build_get_property(elf EXECUTABLE)
|
||||
if(CONFIG_COMPILER_DUMP_RTL_FILES)
|
||||
add_custom_target(check_test_app_sections ALL
|
||||
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
|
||||
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/
|
||||
--elf-file ${CMAKE_BINARY_DIR}/*.elf
|
||||
find-refs
|
||||
--from-sections=.iram0.text
|
||||
--to-sections=.flash.text,.flash.rodata
|
||||
--exit-code
|
||||
DEPENDS ${elf}
|
||||
)
|
||||
endif()
|
||||
|
@@ -8,8 +8,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/errno.h>
|
||||
#include "unity.h"
|
||||
#include "unity_test_utils_cache.h"
|
||||
#include "esp_private/usb_console.h"
|
||||
#include "esp_vfs_cdcacm.h"
|
||||
#include "esp_rom_sys.h"
|
||||
|
||||
static void flush_write(void)
|
||||
{
|
||||
@@ -263,6 +265,39 @@ static void test_usb_cdc_read_no_exit_on_newline_reception(void)
|
||||
vTaskDelay(2); // wait for tasks to exit
|
||||
}
|
||||
|
||||
static void IRAM_ATTR test_input_output_post_cache_disable(void *args)
|
||||
{
|
||||
static DRAM_ATTR const char test_msg[] = "test_message\n";
|
||||
esp_rom_printf(test_msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test that the tx and rx cb are placed in IRAM correctly
|
||||
*/
|
||||
static void test_usb_cdc_ets_printf_cache_disabled(void)
|
||||
{
|
||||
test_setup(__func__, sizeof(__func__));
|
||||
|
||||
/* make sure blocking mode is enabled */
|
||||
int flags = fcntl(STDIN_FILENO, F_GETFL, 0);
|
||||
fcntl(STDIN_FILENO, F_SETFL, flags & (~O_NONBLOCK));
|
||||
|
||||
#if CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF
|
||||
unity_utils_run_cache_disable_stub(test_input_output_post_cache_disable, NULL);
|
||||
#else
|
||||
#error This test must run with CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF enabled
|
||||
#endif
|
||||
|
||||
// send message to the test environment to report successful test
|
||||
char ready_msg[] = "successful test\n";
|
||||
write(fileno(stdout), ready_msg, sizeof(ready_msg));
|
||||
|
||||
fcntl(STDIN_FILENO, F_SETFL, flags);
|
||||
esp_vfs_dev_cdcacm_set_rx_line_endings(ESP_LINE_ENDINGS_CRLF);
|
||||
esp_vfs_dev_cdcacm_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
|
||||
vTaskDelay(2); // wait for tasks to exit
|
||||
}
|
||||
|
||||
/* Always make sure that the function calling sequence in the main
|
||||
* function matches the expected order in the pytest function.
|
||||
*/
|
||||
@@ -272,4 +307,5 @@ void app_main(void)
|
||||
test_usb_cdc_read_non_blocking();
|
||||
test_usb_cdc_read_blocking();
|
||||
test_usb_cdc_read_no_exit_on_newline_reception();
|
||||
test_usb_cdc_ets_printf_cache_disabled();
|
||||
}
|
||||
|
@@ -37,3 +37,8 @@ def test_usb_cdc_vfs_default(dut: Dut) -> None:
|
||||
dut.expect_exact('test_usb_cdc_read_no_exit_on_newline_reception', timeout=2)
|
||||
dut.expect_exact('ready to receive', timeout=2)
|
||||
dut.write('!(@*#&(!*@&#((SDasdkjhad\nce')
|
||||
|
||||
# test run: test_usb_cdc_ets_printf_cache_disabled
|
||||
dut.expect_exact('test_usb_cdc_ets_printf_cache_disabled', timeout=2)
|
||||
dut.expect_exact('test_message', timeout=2)
|
||||
dut.expect_exact('successful test', timeout=2)
|
||||
|
@@ -1,8 +1,12 @@
|
||||
# Enable Unity fixture support
|
||||
CONFIG_UNITY_ENABLE_FIXTURE=n
|
||||
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y
|
||||
CONFIG_COMPILER_DUMP_RTL_FILES=y
|
||||
|
||||
# Custom partition table for this test app
|
||||
CONFIG_ESP_TASK_WDT_INIT=n
|
||||
|
||||
CONFIG_ESP_CONSOLE_USB_CDC=y
|
||||
|
||||
# one test requires this option to be enabled
|
||||
CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF=y
|
||||
|
Reference in New Issue
Block a user