diff --git a/components/newlib/Kconfig b/components/newlib/Kconfig index 98e63e8c03..78eaa47376 100644 --- a/components/newlib/Kconfig +++ b/components/newlib/Kconfig @@ -1,10 +1,11 @@ menu "Newlib" choice NEWLIB_STDOUT_LINE_ENDING - prompt "Line ending for UART output" + prompt "Line ending for console output" default NEWLIB_STDOUT_LINE_ENDING_CRLF + depends on VFS_SUPPORT_IO help - This option allows configuring the desired line endings sent to UART + This option allows configuring the desired line endings sent to console when a newline ('\n', LF) appears on stdout. Three options are possible: @@ -25,10 +26,11 @@ menu "Newlib" endchoice choice NEWLIB_STDIN_LINE_ENDING - prompt "Line ending for UART input" + prompt "Line ending for console input" default NEWLIB_STDIN_LINE_ENDING_CR + depends on VFS_SUPPORT_IO help - This option allows configuring which input sequence on UART produces + This option allows configuring which input sequence on console produces a newline ('\n', LF) on stdin. Three options are possible: diff --git a/components/newlib/syscalls.c b/components/newlib/syscalls.c index 20d890b287..c60280912f 100644 --- a/components/newlib/syscalls.c +++ b/components/newlib/syscalls.c @@ -33,6 +33,9 @@ ssize_t _write_r_console(struct _reent *r, int fd, const void * data, size_t siz const char* cdata = (const char*) data; if (fd == STDOUT_FILENO || fd == STDERR_FILENO) { for (size_t i = 0; i < size; ++i) { + if (cdata[i] == '\n') { + esp_rom_output_tx_one_char('\r'); + } esp_rom_output_tx_one_char(cdata[i]); } return size; @@ -53,6 +56,9 @@ ssize_t _read_r_console(struct _reent *r, int fd, void * data, size_t size) if (status != 0) { break; } + if (cdata[received] == '\r') { + cdata[received] = '\n'; + } } if (received == 0) { errno = EWOULDBLOCK; diff --git a/tools/test_apps/system/mmu_page_size/pytest_mmu_page_size.py b/tools/test_apps/system/mmu_page_size/pytest_mmu_page_size.py index cd9eb47db2..d4cb1104af 100644 --- a/tools/test_apps/system/mmu_page_size/pytest_mmu_page_size.py +++ b/tools/test_apps/system/mmu_page_size/pytest_mmu_page_size.py @@ -27,7 +27,7 @@ def test_app_mmu_page_size_32k_and_bootloader_mmu_page_size_64k(dut: Dut, app_do dut.serial.bootloader_flash(path_to_mmu_page_size_64k_build) dut.expect('MMU page size mismatch') dut.expect('App is running') - dut.expect('Partition test done\n') + dut.expect('Partition test done') @pytest.mark.esp32c6 @@ -49,4 +49,4 @@ def test_app_mmu_page_size_64k_and_bootloader_mmu_page_size_32k(dut: Dut, app_do dut.serial.bootloader_flash(path_to_mmu_page_size_32k_build) dut.expect('MMU page size mismatch') dut.expect('App is running') - dut.expect('Partition test done\n') + dut.expect('Partition test done') diff --git a/tools/test_apps/system/unicore_bootloader/pytest_unicore_bootloader.py b/tools/test_apps/system/unicore_bootloader/pytest_unicore_bootloader.py index da16ff07db..3e6ba5b11a 100644 --- a/tools/test_apps/system/unicore_bootloader/pytest_unicore_bootloader.py +++ b/tools/test_apps/system/unicore_bootloader/pytest_unicore_bootloader.py @@ -34,7 +34,7 @@ def test_multicore_app_and_unicore_bootloader(dut: Dut, app_downloader, config) if 'psram' in config: dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator')) dut.expect('App is running') - dut.expect('NVS test done\n') + dut.expect('NVS test done') @pytest.mark.esp32 @@ -62,4 +62,4 @@ def test_unicore_app_and_multicore_bootloader(dut: Dut, app_downloader, config) if 'psram' in config: dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator')) dut.expect('App is running') - dut.expect('NVS test done\n') + dut.expect('NVS test done')